print("F1 Score: {}".format(f1_score(y_pred_m, y_test_m, average = 'weighted')))
    print("Precision: {}".format(precision_score(y_pred_m, y_test_m, average='weighted')))
    print("Recall: {}".format(recall_score(y_pred_m, y_test_m, average='weighted')))    
    
    #Performance Report, Motions
    for particle_type in class_names_p:
        pred_score_p = best_p.score(X_test_p[y_test_p.id==particle_type], y_test_p[y_test_p.id==particle_type])
        print("{} accuracy = {p:8.4f}".format(particle_type, p=pred_score_p))
    print("Cohen Kappa: {}".format(cohen_kappa_score(y_pred_p, y_test_p)))   
    print("Accuracy: {}".format(accuracy_score(y_pred_p, y_test_p)))
    print("F1 Score: {}".format(f1_score(y_pred_p, y_test_p, average = 'weighted')))
    print("Precision: {}".format(precision_score(y_pred_p, y_test_p, average='weighted')))
    print("Recall: {}".format(recall_score(y_pred_p, y_test_p, average='weighted')))    


learning_curves = False
if learning_curves:
    plot_learning_curves(model_m, X_train1_m, y_train1_m, low_limit=0.5, title = "Decision Tree - Motions Set - Post-Tuning Learning Curves")
    plot_learning_curves(model_p, X_train1_p, y_train1_p, low_limit=0.5, title = "Decision Tree - Particles Set - Post-Tuning Learning Curves")
    
    
print("time elapsed: {}".format(time.time()-t0))




# References
# https://medium.com/@rnbrown/creating-and-visualizing-decision-trees-with-python-f8e8fa394176
# https://towardsdatascience.com/decision-trees-pruning-4241cc266fef
# https://stats.stackexchange.com/questions/28029/training-a-decision-tree-against-unbalanced-data
# https://www.geeksforgeeks.org/decision-tree-implementation-python/
Beispiel #2
0
    print("Cohen Kappa: {}".format(cohen_kappa_score(y_pred, y_test)))
    print("Accuracy: {}".format(accuracy_score(y_pred, y_test)))
    print("Balanced Accuracy: {}".format(
        balanced_accuracy_score(y_pred, y_test)))
    print("F1 Score: {}".format(f1_score(y_pred, y_test, average='weighted')))
    print("Precision: {}".format(
        precision_score(y_pred, y_test, average='weighted')))
    print("Recall: {}".format(recall_score(y_pred, y_test,
                                           average='weighted')))

learning_curves = False
if learning_curves:
    estimator = KerasClassifier(build_fn=classification_model,
                                epochs=epo,
                                batch_size=bat,
                                verbose=0)
    #scorer = make_scorer(cohen_kappa_score)
    plot_learning_curves(
        estimator,
        X_train1,
        y_train1,
        title="Neural Network - Particles Set - Post-Tuning Learning Curves",
        low_limit=0.6)

print("time elapsed: {}".format(time.time() - t0))

#References:
# borrowed heavily from
# https://www.tensorflow.org/tutorials/keras/basic_classification
# https://machinelearningmastery.com/multi-class-classification-tutorial-keras-deep-learning-library/
# https://machinelearningmastery.com/display-deep-learning-model-training-history-in-keras/
Beispiel #3
0
        pred_score_p = best_p.score(X_test_p[y_test_p.id == particle_type],
                                    y_test_p[y_test_p.id == particle_type])
        print("{} accuracy = {p:8.4f}".format(particle_type, p=pred_score_p))
    print("Cohen Kappa: {}".format(cohen_kappa_score(y_pred_p, y_test_p)))
    print("Accuracy: {}".format(accuracy_score(y_pred_p, y_test_p)))
    print("F1 Score: {}".format(
        f1_score(y_pred_p, y_test_p, average='weighted')))
    print("Precision: {}".format(
        precision_score(y_pred_p, y_test_p, average='weighted')))
    print("Recall: {}".format(
        recall_score(y_pred_p, y_test_p, average='weighted')))

learning_curves = False
if learning_curves:
    plot_learning_curves(
        model_m,
        X_train1_m,
        y_train1_m,
        low_limit=0.6,
        title="SVM - Motions Set - Post-Tuning Learning Curves")
    plot_learning_curves(
        model_p,
        X_train1_p,
        y_train1_p,
        low_limit=0.6,
        title="SVM - Particles Set - Post-Tuning Learning Curves")

print("time elapsed: {}".format(time.time() - t0))

#References
#https://scikit-learn.org/stable/modules/svm.html