コード例 #1
0
# creating testing and training labels
train_labels = np.array(train['bot'])
test_labels = np.array(test['bot'])

# creating index and columns for our final dataframe which contains results
index = [
    'NaiveBayes - Gaussion', 'SVM', 'Decision Tree', 'Random Forest',
    'Adaboost'
]
columns = ['Accuracy', 'Precision', 'Recall', 'F1_Score', 'AUC_Score']

# Initializing the dataframe
results = pd.DataFrame(index=index, columns=columns)

# Calling each of the ML methods and saving the corresponding returned accuracy
naiveb = NaiveBayes.TrainTest(features_train, train_labels, features_test,
                              test_labels)
results['Accuracy']['NaiveBayes - Gaussion'], results['Precision'][
    'NaiveBayes - Gaussion'], results['Recall'][
        'NaiveBayes - Gaussion'], results['F1_Score'][
            'NaiveBayes - Gaussion'], results['AUC_Score'][
                'NaiveBayes - Gaussion'] = naiveb

svm = SVM.TrainTest(features_train, train_labels, features_test, test_labels)
results['Accuracy']['SVM'], results['Precision']['SVM'], results['Recall'][
    'SVM'], results['F1_Score']['SVM'], results['AUC_Score']['SVM'] = svm

dtree = DecisionTree.TrainTest(features_train, train_labels, features_test,
                               test_labels)
results['Accuracy']['Decision Tree'], results['Precision'][
    'Decision Tree'], results['Recall']['Decision Tree'], results['F1_Score'][
        'Decision Tree'], results['AUC_Score']['Decision Tree'] = dtree