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

improve courseName retrieval

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