<jupyter_start><jupyter_text>All models got `get_proba` parameters.If True, it will returned probability every classes. Else, it will return highest probability class. **Default is False.**  Load multinomial model<jupyter_code>model = malaya.toxic.multinomial()
model.predict(string)
model.predict(string,get_proba=True)
model.predict(another_string)
model.predict(another_string,get_proba=True)
model.predict_batch([string,another_string])
model.predict_batch([string,another_string],get_proba=True)<jupyter_output><empty_output><jupyter_text>Load logistics model<jupyter_code>model = malaya.toxic.logistic()
model.predict(string)
model.predict_batch([string,another_string],get_proba=True)<jupyter_output><empty_output><jupyter_text>List available deep learning models<jupyter_code>malaya.toxic.available_deep_model()<jupyter_output><empty_output><jupyter_text>Load deep learning model<jupyter_code>for model in malaya.toxic.available_deep_model():
    print('Testing %s model'%(model))
    deep_model = malaya.toxic.deep_model(model = model)
    print(deep_model.predict(string))
    print(deep_model.predict_batch([string, another_string]))
    print(deep_model.predict_batch([string, another_string],get_proba=True))
    print()<jupyter_output>Testing bahdanau model
[]
[[], ['toxic']]
[{'toxic': 0.002869941, 'severe_toxic': 3.2165422e-05, 'obscene': 0.00031625567, 'threat': 3.3063134e-05, 'insult': 0.0001917479, 'identity_hate': 5.6739605e-05}, {'toxic': 0.844302, 'severe_toxic': 0.0026948317, 'obscene': 0.048079386, 'threat': 0.00057450164, 'insult': 0.108705685, 'identity_hate': 0.06786145}]

Testing hierarchical model
[]
[[], ['toxic']]
[{'toxic': 0.01493061, 'severe_toxic': 0.0001075709, 'obscene': 0.003345779, 'threat': 0.00030603033, 'insult': 0.0016393703, 'identity_hate': 0.00053284934}, {'toxic': 0.69389653, 'severe_toxic': 0.002439942, 'obscene': 0.033795167, 'threat': 0.002826849, 'insult': 0.30907208, 'identity_hate': 0.06302948}]

Testing luong model
[]
[[], ['toxic']]
[{'toxic': 0.0038469762, 'severe_toxic': 0.00030991185, 'obscene': 0.0025601375, 'threat': 0.0010575273, 'insult': 0.0007667314, 'identity_hate': 0.0008790955}, {'toxic': 0.9767287, 'severe_toxic': 0.021122381, 'obscene': 0.25348565, 'threat': 0.0[...]<jupyter_text>Unsupervised important words learning<jupyter_code>import matplotlib.pyplot as plt
import seaborn as sns
sns.set() # i just really like seaborn colors<jupyter_output><empty_output><jupyter_text>We need to set `get_proba` become True to get the 'attention'.  Visualizing bahdanau model<jupyter_code>model = malaya.toxic.deep_model('bahdanau')
result = model.predict(another_string,get_proba=True)['attention']

plt.figure(figsize = (15, 7))
labels = [r[0] for r in result]
val = [r[1] for r in result]
aranged = [i for i in range(len(labels))]
plt.bar(aranged, val)
plt.xticks(aranged, labels, rotation = 'vertical')
plt.show()<jupyter_output><empty_output><jupyter_text>Visualizing luong model<jupyter_code>model = malaya.toxic.deep_model('luong')
result = model.predict(another_string,get_proba=True)['attention']

plt.figure(figsize = (15, 7))
labels = [r[0] for r in result]
val = [r[1] for r in result]
aranged = [i for i in range(len(labels))]
plt.bar(aranged, val)
plt.xticks(aranged, labels, rotation = 'vertical')
plt.show()<jupyter_output><empty_output><jupyter_text>Visualizing hierarchical model<jupyter_code>model = malaya.toxic.deep_model('hierarchical')
result = model.predict(another_string,get_proba=True)['attention']

plt.figure(figsize = (15, 7))
labels = [r[0] for r in result]
val = [r[1] for r in result]
aranged = [i for i in range(len(labels))]
plt.bar(aranged, val)
plt.xticks(aranged, labels, rotation = 'vertical')
plt.show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15386666666666668, 'fraction_numerical': 0.09466666666666666, 'mean_word_length': 7.995203836930456, 'pattern_counts': {'":': 0, '<': 32, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '623946', 'license': 'MIT', 'n_tokens_mistral': 1673, 'n_tokens_neox': 1383, 'n_words': 265, 'path': 'example/toxicity/load-toxic.ipynb', 'repo_name': 'fossabot/Malaya', 'size': '3750'}