Commit b209d90e authored by estellearrc's avatar estellearrc
Browse files

confusion matrices ok

parent 3a2554ad
......@@ -5,7 +5,7 @@ import pandas as pd
from matplotlib import pyplot as plt
from sklearn import tree
from sklearn.metrics import ConfusionMatrixDisplay, confusion_matrix, accuracy_score
import graphviz
# import graphviz
from CART import CartTree
......@@ -49,16 +49,21 @@ def trainCart(comparisonSKLearn=False, path=""):
# PREDICTIONS
Y_pred = myclassifier.predict(X_test)
print("accuracy :", accuracy_score(Y_test, Y_pred))
print(confusion_matrix(Y_test, Y_pred, labels=classes))
ConfusionMatrixDisplay.from_predictions(
Y_test, Y_pred, display_labels=classes)
cm = confusion_matrix(Y_test, Y_pred, labels=classes)
print(cm)
disp = ConfusionMatrixDisplay(cm, display_labels=classes)
disp.plot()
plt.title("My predictions")
plt.show()
Y_pred = clf.predict(X_test)
print("accuracy :", accuracy_score(Y_test, Y_pred))
ConfusionMatrixDisplay.from_predictions(
Y_test, Y_pred, display_labels=classes)
cm = confusion_matrix(Y_test, Y_pred, labels=classes)
print(cm)
disp = ConfusionMatrixDisplay(cm, display_labels=classes)
disp.plot()
plt.title("SKLEARN")
plt.show()
......
......@@ -6,9 +6,12 @@ int main(int argc, char **argv)
if (argc > 1)
{
file_path = argv[1];
auto start_chrono = std::chrono::high_resolution_clock::now();
std::map<FTYPE, DataVector> features = compute_features_for(file_path);
std::string result = RFHardAlgo(features);
std::cout<<result<<std::endl;
auto stop_chrono = std::chrono::high_resolution_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::microseconds>(stop_chrono - start_chrono);
std::cout << "Predicted genre (version weight saved): " << result << " with " << duration.count() << " microseconds" << std::endl;
}
// std::cout << "Compute accuracy for soft voting... \n";
// real soft_accuracy = compute_accuracy_CART("../../RF/file_test.csv", (vFunctionCallCART)RFSoftAlgo, matrix);
......
import cmath
import pandas as pd
import numpy as np
from sklearn import svm
......@@ -7,12 +8,12 @@ from sklearn.model_selection import train_test_split
from sklearn.svm import LinearSVC
from matplotlib import pyplot as plt
from sklearn.metrics import ConfusionMatrixDisplay, confusion_matrix
import graphviz
# import graphviz
from sklearn.metrics import accuracy_score
from sklearn.model_selection import GridSearchCV
"""
File to launch from racine or change path
File to launch from root or change path
"""
......@@ -71,9 +72,10 @@ def trainSVM(saveWeighs=False, saveAlgo=False, path=''):
# PREDICTIONS
Y_pred = svm_clf.predict(X_test)
print("accuracy:", accuracy_score(Y_test, Y_pred))
print(confusion_matrix(Y_test, Y_pred, labels=classes))
ConfusionMatrixDisplay.from_predictions(
Y_test, Y_pred, display_labels=classes)
cm = confusion_matrix(Y_test, Y_pred, labels=classes)
print(cm)
disp = ConfusionMatrixDisplay(cm, display_labels=classes)
disp.plot()
plt.title("My predictions")
plt.show()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment