Commit 702e9be6 authored by Antoine PIGEAU's avatar Antoine PIGEAU
Browse files

update test

parent a0e58826
......@@ -61,20 +61,32 @@ class Constant(ConstantInterface):
IMPLEMENTED_FEATURES_BEST_LR_25_EDM = [4, 7, 8, 10, 11]
IMPLEMENTED_FEATURES_BEST_LR_100 = [7, 6, 12, 28, 8, 10, 14, 11, 27, 30, 9, 5]
IMPLEMENTED_FEATURES_BACKWARD_BEST_LR_100 = [7, 6, 12, 28, 8, 10, 14, 11, 27, 30, 9, 5]
IMPLEMENTED_FEATURES_BEST_LR_75 = [7, 14, 30, 32, 9, 27]
IMPLEMENTED_FEATURES_BACKWARD_BEST_LR_75 = [7, 14, 30, 32, 9, 27]
IMPLEMENTED_FEATURES_BEST_LR_50 = [27, 7, 28]
IMPLEMENTED_FEATURES_BACKWARD_BEST_LR_50 = [27, 7, 28]
IMPLEMENTED_FEATURES_BEST_LR_25 = [7, 14, 19, 22, 30, 35, 9, 13, 23, 36, 4, 12, 15, 18, 20, 21, 28]
IMPLEMENTED_FEATURES_BACKWARD_BEST_LR_25 = [7, 14, 19, 22, 30, 35, 9, 13, 23, 36, 4, 12, 15, 18, 20, 21, 28]
IMPLEMENTED_FEATURES_BACKWARD_BEST_LR = { 25 : IMPLEMENTED_FEATURES_BACKWARD_BEST_LR_25,
50 : IMPLEMENTED_FEATURES_BACKWARD_BEST_LR_50,
75 : IMPLEMENTED_FEATURES_BACKWARD_BEST_LR_75,
100 : IMPLEMENTED_FEATURES_BACKWARD_BEST_LR_100}
IMPLEMENTED_FEATURES_BEST_BACKWARD_LR_MERGED_ALL_COURSES_25 = [0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 28, 30, 32, 33, 34, 35, 36]
IMPLEMENTED_FEATURES_BEST_FORWARD_LR_MERGED_ALL_COURSES_25 = [30, 35, 34, 11, 33]
IMPLEMENTED_FEATURES_BEST_FORWARD_LR_MERGED_ALL_COURSES_50 = [27, 32, 9, 22]
IMPLEMENTED_FEATURES_BEST_FORWARD_LR_MERGED_ALL_COURSES_75 = [27, 28, 32, 9, 10, 35, 5, 15]
IMPLEMENTED_FEATURES_BEST_FORWARD_LR_MERGED_ALL_COURSES_100 = [27, 1, 7, 23]
IMPLEMENTED_FEATURES_FORWARD_BEST_MERGED_LR = { 25 : IMPLEMENTED_FEATURES_BEST_FORWARD_LR_MERGED_ALL_COURSES_25,
50 : IMPLEMENTED_FEATURES_BEST_FORWARD_LR_MERGED_ALL_COURSES_50,
75 : IMPLEMENTED_FEATURES_BEST_FORWARD_LR_MERGED_ALL_COURSES_75,
100 : IMPLEMENTED_FEATURES_BEST_FORWARD_LR_MERGED_ALL_COURSES_100}
IMPLEMENTED_FEATURES_BEST_LR = { 25 : IMPLEMENTED_FEATURES_BEST_LR_25,
50 : IMPLEMENTED_FEATURES_BEST_LR_50,
75 : IMPLEMENTED_FEATURES_BEST_LR_75,
100 : IMPLEMENTED_FEATURES_BEST_LR_100}
IMPLEMENTED_FEATURES_BEST_LR_MERGED_ALL_COURSES_25 = [0, 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 25, 26, 27, 28, 30, 32, 33, 34, 35, 36]
'''
Best features for each course independently
......
# -*- coding: UTF-8 -*-
'''
Created on 29-Apr-2014
This file is part of Hubble-UserProfile.
Hubble-UserProfile is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Hubble-UserProfile is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Hubble-UserProfile. If not, see <http://www.gnu.org/licenses/>.
@author: Antoine Pigeau
'''
import os
from datetime import datetime
from exportManager.exportBestFeature import ExportBestFeature
from project.projectParameters import ProjectParameters
from classifierManager.ocr.classifier import Classifier
from classifierManager.constant import Constant as ConstantClassifier
from featureManager.ocr.constant import Constant as ConstantFeature
from model.ocr.constant import Constant as ConstantModel
from model.ocr.course import Course
if __name__ == "__main__":
print("start of the process boosting")
startTime = datetime.now()
classifier = Classifier(idCourses = ConstantModel.ID_COURSES,
nameGroups = [ConstantModel.GROUP_SUCCEED_ALL_USERS, ConstantModel.GROUP_FAILED_ALL_USERS],
features = ConstantFeature.IMPLEMENTED_FEATURES,
typeFeatureGroup = ConstantFeature.TYPE_FEATURE_GROUP,
hiddenLayers = None,
featuresByCourse = ConstantFeature.BEST_LR_FEATURE_ALL_COURSES,
featuresByPeriod = None)
# classifier = Classifier(idCourses=ConstantModel.ID_COURSES,
# nameGroups=[ConstantModel.GROUP_SUCCEED_ALL_USERS, ConstantModel.GROUP_FAILED_ALL_USERS],
# features = ConstantFeature.IMPLEMENTED_FEATURES_SESSION_TEST,
# typeFeatureGroup = ConstantFeature.TYPE_FEATURE_GROUP_SEQUENTIAL_N,
# hiddenLayers=[16])
classifier.setScriptClassifier(ConstantClassifier.LogisticRegression)
'''
classification task process
'''
# course = Course(ConstantModel.COURSE_ID_ARDUINO)
# groups = [ConstantModel.GROUP_SUCCEED_ALL_USERS, ConstantModel.GROUP_FAILED_ALL_USERS]
''' classification one time '''
# (accuracy, confusionMatrix, weightOrEpoch, rocScore) = classifier.predictionTask(course, whereToCut=25)
# print("accuracy="+str(accuracy))
# print(confusionMatrix)
# print("epochOrWeight="+str(weightOrEpoch))
# print("auc="+str(rocScore))
''' classification N times '''
# (accuracy, confusionMatrix, weightOrEpoch, rocScore) = classifier.predictionTaskNTimes(course,
# whereToCut=25,
# ntime=1,
# cache = False)
# print("accuracy: ", accuracy)
# print("confusion Matrix:\n", confusionMatrix)
# print("Weight or Epoch: ", weightOrEpoch)
# print("AUC score: ", rocScore)
''' for all courses '''
# (accuracies, accuracysPerClass, aucScores) = classifier.predictionTaskForAllCourses(whereToCut=25, ntime=10)
# print("accuracy: ", accuracies)
# print("accuracy per class:\n", accuracysPerClass)
# print("AUC scores: ", aucScores)
''' for all periods '''
classifier.predictionTaskForAllPeriods(ntime=10)
''' NN : all courses with hidden layers'''
# classifier.scriptClassifier.launchTestForAllCoursesHiddenLayers()
'''
Generate the best features for each course independently (useful for LR and SVM)
Warning: SVM is very slow if the AUC criterion is used
'''
# dictBestFeature = {}
# classifier.scriptClassifier.getBackwardBestFeaturesCourse(course, whereToCut=25, dictBestFeature = dictBestFeature)
# classifier.scriptClassifier.getBestFeaturesAllCourses(whereToCut=25, dictBestFeature = dictBestFeature)
# classifier.scriptClassifier.getBestFeaturesAllCourses(whereToCut=50, dictBestFeature = dictBestFeature)
# classifier.scriptClassifier.getBestFeaturesAllCourses(whereToCut=75, dictBestFeature = dictBestFeature)
# classifier.scriptClassifier.getBestFeaturesAllCourses(whereToCut=100, dictBestFeature = dictBestFeature)
#
# print(dictBestFeature)
#
# pathDirectory = os.path.join(ProjectParameters.DIRECTORY_EXPERIMENT, ProjectParameters.DIRECTORY_OCR, "Code")
#
# exportBestFeature = ExportBestFeature(pathDirectory=pathDirectory,
# fileName="bestFeatureLR.txt",
# dictBestFeature=dictBestFeature)
#
# exportBestFeature.export()
stopTime = datetime.now()
print(("end of the process boosting ("+str(stopTime-startTime)+")"))
# -*- coding: UTF-8 -*-
'''
Created on 29-Apr-2014
This file is part of Hubble-UserProfile.
Hubble-UserProfile is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Hubble-UserProfile is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Hubble-UserProfile. If not, see <http://www.gnu.org/licenses/>.
@author: Antoine Pigeau
'''
import os
from datetime import datetime
from exportManager.exportBestFeature import ExportBestFeature
from project.projectParameters import ProjectParameters
from classifierManager.ocr.classifier import Classifier
from classifierManager.constant import Constant as ConstantClassifier
from featureManager.ocr.constant import Constant as ConstantFeature
from model.ocr.constant import Constant as ConstantModel
from model.ocr.course import Course
if __name__ == "__main__":
print("start of the process boosting")
startTime = datetime.now()
classifier = Classifier(idCourses = ConstantModel.ID_COURSES,
nameGroups = [ConstantModel.GROUP_SUCCEED_ALL_USERS, ConstantModel.GROUP_FAILED_ALL_USERS],
features = ConstantFeature.IMPLEMENTED_FEATURES_SESSION,
typeFeatureGroup = ConstantFeature.TYPE_FEATURE_GROUP_SEQUENTIAL_N,
hiddenLayers = None,
featuresByCourse = None, #ConstantFeature.BEST_LR_FEATURE_ALL_COURSES,
featuresByPeriod = None)
# classifier = Classifier(idCourses=ConstantModel.ID_COURSES,
# nameGroups=[ConstantModel.GROUP_SUCCEED_ALL_USERS, ConstantModel.GROUP_FAILED_ALL_USERS],
# features = ConstantFeature.IMPLEMENTED_FEATURES_SESSION_TEST,
# typeFeatureGroup = ConstantFeature.TYPE_FEATURE_GROUP_SEQUENTIAL_N,
# hiddenLayers=[16])
classifier.setScriptClassifier(ConstantClassifier.LstmNumerical)
'''
classification task process
'''
# course = Course(ConstantModel.COURSE_ID_ARDUINO)
# groups = [ConstantModel.GROUP_SUCCEED_ALL_USERS, ConstantModel.GROUP_FAILED_ALL_USERS]
''' classification one time '''
# (accuracy, confusionMatrix, weightOrEpoch, rocScore) = classifier.predictionTask(course, whereToCut=25)
# print("accuracy="+str(accuracy))
# print(confusionMatrix)
# print("epochOrWeight="+str(weightOrEpoch))
# print("auc="+str(rocScore))
''' classification N times '''
# (accuracy, confusionMatrix, weightOrEpoch, rocScore) = classifier.predictionTaskNTimes(course,
# whereToCut=25,
# ntime=1,
# cache = False)
# print("accuracy: ", accuracy)
# print("confusion Matrix:\n", confusionMatrix)
# print("Weight or Epoch: ", weightOrEpoch)
# print("AUC score: ", rocScore)
''' for all courses '''
# (accuracies, accuracysPerClass, aucScores) = classifier.predictionTaskForAllCourses(whereToCut=25, ntime=10)
# print("accuracy: ", accuracies)
# print("accuracy per class:\n", accuracysPerClass)
# print("AUC scores: ", aucScores)
''' for all periods '''
#classifier.predictionTaskForAllPeriods(ntime=10)
''' NN : all courses with hidden layers'''
classifier.scriptClassifier.launchTestForAllCoursesHiddenLayers()
'''
Generate the best features for each course independently (useful for LR and SVM)
Warning: SVM is very slow if the AUC criterion is used
'''
# dictBestFeature = {}
# classifier.scriptClassifier.getBackwardBestFeaturesCourse(course, whereToCut=25, dictBestFeature = dictBestFeature)
# classifier.scriptClassifier.getBestFeaturesAllCourses(whereToCut=25, dictBestFeature = dictBestFeature)
# classifier.scriptClassifier.getBestFeaturesAllCourses(whereToCut=50, dictBestFeature = dictBestFeature)
# classifier.scriptClassifier.getBestFeaturesAllCourses(whereToCut=75, dictBestFeature = dictBestFeature)
# classifier.scriptClassifier.getBestFeaturesAllCourses(whereToCut=100, dictBestFeature = dictBestFeature)
#
# print(dictBestFeature)
#
# pathDirectory = os.path.join(ProjectParameters.DIRECTORY_EXPERIMENT, ProjectParameters.DIRECTORY_OCR, "Code")
#
# exportBestFeature = ExportBestFeature(pathDirectory=pathDirectory,
# fileName="bestFeatureLR.txt",
# dictBestFeature=dictBestFeature)
#
# exportBestFeature.export()
stopTime = datetime.now()
print(("end of the process boosting ("+str(stopTime-startTime)+")"))
# -*- coding: UTF-8 -*-
'''
Created on 29-Apr-2014
This file is part of Hubble-UserProfile.
Hubble-UserProfile is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Hubble-UserProfile is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Hubble-UserProfile. If not, see <http://www.gnu.org/licenses/>.
@author: Antoine Pigeau
'''
from datetime import datetime
from classifierManager.ocr.classifier import Classifier
from classifierManager.constant import Constant as ConstantClassifier
from featureManager.ocr.constant import Constant as ConstantFeature
from model.ocr.constant import Constant as ConstantModel
from model.ocr.course import Course
from model.mergedCourse import MergedCourse
if __name__ == "__main__":
print("start of the process boosting")
startTime = datetime.now()
classifier = Classifier(idCourses = ConstantModel.ID_COURSES,
directory = Classifier.DIRECTORY_EXPERIMENT_MERGED,
nameGroups = [ConstantModel.GROUP_SUCCEED_ALL_USERS, ConstantModel.GROUP_FAILED_ALL_USERS],
features = None,
typeFeatureGroup = ConstantFeature.TYPE_FEATURE_GROUP,
hiddenLayers = ConstantFeature.HIDDEN_LAYERS_BEST_NN_PERCEPTRON_MERGED,
featuresByPeriod = None,
featuresByCourse= None)
classifier.setScriptClassifier(ConstantClassifier.LogisticRegression)
'''
Creation of the merged course with all the courses
'''
courses = []
for idCourse in ConstantModel.ID_COURSES:
courses.append(Course(idCourse, granularity=ConstantModel.CHAPTER))
mergedCourse = MergedCourse(courses)
'''
Prediction task for all courses on each period
'''
''' classification one time '''
#groups = [ConstantModel.GROUP_SUCCEED_ALL_USERS, ConstantModel.GROUP_FAILED_ALL_USERS]
#classifier.testCourseId = ConstantModel.COURSE_ID_GESTION_PROJET
#(accuracy, confusionMatrix, weightOrEpoch, rocScore) = classifier.predictionTaskNTimes(mergedCourse, whereToCut=25, cache = False)
#(accuracy, confusionMatrix, weightOrEpoch, rocScore) = classifier.predictionTask(mergedCourse, whereToCut=25)
#print("accuracy="+str(accuracy))
#print(confusionMatrix)
#print("weightOrEpoch="+str(weightOrEpoch))
#print("auc="+str(rocScore))
''' classification n-times for a specific period '''
#(accuracies, accuracysPerClass, aucScores) = classifier.predictionForMergedCourse(mergedCourse, whereToCut=25, ntime=10)
#print("Accuracies:", accuracies)
#print("accuracysPerClass:,", accuracysPerClass)
#print("auc Scores:", aucScores)
''' classification for all periods '''
#classifier.predictionTaskForMergedForAllPeriods(mergedCourse, ntime=10)
'''
Best features for LR
'''
classifier.scriptClassifier.getMergedForwardBestFeaturesCourse(mergedCourse,
features = ConstantFeature.IMPLEMENTED_FEATURES,
whereToCut=25)
classifier.scriptClassifier.getMergedForwardBestFeaturesCourse(mergedCourse,
features = ConstantFeature.IMPLEMENTED_FEATURES,
whereToCut=100)
classifier.scriptClassifier.getMergedForwardBestFeaturesCourse(mergedCourse,
features = ConstantFeature.IMPLEMENTED_FEATURES,
whereToCut=75)
classifier.scriptClassifier.getMergedForwardBestFeaturesCourse(mergedCourse,
features = ConstantFeature.IMPLEMENTED_FEATURES,
whereToCut=50)
classifier.scriptClassifier.getMergedBackwardBestFeaturesCourse(mergedCourse,
features = ConstantFeature.IMPLEMENTED_FEATURES,
whereToCut=25)
classifier.scriptClassifier.getMergedBackwardBestFeaturesCourse(mergedCourse,
features = ConstantFeature.IMPLEMENTED_FEATURES,
whereToCut=50)
classifier.scriptClassifier.getMergedBackwardBestFeaturesCourse(mergedCourse,
features = ConstantFeature.IMPLEMENTED_FEATURES,
whereToCut=75)
classifier.scriptClassifier.getMergedBackwardBestFeaturesCourse(mergedCourse,
features = ConstantFeature.IMPLEMENTED_FEATURES,
whereToCut=100)
'''
Neural Network
'''
#classifier.scriptClassifier.launchTestForMergedCourseHiddenLayers()
stopTime = datetime.now()
print(("end of the classification task ("+str(stopTime-startTime)+")"))
# -*- coding: UTF-8 -*-
'''
Created on 29-Apr-2014
This file is part of Hubble-UserProfile.
Hubble-UserProfile is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Hubble-UserProfile is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with Hubble-UserProfile. If not, see <http://www.gnu.org/licenses/>.
@author: Antoine Pigeau
'''
from datetime import datetime
from classifierManager.ocr.classifier import Classifier
from classifierManager.constant import Constant as ConstantClassifier
from featureManager.ocr.constant import Constant as ConstantFeature
from model.ocr.constant import Constant as ConstantModel
from model.ocr.course import Course
from model.mergedCourse import MergedCourse
if __name__ == "__main__":
print("start of the process boosting")
startTime = datetime.now()
classifier = Classifier(idCourses = ConstantModel.ID_COURSES,
directory = Classifier.DIRECTORY_EXPERIMENT_MERGED,
nameGroups = [ConstantModel.GROUP_SUCCEED_ALL_USERS, ConstantModel.GROUP_FAILED_ALL_USERS],
features = None,
typeFeatureGroup = ConstantFeature.TYPE_FEATURE_GROUP,
hiddenLayers = None,
featuresByPeriod = ConstantFeature.IMPLEMENTED_FEATURES_FORWARD_BEST_MERGED_LR,
featuresByCourse= None)
classifier.setScriptClassifier(ConstantClassifier.LogisticRegression)
'''
Creation of the merged course with all the courses
'''
courses = []
for idCourse in ConstantModel.ID_COURSES:
courses.append(Course(idCourse, granularity=ConstantModel.CHAPTER))
mergedCourse = MergedCourse(courses)
'''
Prediction task for all courses on each period
'''
''' classification one time '''
#groups = [ConstantModel.GROUP_SUCCEED_ALL_USERS, ConstantModel.GROUP_FAILED_ALL_USERS]
#classifier.testCourseId = ConstantModel.COURSE_ID_GESTION_PROJET
#(accuracy, confusionMatrix, weightOrEpoch, rocScore) = classifier.predictionTaskNTimes(mergedCourse, whereToCut=25, cache = False)
#(accuracy, confusionMatrix, weightOrEpoch, rocScore) = classifier.predictionTask(mergedCourse, whereToCut=25)
#print("accuracy="+str(accuracy))
#print(confusionMatrix)
#print("weightOrEpoch="+str(weightOrEpoch))
#print("auc="+str(rocScore))
''' classification n-times for a specific period '''
#(accuracies, accuracysPerClass, aucScores) = classifier.predictionForMergedCourse(mergedCourse, whereToCut=25, ntime=10)
#print("Accuracies:", accuracies)
#print("accuracysPerClass:,", accuracysPerClass)
#print("auc Scores:", aucScores)
''' classification for all periods '''
classifier.predictionTaskForMergedForAllPeriods(mergedCourse, ntime=10)
'''
Best features for LR
'''
# classifier.scriptClassifier.getMergedForwardBestFeaturesCourse(mergedCourse,
# features = ConstantFeature.IMPLEMENTED_FEATURES,
# whereToCut=25)
#
# classifier.scriptClassifier.getMergedForwardBestFeaturesCourse(mergedCourse,
# features = ConstantFeature.IMPLEMENTED_FEATURES,
# whereToCut=100)
#
# classifier.scriptClassifier.getMergedForwardBestFeaturesCourse(mergedCourse,
# features = ConstantFeature.IMPLEMENTED_FEATURES,
# whereToCut=75)
#
# classifier.scriptClassifier.getMergedForwardBestFeaturesCourse(mergedCourse,
# features = ConstantFeature.IMPLEMENTED_FEATURES,
# whereToCut=50)
# classifier.scriptClassifier.getMergedBackwardBestFeaturesCourse(mergedCourse,
# features = ConstantFeature.IMPLEMENTED_FEATURES,
# whereToCut=25)
#
# classifier.scriptClassifier.getMergedBackwardBestFeaturesCourse(mergedCourse,
# features = ConstantFeature.IMPLEMENTED_FEATURES,
# whereToCut=50)
#
# classifier.scriptClassifier.getMergedBackwardBestFeaturesCourse(mergedCourse,
# features = ConstantFeature.IMPLEMENTED_FEATURES,
# whereToCut=75)
#
# classifier.scriptClassifier.getMergedBackwardBestFeaturesCourse(mergedCourse,
# features = ConstantFeature.IMPLEMENTED_FEATURES,
# whereToCut=100)
'''
Neural Network
'''
#classifier.scriptClassifier.launchTestForMergedCourseHiddenLayers()
stopTime = datetime.now()
print(("end of the classification task ("+str(stopTime-startTime)+")"))
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