Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Antoine PIGEAU
2015-Hubble-UserProfiles
Commits
0125b1e3
Commit
0125b1e3
authored
Feb 05, 2019
by
ZHOU yao
Browse files
merge
parents
2a985491
61b826e0
Changes
7
Hide whitespace changes
Inline
Side-by-side
source/classifierManager/oulad/main.py
View file @
0125b1e3
...
...
@@ -46,11 +46,12 @@ if __name__ == "__main__":
#features = [5, 6, 7, 8, 9, 10, 15]
features
=
ConstantFeature
.
FEATURES_ALL
#(accuracy, confusionMatrix, resultWeight) = scriptAB.predictionTask(idCourse, groupNames, whereToCut=None)
#(accuracy, confusionMatrix, resultWeight) = scriptAB.predictionTask(idCourse, groupNames, whereToCut=25)
#print("Accuracy:"+str(accuracy))
#print("Confusion Matrix:"+str(confusionMatrix))
#scriptAB.predictionTaskNTimes(idCourse, groupNames, whereToCut=None, ntime=2, cache=True)
#scriptAB.predictionTaskForAllCourses(groupNames, ConstantModel.ID_COURSES, whereToCut=25)
scriptAB
.
predictionTaskForAllCoursesPeriod
(
groupNames
,
ConstantModel
.
ID_COURSES
)
#scriptABTemporal.predictionTaskForAllCoursesPeriod(groups)
...
...
source/classifierManager/oulad/scriptAdaBoost.py
View file @
0125b1e3
...
...
@@ -28,7 +28,6 @@ from featureManager.oulad.constant import Constant as ConstantFeature
from
featureManager.ocr.featureGroupProxyTemporal
import
FeatureGroupProxyTemporal
from
classifierManager.boosting
import
Boosting
from
classifierManager.oulad.scriptClassifier
import
ScriptClassifier
class
ScriptAdaBoost
(
ScriptClassifier
):
...
...
source/classifierManager/oulad/scriptClassifier.py
View file @
0125b1e3
...
...
@@ -91,9 +91,8 @@ class ScriptClassifier:
''' load feature '''
self
.
featureMultiGroup
.
featureGroups
=
[]
self
.
featureMultiGroup
.
data
=
pd
.
DataFrame
()
self
.
featureMultiGroup
.
addGroup
(
course
,
groupNames
,
self
.
features
,
whereToCut
,
whereToCutUnity
)
self
.
featureMultiGroup
.
clear
()
self
.
featureMultiGroup
.
addGroup
(
course
,
groupNames
,
self
.
features
,
whereToCut
=
whereToCut
,
whereToCutUnity
=
whereToCutUnity
)
train_x
,
train_y
,
test_x
,
test_y
=
self
.
featureMultiGroup
.
getTrainTestNumpyFeatures
()
test_y
=
np
.
ravel
(
test_y
)
...
...
@@ -145,6 +144,7 @@ class ScriptClassifier:
model
=
self
.
loadModel
()
print
(
"Model loaded:"
+
str
(
type
(
model
)))
print
(
"groups:"
+
str
(
groups
))
model
.
fit
(
train_x
,
train_y
)
...
...
@@ -157,7 +157,8 @@ class ScriptClassifier:
print
(
"--------------------------------------------------"
)
print
(
"input dimension:"
+
str
(
train_x
.
shape
))
print
(
"train[0, 500:600]="
+
str
(
train_x
[
0
,
10
:
60
]))
print
(
"input dimension:"
+
str
(
train_y
.
shape
))
print
(
"train[0, 10:60]="
+
str
(
train_x
[
0
,
10
:
60
]))
courseName
=
course
.
getName
()
print
((
"Course "
+
courseName
+
": "
+
str
(
accuracy
)))
print
(
"Confusion Matrix:"
)
...
...
@@ -179,12 +180,13 @@ class ScriptClassifier:
'''
accuracys
=
[]
course
=
Course
(
idCourse
)
size
=
len
(
groupNames
)
confusionMatrice
=
np
.
zeros
((
size
,
size
))
dictResultWeight
=
{}
nameCourse
=
C
ourse
.
get
CourseName
(
idCourse
,
summary
=
True
)
nameCourse
=
c
ourse
.
get
Name
(
)
fileNameSavedResult
=
os
.
path
.
join
(
ScriptClassifier
.
DIRECTORY_EXPERIMENT
,
self
.
fileName
+
str
(
nameCourse
)
+
'Session'
+
str
(
whereToCut
)
+
'.p'
)
...
...
@@ -244,17 +246,25 @@ class ScriptClassifier:
with
open
(
fileNameResult
,
'w'
)
as
fileResult
:
for
idCourse
in
idCourses
:
#[Course.COURSE_ID_ARDUINO, Course.COURSE_ID_AUDACE]
print
(
"idCourse: "
+
str
(
idCourse
))
course
=
Course
(
idCourse
)
(
accuracy
,
confusionMatrix
,
dictWeight
)
=
self
.
predictionTaskNTimes
(
idCourse
,
groupNames
,
whereToCut
=
whereToCut
,
ntime
=
10
)
ntime
=
2
)
scores
.
append
(
accuracy
)
if
dictWeight
:
dictWeightAllCourses
[
idCourse
]
=
dictWeight
courseName
=
Course
.
getCourseName
(
idCourse
,
summary
=
True
)
dictWeightAllCourses
[
idCourse
]
=
dictWeight
courseName
=
course
.
getName
()
fileResult
.
write
(
"--------------------------
\n
"
)
fileResult
.
write
(
"Course "
+
courseName
+
": accuracy("
+
str
(
accuracy
)
+
")
\n
"
)
...
...
source/featureManager/oulad/featureMultiGroup.py
View file @
0125b1e3
...
...
@@ -60,7 +60,7 @@ class FeatureMultiGroup:
if
self
.
course
is
None
:
self
.
course
=
featureGroup
.
getCourse
()
elif
self
.
course
!=
featureGroup
.
getCourse
():
elif
self
.
course
.
getIdCourse
()
!=
featureGroup
.
getCourse
()
.
getIdCourse
()
:
warnings
.
warn
(
'featureManager.features - FeatureMultiGroup - FeatureMultiGroup are merged from different courses'
,
Warning
)
label
=
len
(
self
.
featureGroups
)
self
.
featureGroups
.
append
(
featureGroup
)
...
...
@@ -154,6 +154,8 @@ class FeatureMultiGroup:
trainX
,
trainY
,
testX
,
testY
=
self
.
getTrainTestPandasFeatures
(
train
,
test
)
return
trainX
.
values
,
trainY
.
values
,
testX
.
values
,
testY
.
values
return
trainX
.
values
.
astype
(
float
)
,
trainY
.
values
.
astype
(
int
)
,
testX
.
values
.
astype
(
float
)
,
testY
.
values
.
astype
(
int
)
def
clear
(
self
):
self
.
__init__
()
\ No newline at end of file
source/featureManager/oulad/featureSequence.py
View file @
0125b1e3
...
...
@@ -257,7 +257,7 @@ class FeatureSequence:
@return: a dataframe with resources as column and one row per user with the averages
'''
return
FeatureSequence
.
__getNumberAccessPerResource
(
idUser
,
events
,
course
,
np
.
mean
,
filterType
)
return
FeatureSequence
.
__getNumberAccessPerResource
(
idUser
,
events
,
course
,
lambda
l
:
np
.
sum
(
l
)
/
len
(
l
)
if
len
(
l
)
else
0
,
filterType
)
@
staticmethod
def
getAllMarks
(
idUser
,
events
,
course
):
...
...
source/featureManager/oulad/testUnitFeatureSequence.py
View file @
0125b1e3
...
...
@@ -43,7 +43,7 @@ class Test(unittest.TestCase):
print
(
nameFeature
+
": "
+
str
(
featureWindowDuration
[
nameFeature
].
values
[
0
]))
self
.
assertTrue
(
featureWindowDuration
[
nameFeature
].
values
[
0
]
==
-
25
9
)
self
.
assertTrue
(
featureWindowDuration
[
nameFeature
].
values
[
0
]
==
25
8
)
dataEmpty
=
FeatureSequence
.
getWindowDuration
(
idUser
,
pd
.
DataFrame
())
...
...
source/model/oulad/constant.py
View file @
0125b1e3
...
...
@@ -78,6 +78,8 @@ class Constant:
ID_COURSES
=
[
AAA_2013_J
]
#DDD_2013_B,DDD_2013_J,DDD_2014_B,DDD_2014_J,FFF_2014_J,FFF_2013_B,FFF_2013_J,FFF_2014_B]
REGISTRATION
=
'registration'
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment