Commit cccb5fe5 authored by Xavier PILLET's avatar Xavier PILLET

COmpeltion of classifierManager.sciprt.scriptPCA code.

parent 6d12115c
No preview for this file type
......@@ -14,7 +14,7 @@ One the Hubble/source folder :
- Constant: where all the constants are stored.
- Event: contains the data for a DataFrame row (for instance, the data for one resource access on OCR).
- Sequence: contains sequences of Event (for one single user).
- SequenceDf ("Df" for "DataFrame"): Singleton, Façade which handles the Sequence objects.
- SequenceDf ("Df" for "DataFrame"): Singleton, façade which handles the Sequence objects.
- package ocr: contains all the son-classes of the model package, specialized for ocr.
- package oulad: contains all the son-classes of the model package, specialized for oulad.
......@@ -29,7 +29,7 @@ One the Hubble/source folder :
- package classifierManager (please see the corresponding UML diagram inside Doc):
- Constant: where all the constants are stored.
- Classifier: perform the classification tasks. It's a facade for the Script interface-like classes.
- package model: contains the warpers from ScikitLearn algorithmes to the Scripts classes.
- package script: contains the interface-like classes with the different algorithme to perform classification.
- package model: contains the warpers from ScikitLearn algorithms to the Scripts classes.
- package script: contains the interface-like classes with the different algorithm to perform classification.
- package ocr: contains the testUnit class and the main module for ocr.
- package oulad: contains the testUnit class and the main module for oulad.
\ No newline at end of file
......@@ -31,14 +31,14 @@ class Test(unittest.TestCase):
idCourse = idCourse
idCourses = [idCourse, idCourse]
print("type(idCourse) : " + str(type(idCourse)))
classifier = Classifier(idCourses, groups)
classifier.setScriptClassifier(script)
print("\n******* classifier.predictionTask(idCourse) *******\n")
classifier.predictionTask(idCourse)
'''
print("\n******* classifier.predictionTaskNTimes(idCourse, whereToCut=100, ntime=2) *******\n")
classifier.predictionTaskNTimes(idCourse, whereToCut=100, ntime=2)
......@@ -50,7 +50,7 @@ class Test(unittest.TestCase):
print("\n******* classifier.predictionTaskForAllPeriods() *******\n")
print("The generation of all the period is too long.")
classifier.predictionTaskForAllPeriods(ntime = 2)
'''
if __name__ == "__main__":
#import sys;sys.argv = ['', 'Test.testLoadFeature']
unittest.main()
\ No newline at end of file
......@@ -334,6 +334,11 @@ class ScriptClassifier:
"Features"+str(classifier.getFeatures())+".p")
with open(fileNameSavedResult, "wb") as fileResult:
print("dictResult : " + str(dictResult) + "\n")
print("classifier.getFeatures() : " + str(classifier.getFeatures()) + "\n")
print("classifier.getWhereToCuts : " + str(classifier.getWhereToCuts) + "\n")
print("classifier.getWhereToCutUnity() : " + str(classifier.getWhereToCutUnity()) + "\n")
print("groups : " + str(groups) + "\n")
pickle.dump((dictResult, classifier.getFeatures(), classifier.getWhereToCuts, classifier.getWhereToCutUnity(), groups), fileResult)
fileNameResult = os.path.join(classifier.getDirectoryExperiment(), "Latex"+
......
......@@ -40,6 +40,8 @@ from classifierManager.script.scriptClassifier import ScriptClassifier
from featureManager.ocr.featureGroup import FeatureGroup
from sequenceManager.ocr.loaderSession import LoaderSession
from exportManager import exportLatex
class ScriptNeuralNetwork(ScriptClassifier):
......@@ -259,8 +261,8 @@ class ScriptNeuralNetwork(ScriptClassifier):
fileResult.write("\n final nbEpoch: epoch("+str(np.average(nbEpochs))+") \n")
return (accuracies, listScore, accuraciesPerCourse)
"""
def predictionTaskForAllCoursesPeriod(self, groups, ntime = 10):
def predictionTaskForAllPeriods(self, classifier, ntime = 10):
'''
......@@ -285,10 +287,12 @@ class ScriptNeuralNetwork(ScriptClassifier):
''' one entry per course. Each value is a list of tuple [(accuracyGroup1, accuracyGroup2, ...), (...)]. One tuple per period'''
dictAccuracyPerGroup = {}
accuracies = []
whereToCuts = classifier.getWhereToCuts()
groups = classifier.getNameGroups()
for w in self.whereToCuts:
(accuracies, listScore, _) = self.predictionTaskForAllCourses(groups,
for w in whereToCuts:
(accuracies, listScore, _) = self.predictionTaskForAllCourses(classifier,
whereToCut=w, ntime=ntime)
print("accuracies:"+str(accuracies))
......@@ -309,7 +313,11 @@ class ScriptNeuralNetwork(ScriptClassifier):
"layers="+str(self.hiddenLayers)+
".p"))
with open(fileNameSavedResult, "wb") as fileResult:
pickle.dump((accuracies, dictAccuracyPerGroup, w, groups), fileResult)
# TODO: check if the data saved here is all we wants. For comparison, in sciprtClassifier, the corresponding line (337) is :
#pickle.dump((dictResult, classifier.getFeatures(), classifier.getWhereToCuts, classifier.getWhereToCutUnity(), groups), fileResult)
pickle.dump((accuracies, dictAccuracyPerGroup, classifier.getFeatures(), w, classifier.getWhereToCutUnity(), groups), fileResult)
fileNameResult = os.path.join(ScriptNeuralNetwork.DIRECTORY_EXPERIMENT, ("Latex"+
self.fileName+
......@@ -318,7 +326,7 @@ class ScriptNeuralNetwork(ScriptClassifier):
"layers="+str(self.hiddenLayers)+
".txt"))
exportLatex.exportResult(fileNameResult, dictAccuracyPerGroup)
"""
def launchTestForAllCoursesHiddenLayers(self, groups, features):
'''
Test on all course for a list of hiddenLayers
......
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