<jupyter_start><jupyter_text>Multilabel Classifier<jupyter_code>classifier_multilabel = ft.supervised('emotion.train.txt', 'multilabel_emotion', label_prefix='__label__', loss= "hs")
result_multilabel = classifier_multilabel.test('emotion.test.txt')
multilabel_restored = ft.load_model("multilabel_emotion.bin", label_prefix='__label__')
result_multilabel = multilabel_restored.test('emotion.test.txt')
p = result_multilabel.precision
r = result_multilabel.recall
F_measure = 2 * ((p * r) / (p + r))
print ('P@1:', p)
print ('R@1:', r)
print ("F1-Score:", F_measure)
#Custom testing.
texts = ["I want to kiss you."]
labels = multilabel_restored.predict_proba(texts, k=4)
labels = labels[0]
print (labels)<jupyter_output>[('happy', 0.699219), ('sad', 0.187935), ('neutral', 0.0747394), ('anger', 0.0344718)]<jupyter_text>Binary Classifier<jupyter_code>classifier_binary = ft.supervised('binary_train.txt', 'binary_emotion', label_prefix='__label__')
result_binary = classifier_binary.test('binary_test.txt')
binary_restored = ft.load_model("binary_emotion.bin", label_prefix='__label__')
result_binary = binary_restored.test('binary_test.txt')
pb = result_binary.precision
rb = result_binary.recall
F_measure_b = 2 * ((pb * rb) / (pb + rb))
print ('P@1:', pb)
print ('R@1:', rb)
print ("F1-Score:", F_measure_b)
#Custom testing.
texts_b = ["I want to kiss you"]
labels_b = binary_restored.predict_proba(texts_b , k=2)
labels_b = labels_b[0]
print (labels_b)<jupyter_output>[('positive', 0.716797), ('negative', 0.28125)]
{'fraction_non_alphanumeric': 0.16589861751152074, 'fraction_numerical': 0.03620803159973667, 'mean_word_length': 7.9411764705882355, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '581380', 'license': 'MIT', 'n_tokens_mistral': 615, 'n_tokens_neox': 571, 'n_words': 103, 'path': 'Text_Emo_Rec_Models/Fasttext_model.ipynb', 'repo_name': 'Erenaliaslangiray/ENGR497_Emotion_Recog', 'size': '1519'}