Skip to content
Snippets Groups Projects
Commit 1b1c5360 authored by titouan's avatar titouan
Browse files

Méthode computePredictionFile ajoutée pour la création du fichier CC2

parent f7b52fff
No related branches found
No related tags found
No related merge requests found
# Default ignored files
/shelf/
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>
\ No newline at end of file
......@@ -95,7 +95,6 @@ def fitFromHisto(S, algo):
S_train, S_test, y_train, y_test = train_test_split(S, y, test_size=0.2, random_state=42)
X_train = np.array([np.array(l["X_histo"]) for l in S_train])
print(len(X_train[0]))
algo.fit(X_train, y_train)
......@@ -129,7 +128,7 @@ def computeError(S):
for image in S:
if image["y_true_class"] != image["y_predicted_class"]:
error_count += 1
return error_count
return round(error_count/len(S), 2)
def computeScore(S):
......@@ -138,5 +137,23 @@ def computeScore(S):
for image in S:
y_true_classes.append(image["y_true_class"])
y_predicted_classes.append(image["y_predicted_class"])
return accuracy_score(y_true_classes,y_predicted_classes)
return round(accuracy_score(y_true_classes,y_predicted_classes),2) * 100
def computePredictionFile(classifier):
file = open("syntax_error.txt", "w+")
file.write("# T. Bertochio, N. Efremon, P. Vigeolas-Choury (Equipe Syntax Error) \n")
file.write("# SVC \n")
file.write("# Concaténation: histogramme de couleurs, niveaux de gris \n")
S = buildSampleFromPath("./Init/Mer", "./Init/Ailleurs")
classifier, S_test, y_test, S_train, y_train = fitFromHisto(S, classifier)
predictFromHisto(S, classifier)
for image in S:
image_name = os.path.split(image["name_path"])[1]
file.write(image_name+" "+str(image["y_predicted_class"])+"\n")
file.write("# EE = "+ str(computeError(S_train))+"\n")
file.write("# ER = "+ str(computeError(S_test))+"\n")
file.write("# SC = "+ str(computeScore(S_test))+"% \n")
file.close()
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment