Commit 026dce3d authored by Antoine PIGEAU's avatar Antoine PIGEAU
Browse files

improve courseName retrieval

parent 25f4eb25
'''
Created on 20 sept. 2017
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: Thomas Depoorter
'''
class ProcessMiningUtility:
#CSV informations
CASE = "UserId"
ACTIVITY = "PartId"
START = "StartTime"
END_TIME = "EndTime"
# Paths
# csv directory
DIR_NAME = "D:/git/2015-Hubble-UserProfiles/2015-Hubble-UserProfile/CSV-Session/ScriptOutput/"
#DIR_NAME = "D:/Programmation/GitLab/2015-Hubble/2015-Hubble-UserProfile/ExperimentProcessMining/"
JAVA_PROJECT = "D:/git/ProcessMiningLibrary/"
#JAVA_PROJECT = "D:/Programmation/GitLab/ProcessMiningLibrary/ProcessMiningLibrary/"
#java lib and bin
JAVA_LIB = JAVA_PROJECT+"lib/*"
JAVA_BIN = JAVA_PROJECT+"bin/"
# CMD
CMD_JAVA = 'java -classpath "' + JAVA_LIB + ';' + JAVA_BIN + '"'
'''
Created on 20 sept. 2017
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: Thomas Depoorter
'''
class ProcessMiningUtility:
#CSV informations
CASE = "UserId"
ACTIVITY = "PartId"
START = "StartTime"
END_TIME = "EndTime"
# Paths
# csv directory
#DIR_NAME = "D:/git/2015-Hubble-UserProfiles/2015-Hubble-UserProfile/CSV-Session/ScriptOutput/"
DIR_NAME = "D:/Programmation/GitLab/2015-Hubble/2015-Hubble-UserProfile/ExperimentProcessMining/"
#JAVA_PROJECT = "D:/git/ProcessMiningLibrary/"
JAVA_PROJECT = "D:/Programmation/GitLab/ProcessMiningLibrary/ProcessMiningLibrary/"
#java lib and bin
JAVA_LIB = JAVA_PROJECT+"lib/*"
JAVA_BIN = JAVA_PROJECT+"bin/"
# CMD
CMD_JAVA = 'java -classpath "' + JAVA_LIB + ';' + JAVA_BIN + '"'
\ No newline at end of file
'''
Created on 13 sept. 2017
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: Thomas Depoorter
'''
import sys
from datetime import datetime
import numpy as np
from sklearn import cross_validation
from sequenceManager.sequenceSession import SequenceSession
from sequenceManager.sequenceInterface import SequenceInterface
from dataManager.course import Course
from heuristicMiner import HeuristicMiner
from conformanceChecking import ConformanceChecking
import operator
sys.setrecursionlimit(10000)
class ScriptConformance:
'''
Calculates the score of the same log with 3 models.
@param modelSucceed : Fitness obtained after a conformance test on the model Success
@param modelFailed : Fitness obtained after a conformance test on the model Failed
@param modelDropout : Fitness obtained after a conformance test on the model Dropout
@return: return a list that contain the score of each model.
'''
def compareScore(self,modelSucceed, modelFailed, modelDropout):
score = [0,0,0];
for i in range(len(modelSucceed)) :
maxInd = np.argmax([modelSucceed[i],modelFailed[i],modelDropout[i]])
score[maxInd]+=1
return score;
'''
@param log: Name of the course which you want to apply the test
@return: The score matrix and text file that contain it
'''
def testLog(self,courseID):
startTime = datetime.now()
#Name correctly the output files
if courseID == Course.COURSE_ID_ARDUINO :
course = "Arduino"
elif courseID == Course.COURSE_ID_JAVA_SCRIPT:
course = "JavaScript"
elif courseID == Course.COURSE_ID_TWITTER:
course ="Twitter"
elif courseID == Course.COURSE_ID_WEB:
course = "Web"
elif courseID == Course.COURSE_ID_RUBY:
course = "Rubys"
elif courseID == Course.COURSE_ID_IONIC:
course = "Inoic"
elif courseID== Course.COURSE_ID_GESTION_PROJET:
course = "Gestion Projet"
elif courseID== Course.COURSE_ID_BOOTSTRAP :
course = "Bootstrap"
else :
return "courseId invalide"
print("script"+course)
sequenceSession = SequenceSession()
#Cross Validation - We charge and split courses for each group
(idCourse,sequencesSuccess) = sequenceSession.getSequences(courseID, SequenceInterface.GROUP_SUCCEED_ALL_USERS)
(idCourse,sequencesFailed) = sequenceSession.getSequences(courseID, SequenceInterface.GROUP_FULL_VIEWER_FAILED)
(idCourse,sequencesDropout) = sequenceSession.getSequences(courseID, SequenceInterface.GROUP_INCOMPLETE_VIEWER_DROPOUT)
sequencesSucceedTrain, sequencesSucceedTest = cross_validation.train_test_split(sequencesSuccess, test_size=0.2)
sequencesFailedTrain, sequencesFailedTest = cross_validation.train_test_split(sequencesFailed, test_size=0.2)
sequencesDropoutTrain, sequencesDropoutTest = cross_validation.train_test_split(sequencesDropout, test_size=0.2)
#sequencesSucceedTest = sequencesSucceedTest[0:2]
#sequencesSucceedTrain = sequencesSucceedTrain[0:2]
#sequencesFailedTest = sequencesFailedTest[0:2]
#sequencesFailedTrain = sequencesFailedTrain[0:2]
#sequencesDropoutTest = sequencesDropoutTest[0:2]
#sequencesDropoutTrain = sequencesDropoutTrain[0:2]
#it adds the idCourse droped by crossvalidation
sequencesSucceedTrain = (idCourse,sequencesSucceedTrain)
sequencesFailedTrain = (idCourse,sequencesFailedTrain)
sequencesDropoutTrain = (idCourse,sequencesDropoutTrain)
sequencesSucceedTest = (idCourse,sequencesSucceedTest)
sequencesFailedTest = (idCourse,sequencesFailedTest)
sequencesDropoutTest = (idCourse,sequencesDropoutTest)
relativeToBest = 0
dependancy = 1.0
heuristicMiner = HeuristicMiner(relativeToBest, dependancy)
conformanceChecking = ConformanceChecking()
print("Succeed")
#Creation of the model
heuristicMiner.applyProcessModel(sequencesSucceedTrain)
#Tests of conformance of each groups on a model
succeedSucceed = conformanceChecking.applyConformanceChecking(heuristicMiner, sequencesSucceedTest)
succeedFailed = conformanceChecking.applyConformanceChecking(heuristicMiner, sequencesFailedTest)
succeedDropout = conformanceChecking.applyConformanceChecking(heuristicMiner, sequencesDropoutTest)
print("Failed")
#Creation of the model
heuristicMiner.applyProcessModel(sequencesFailedTrain)
#Tests of conformance of each groups on a model
failedSucceed = conformanceChecking.applyConformanceChecking(heuristicMiner, sequencesSucceedTest)
failedFailed = conformanceChecking.applyConformanceChecking(heuristicMiner, sequencesFailedTest)
failedDropout = conformanceChecking.applyConformanceChecking(heuristicMiner, sequencesDropoutTest)
print("Dropout")
#Creation of the model
heuristicMiner.applyProcessModel(sequencesDropoutTrain)
#Tests of conformance of each groups on a model
dropoutSucceed = conformanceChecking.applyConformanceChecking(heuristicMiner, sequencesSucceedTest)
dropoutFailed = conformanceChecking.applyConformanceChecking(heuristicMiner, sequencesFailedTest)
dropoutDropout = conformanceChecking.applyConformanceChecking(heuristicMiner, sequencesDropoutTest)
#Compare the fitness of each group on each model in order to identify which log match whith which model
finalScore = np.array([self.compareScore(succeedSucceed[0], failedSucceed[0], dropoutSucceed[0]),
self.compareScore(succeedFailed[0], failedFailed[0], dropoutFailed[0]),
self.compareScore(succeedDropout[0], failedDropout[0], dropoutDropout[0])])
finalScore = finalScore.transpose()
print(finalScore)
#Test Export
#Write all datas in a text file
dest = open(course+"result.txt", "w")
stopTime = datetime.now()
dest.write(str(succeedSucceed))
dest.write("\n")
dest.write(str(failedSucceed))
dest.write("\n")
dest.write(str(dropoutSucceed))
dest.write("\n")
dest.write(str(succeedFailed))
dest.write("\n")
dest.write(str(failedFailed))
dest.write("\n")
dest.write(str(dropoutFailed))
dest.write("\n")
dest.write(str(succeedDropout))
dest.write("\n")
dest.write(str(failedDropout))
dest.write("\n")
dest.write(str(dropoutDropout))
dest.write("\n")
dest.write(str(finalScore))
dest.write("\n")
dest.write(str(stopTime-startTime))
dest.write("\n")
dest.close()
stopTime = datetime.now()
print("end of the process scriptConformance ("+str(stopTime-startTime)+")")
return finalScore
'''
Export the score matrix in a text file
@param score: score matrix
@param pathExport: path where the text file will be save
@return: A text file that contain the score matrix
'''
#Export the score matrix in a text file
def export (self, score, pathExport):
dest = open(pathExport, "w")
dest.write(str(score))
dest.close()
'''
Launch the script for each courses.
@return: Retrun a text file for each course, that contains the score matrix
'''
def testAllLog(self):
startTime = datetime.now()
"""
Export while test export is disabled
self.export(self.testLog("Arduino"),'ArduinoResult.txt')
self.export(self.testLog("JavaScript"),'JavaScriptResult.txt')
self.export(self.testLog("Twitter"),'TwitterResult.txt')
self.export(self.testLog("Web"),'WebResult.txt')
self.export(self.testLog("Rubys"),'RubysResult.txt')
self.export(self.testLog("Inoic"),'InoicResult.txt')
self.export(self.testLog("Gestion Projet"),'GestionProjetResult.txt')
self.export(self.testLog("Bootstrap"),'BootStrapResult.txt')
"""
self.testLog(Course.COURSE_ID_ARDUINO)
self.testLog(Course.COURSE_ID_JAVA_SCRIPT)
self.testLog(Course.COURSE_ID_TWITTER)
self.testLog(Course.COURSE_ID_WEB)
self.testLog(Course.COURSE_ID_RUBY)
self.testLog(Course.COURSE_ID_IONIC)
self.testLog(Course.COURSE_ID_GESTION_PROJET)
self.testLog(Course.COURSE_ID_BOOTSTRAP)
stopTime = datetime.now()
print("end of the process scriptAllLog ("+str(stopTime-startTime)+")")
'''
Created on 13 sept. 2017
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: Thomas Depoorter
'''
import sys
from datetime import datetime
import numpy as np
from sklearn import cross_validation
from sequenceManager.sequenceSession import SequenceSession
from sequenceManager.sequenceInterface import SequenceInterface
from dataManager.course import Course
from heuristicMiner import HeuristicMiner
from conformanceChecking import ConformanceChecking
sys.setrecursionlimit(10000)
class ScriptConformance:
'''
Calculates the score of the same log with 3 models.
@param modelSucceed : Fitness obtained after a conformance test on the model Success
@param modelFailed : Fitness obtained after a conformance test on the model Failed
@param modelDropout : Fitness obtained after a conformance test on the model Dropout
@return: return a list that contain the score of each model.
'''
def compareScore(self,modelSucceed, modelFailed, modelDropout):
score = [0,0,0];
for i in range(len(modelSucceed)) :
maxInd = np.argmax([modelSucceed[i],modelFailed[i],modelDropout[i]])
score[maxInd]+=1
return score;
'''
@param log: Name of the course which you want to apply the test
@return: The score matrix and text file that contain it
'''
def testLog(self,idCourse):
startTime = datetime.now()
courseName = Course.getCourseName(idCourse, summary=True)
print("script"+courseName)
sequenceSession = SequenceSession()
#Cross Validation - We charge and split courses for each group
(_,sequencesSuccess) = sequenceSession.getSequences(idCourse, SequenceInterface.GROUP_SUCCEED_ALL_USERS)
(_,sequencesFailed) = sequenceSession.getSequences(idCourse, SequenceInterface.GROUP_FULL_VIEWER_FAILED)
(_,sequencesDropout) = sequenceSession.getSequences(idCourse, SequenceInterface.GROUP_INCOMPLETE_VIEWER_DROPOUT)
sequencesSucceedTrain, sequencesSucceedTest = cross_validation.train_test_split(sequencesSuccess, test_size=0.2)
sequencesFailedTrain, sequencesFailedTest = cross_validation.train_test_split(sequencesFailed, test_size=0.2)
sequencesDropoutTrain, sequencesDropoutTest = cross_validation.train_test_split(sequencesDropout, test_size=0.2)
#sequencesSucceedTest = sequencesSucceedTest[0:2]
#sequencesSucceedTrain = sequencesSucceedTrain[0:2]
#sequencesFailedTest = sequencesFailedTest[0:2]
#sequencesFailedTrain = sequencesFailedTrain[0:2]
#sequencesDropoutTest = sequencesDropoutTest[0:2]
#sequencesDropoutTrain = sequencesDropoutTrain[0:2]
#it adds the idCourse droped by crossvalidation
sequencesSucceedTrain = (idCourse,sequencesSucceedTrain)
sequencesFailedTrain = (idCourse,sequencesFailedTrain)
sequencesDropoutTrain = (idCourse,sequencesDropoutTrain)
sequencesSucceedTest = (idCourse,sequencesSucceedTest)
sequencesFailedTest = (idCourse,sequencesFailedTest)
sequencesDropoutTest = (idCourse,sequencesDropoutTest)
relativeToBest = 0
dependancy = 1.0
heuristicMiner = HeuristicMiner(relativeToBest, dependancy)
conformanceChecking = ConformanceChecking()
print("Succeed")
#Creation of the model
heuristicMiner.applyProcessModel(sequencesSucceedTrain)
#Tests of conformance of each groups on a model
succeedSucceed = conformanceChecking.applyConformanceChecking(heuristicMiner, sequencesSucceedTest)
succeedFailed = conformanceChecking.applyConformanceChecking(heuristicMiner, sequencesFailedTest)
succeedDropout = conformanceChecking.applyConformanceChecking(heuristicMiner, sequencesDropoutTest)
print("Failed")
#Creation of the model
heuristicMiner.applyProcessModel(sequencesFailedTrain)
#Tests of conformance of each groups on a model
failedSucceed = conformanceChecking.applyConformanceChecking(heuristicMiner, sequencesSucceedTest)
failedFailed = conformanceChecking.applyConformanceChecking(heuristicMiner, sequencesFailedTest)
failedDropout = conformanceChecking.applyConformanceChecking(heuristicMiner, sequencesDropoutTest)
print("Dropout")
#Creation of the model
heuristicMiner.applyProcessModel(sequencesDropoutTrain)
#Tests of conformance of each groups on a model
dropoutSucceed = conformanceChecking.applyConformanceChecking(heuristicMiner, sequencesSucceedTest)
dropoutFailed = conformanceChecking.applyConformanceChecking(heuristicMiner, sequencesFailedTest)
dropoutDropout = conformanceChecking.applyConformanceChecking(heuristicMiner, sequencesDropoutTest)
#Compare the fitness of each group on each model in order to identify which log match whith which model
finalScore = np.array([self.compareScore(succeedSucceed[0], failedSucceed[0], dropoutSucceed[0]),
self.compareScore(succeedFailed[0], failedFailed[0], dropoutFailed[0]),
self.compareScore(succeedDropout[0], failedDropout[0], dropoutDropout[0])])
finalScore = finalScore.transpose()
print(finalScore)
#Test Export
#Write all datas in a text file
dest = open(courseName+"result.txt", "w")
stopTime = datetime.now()
dest.write(str(succeedSucceed))
dest.write("\n")
dest.write(str(failedSucceed))
dest.write("\n")
dest.write(str(dropoutSucceed))
dest.write("\n")
dest.write(str(succeedFailed))
dest.write("\n")
dest.write(str(failedFailed))
dest.write("\n")
dest.write(str(dropoutFailed))
dest.write("\n")
dest.write(str(succeedDropout))
dest.write("\n")
dest.write(str(failedDropout))
dest.write("\n")
dest.write(str(dropoutDropout))
dest.write("\n")
dest.write(str(finalScore))
dest.write("\n")
dest.write(str(stopTime-startTime))
dest.write("\n")
dest.close()
stopTime = datetime.now()
print("end of the process scriptConformance ("+str(stopTime-startTime)+")")
return finalScore
'''
Export the score matrix in a text file
@param score: score matrix
@param pathExport: path where the text file will be save
@return: A text file that contain the score matrix
'''
#Export the score matrix in a text file
def export (self, score, pathExport):
dest = open(pathExport, "w")
dest.write(str(score))
dest.close()
'''
Launch the script for each courses.
@return: Retrun a text file for each course, that contains the score matrix
'''
def testAllLog(self):
startTime = datetime.now()
"""
Export while test export is disabled
self.export(self.testLog("Arduino"),'ArduinoResult.txt')
self.export(self.testLog("JavaScript"),'JavaScriptResult.txt')
self.export(self.testLog("Twitter"),'TwitterResult.txt')
self.export(self.testLog("Web"),'WebResult.txt')
self.export(self.testLog("Rubys"),'RubysResult.txt')
self.export(self.testLog("Inoic"),'InoicResult.txt')
self.export(self.testLog("Gestion Projet"),'GestionProjetResult.txt')
self.export(self.testLog("Bootstrap"),'BootStrapResult.txt')
"""
self.testLog(Course.COURSE_ID_ARDUINO)
self.testLog(Course.COURSE_ID_JAVA_SCRIPT)
self.testLog(Course.COURSE_ID_TWITTER)
self.testLog(Course.COURSE_ID_WEB)
self.testLog(Course.COURSE_ID_RUBY)
self.testLog(Course.COURSE_ID_IONIC)
self.testLog(Course.COURSE_ID_GESTION_PROJET)
self.testLog(Course.COURSE_ID_BOOTSTRAP)
stopTime = datetime.now()
print("end of the process scriptAllLog ("+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