diff --git a/AIclassifier.py b/AIclassifier.py index 4eebd8d..a22f7c7 100644 --- a/AIclassifier.py +++ b/AIclassifier.py @@ -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) @@ -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) diff --git a/output/AI Classifier/1Label_confusion_matrix_NonNorm.png b/output/AI Classifier/1Label_confusion_matrix_NonNorm.png index 634961b..337cc7e 100644 Binary files a/output/AI Classifier/1Label_confusion_matrix_NonNorm.png and b/output/AI Classifier/1Label_confusion_matrix_NonNorm.png differ diff --git a/output/AI Classifier/1Label_confusion_matrix_NormTrue.png b/output/AI Classifier/1Label_confusion_matrix_NormTrue.png index 64ff216..dfe3cbb 100644 Binary files a/output/AI Classifier/1Label_confusion_matrix_NormTrue.png and b/output/AI Classifier/1Label_confusion_matrix_NormTrue.png differ diff --git a/output/AI Classifier/1labelPredictionsStatsTest.txt b/output/AI Classifier/1labelPredictionsStatsTest.txt index d6e096b..4c8e323 100644 --- a/output/AI Classifier/1labelPredictionsStatsTest.txt +++ b/output/AI Classifier/1labelPredictionsStatsTest.txt @@ -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. ]