Skip to content

Commit

Permalink
removed some comments and rerun bigrams again
Browse files Browse the repository at this point in the history
  • Loading branch information
gicraveiro committed Feb 5, 2022
1 parent 7f207b1 commit 396f888
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 23 deletions.
28 changes: 14 additions & 14 deletions AIclassifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,8 @@ def create_vectors_list(sents, conversion_dict):
print('Feature:',feature[1],'Score:',feature[0])

# Predicting
predictions = model.predict(dev_matrix_array)
#predictions = model.predict(test_matrix_array)
#predictions = model.predict(dev_matrix_array)
predictions = model.predict(test_matrix_array)
#predictions = model.predict(dev_word_embedding_features)
#predictions = model.predict(test_word_embedding_features)

Expand All @@ -305,29 +305,29 @@ def create_vectors_list(sents, conversion_dict):
print("Predictions:\n", predictions)

# Confusion matrix
#test_list = test_labels_primary.tolist()
dev_list = dev_labels_primary.tolist()
test_list = test_labels_primary.tolist()
#dev_list = dev_labels_primary.tolist()
pred_list = [pred for pred in predictions]
labels=[1,3,5,4,2]
path='output/AI Classifier/dev_1Label_confusion_matrix_NormTrue.png'
path='output/AI Classifier/1Label_confusion_matrix_NormTrue.png'
display_labels=['Commit to privacy', 'Declare opinion about privacy','Not applicable','Related to privacy','Violate privacy']
# NORMALIZED CONFUSION MATRIX
create_confusion_matrix(dev_list, pred_list, "true", path, labels, display_labels)
#create_confusion_matrix(test_list, pred_list, "true", path, labels, display_labels)
#create_confusion_matrix(dev_list, pred_list, "true", path, labels, display_labels)
create_confusion_matrix(test_list, pred_list, "true", path, labels, display_labels)
# NON NORMALIZED CONFUSION MATRIX
path='output/AI Classifier/dev_1Label_confusion_matrix_NonNorm.png'
create_confusion_matrix(dev_list, pred_list, None, path, labels, display_labels)
#create_confusion_matrix(test_list, pred_list, None, path, labels, display_labels)
path='output/AI Classifier/1Label_confusion_matrix_NonNorm.png'
#create_confusion_matrix(dev_list, pred_list, None, path, labels, display_labels)
create_confusion_matrix(test_list, pred_list, None, path, labels, display_labels)

# FLAG - CHECK IF CONFUSION MATRIX IS CORRECT FOR EVERY LABEL
path='output/AI Classifier/1labelPredictionsStatsDev.txt'
#path='output/AI Classifier/1labelPredictionsStatsTest.txt'
#path='output/AI Classifier/1labelPredictionsStatsDev.txt'
path='output/AI Classifier/1labelPredictionsStatsTest.txt'
os.makedirs(os.path.dirname(path), exist_ok=True)
with open(path, 'w') as file:
#print("Performance measures - Unigram Dictionary - MLP Word Embeddings\n", file=file)
print("Performance measures - Unigram Dictionary - Adaboost\n", file=file)
write_output_stats_file(path, "Dev", dev_labels_primary, predictions, labels)
#write_output_stats_file(path, "Test", test_labels_primary, predictions, labels)
#write_output_stats_file(path, "Dev", dev_labels_primary, predictions, labels)
write_output_stats_file(path, "Test", test_labels_primary, predictions, labels)

# TO DO: WRITE PREDICTIONS JSON FILE -> LEARN HOW TO TRANSFORM ADABOOST OUTPUT IN DICT ( LIST OF ({"text":sentence['text'], "label":label}))
#write_predictions_file("Dev", dev_pred_dict)
Expand Down
Binary file modified output/AI Classifier/1Label_confusion_matrix_NonNorm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified output/AI Classifier/1Label_confusion_matrix_NormTrue.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 9 additions & 9 deletions output/AI Classifier/1labelPredictionsStatsTest.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Performance measures - Unigram Dictionary - MLP Word Embeddings
Performance measures - Unigram Dictionary - Adaboost

Test set:

Precision macro: 0.534
Precision Individually: [0.778 0. 0.73 0.75 0.412]
Recall macro: 0.469
Recall Individually: [0.5 0. 0.871 0.273 0.7 ]
F1 Score micro: 0.657
F1 Score macro: 0.464
F1 Score weighted: 0.638
F1 Score Individually: [0.609 0. 0.794 0.4 0.519]
Precision macro: 0.257
Precision Individually: [0.8 0. 0.484 0. 0. ]
Recall macro: 0.251
Recall Individually: [0.286 0. 0.968 0. 0. ]
F1 Score micro: 0.507
F1 Score macro: 0.213
F1 Score weighted: 0.386
F1 Score Individually: [0.421 0. 0.645 0. 0. ]


0 comments on commit 396f888

Please sign in to comment.