Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
2
2020-101
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Sachith Fernando
2020-101
Commits
d28b5572
Commit
d28b5572
authored
Dec 26, 2020
by
I.K Seneviratne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Committing the modifications of finding correlations between student behavior components.
.
parent
723f804a
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
310 additions
and
131 deletions
+310
-131
FirstApp/api.py
FirstApp/api.py
+1
-0
FirstApp/logic/student_behavior_process.py
FirstApp/logic/student_behavior_process.py
+200
-47
FirstApp/templates/FirstApp/Home.html
FirstApp/templates/FirstApp/Home.html
+109
-84
No files found.
FirstApp/api.py
View file @
d28b5572
...
...
@@ -1167,6 +1167,7 @@ class GetLectureActivityCorrelations(APIView):
activity_correlations
=
ar
.
get_activity_correlations
(
individual_lec_activities
,
lec_recorded_activity_data
)
return
Response
({
"correlations"
:
activity_correlations
})
...
...
FirstApp/logic/student_behavior_process.py
View file @
d28b5572
...
...
@@ -5,10 +5,14 @@ def calculate_student_activity_emotion_correlations(lec_activities, lec_emotions
# this variable will be used to store the correlations
correlations
=
[]
limit
=
10
# limit = 10
limit
=
len
(
lec_activities
)
data_index
=
[
'lecture-{}'
.
format
(
i
+
1
)
for
i
in
range
(
len
(
lec_activities
))]
# define the correlation data dictionary
corr_data
=
{}
# student gaze labels
student_activity_labels
=
[
'phone checking'
,
'listening'
,
'note taking'
]
student_emotion_labels
=
[
'Happy'
,
'Sad'
,
'Angry'
,
'Surprise'
,
'Neutral'
]
...
...
@@ -28,29 +32,74 @@ def calculate_student_activity_emotion_correlations(lec_activities, lec_emotions
# loop through the lecture activity data
for
data
in
lec_activities
:
value
=
int
(
data
[
'phone_perct'
])
value1
=
int
(
data
[
'listening_perct'
])
value2
=
int
(
data
[
'writing_perct'
])
if
value
!=
0
:
phone_perct_list
.
append
(
int
(
data
[
'phone_perct'
]))
if
value1
!=
0
:
listen_perct_list
.
append
(
int
(
data
[
'listening_perct'
]))
if
value2
!=
0
:
note_perct_list
.
append
(
int
(
data
[
'writing_perct'
]))
# loop through the lecture emotion data
for
data
in
lec_emotions
:
value
=
int
(
data
[
'happy_perct'
])
value1
=
int
(
data
[
'sad_perct'
])
value2
=
int
(
data
[
'angry_perct'
])
value3
=
int
(
data
[
'surprise_perct'
])
value4
=
int
(
data
[
'neutral_perct'
])
if
value
!=
0
:
happy_perct_list
.
append
(
int
(
data
[
'happy_perct'
]))
if
value1
!=
0
:
sad_perct_list
.
append
(
int
(
data
[
'sad_perct'
]))
if
value2
!=
0
:
angry_perct_list
.
append
(
int
(
data
[
'angry_perct'
]))
if
value3
!=
0
:
surprise_perct_list
.
append
(
int
(
data
[
'surprise_perct'
]))
if
value4
!=
0
:
neutral_perct_list
.
append
(
int
(
data
[
'neutral_perct'
]))
corr_data
=
{
'phone checking'
:
phone_perct_list
,
'listening'
:
listen_perct_list
,
'note taking'
:
note_perct_list
,
'Happy'
:
happy_perct_list
,
'Sad'
:
sad_perct_list
,
'Angry'
:
angry_perct_list
,
'Surprise'
:
surprise_perct_list
,
'Neutral'
:
neutral_perct_list
,
}
if
len
(
phone_perct_list
)
==
len
(
lec_activities
):
corr_data
[
student_activity_labels
[
0
]]
=
phone_perct_list
if
len
(
listen_perct_list
)
==
len
(
lec_activities
):
corr_data
[
student_activity_labels
[
1
]]
=
listen_perct_list
if
len
(
note_perct_list
)
==
len
(
lec_activities
):
corr_data
[
student_activity_labels
[
2
]]
=
note_perct_list
if
len
(
happy_perct_list
)
==
len
(
lec_activities
):
corr_data
[
student_emotion_labels
[
0
]]
=
happy_perct_list
if
len
(
sad_perct_list
)
==
len
(
lec_activities
):
corr_data
[
student_emotion_labels
[
1
]]
=
sad_perct_list
if
len
(
angry_perct_list
)
==
len
(
lec_activities
):
corr_data
[
student_emotion_labels
[
2
]]
=
angry_perct_list
if
len
(
surprise_perct_list
)
==
len
(
lec_activities
):
corr_data
[
student_emotion_labels
[
3
]]
=
surprise_perct_list
if
len
(
neutral_perct_list
)
==
len
(
lec_activities
):
corr_data
[
student_emotion_labels
[
4
]]
=
neutral_perct_list
# corr_data = {'phone checking': phone_perct_list, 'listening': listen_perct_list, 'note taking': note_perct_list,
# 'Happy': happy_perct_list, 'Sad': sad_perct_list, 'Angry': angry_perct_list, 'Surprise': surprise_perct_list, 'Neutral': neutral_perct_list,
# }
print
(
'data: '
,
corr_data
)
# create the dataframe
df
=
pd
.
DataFrame
(
corr_data
,
index
=
data_index
)
df
=
df
[(
df
.
T
!=
0
)
.
any
()]
print
(
df
)
# calculate the correlation
pd_series
=
ut
.
get_top_abs_correlations
(
df
,
limit
)
print
(
pd_series
)
# assign a new value to the 'limit' variable
limit
=
len
(
pd_series
)
if
len
(
pd_series
)
<
limit
else
limit
for
i
in
range
(
limit
):
# this dictionary will get the pandas.Series object's indices and values separately
corr_dict
=
{}
...
...
@@ -70,6 +119,7 @@ def calculate_student_activity_emotion_correlations(lec_activities, lec_emotions
# append the dictionary to the 'correlations' list
correlations
.
append
(
corr_dict
)
# return the list
return
correlations
...
...
@@ -79,13 +129,16 @@ def calculate_student_activity_gaze_correlations(lec_activities, lec_gaze):
# this variable will be used to store the correlations
correlations
=
[]
limit
=
10
limit
=
len
(
lec_activities
)
data_index
=
[
'lecture-{}'
.
format
(
i
+
1
)
for
i
in
range
(
len
(
lec_activities
))]
# this dictionary contains the correlation data
corr_data
=
{}
# student gaze labels
student_activity_labels
=
[
'phone checking'
,
'listening'
,
'note taking'
]
student_emotion_labels
=
[
'Happy'
,
'Sad'
,
'Angry'
,
'Surprise'
,
'Neutral'
]
#
student_emotion_labels = ['Happy', 'Sad', 'Angry', 'Surprise', 'Neutral']
student_gaze_labels
=
[
'Up and Right'
,
'Up and Left'
,
'Down and Right'
,
'Down and Left'
,
'Front'
]
# lecture activity data list (student)
...
...
@@ -103,30 +156,73 @@ def calculate_student_activity_gaze_correlations(lec_activities, lec_gaze):
# loop through the lecture activity data
for
data
in
lec_activities
:
value
=
int
(
data
[
'phone_perct'
])
value1
=
int
(
data
[
'listening_perct'
])
value2
=
int
(
data
[
'writing_perct'
])
if
value
!=
0
:
phone_perct_list
.
append
(
int
(
data
[
'phone_perct'
]))
if
value1
!=
0
:
listen_perct_list
.
append
(
int
(
data
[
'listening_perct'
]))
if
value2
!=
0
:
note_perct_list
.
append
(
int
(
data
[
'writing_perct'
]))
# loop through the lecture activity data
for
data
in
lec_gaze
:
value
=
int
(
data
[
'looking_up_and_right_perct'
])
value1
=
int
(
data
[
'looking_up_and_left_perct'
])
value2
=
int
(
data
[
'looking_down_and_right_perct'
])
value3
=
int
(
data
[
'looking_down_and_left_perct'
])
value4
=
int
(
data
[
'looking_front_perct'
])
if
value
!=
0
:
upright_perct_list
.
append
(
int
(
data
[
'looking_up_and_right_perct'
]))
if
value1
!=
0
:
upleft_perct_list
.
append
(
int
(
data
[
'looking_up_and_left_perct'
]))
if
value2
!=
0
:
downright_perct_list
.
append
(
int
(
data
[
'looking_down_and_right_perct'
]))
if
value3
!=
0
:
downleft_perct_list
.
append
(
int
(
data
[
'looking_down_and_left_perct'
]))
if
value4
!=
0
:
front_perct_list
.
append
(
int
(
data
[
'looking_front_perct'
]))
corr_data
=
{
'phone checking'
:
phone_perct_list
,
'listening'
:
listen_perct_list
,
'note taking'
:
note_perct_list
,
'Up and Right'
:
upright_perct_list
,
'Up and Left'
:
upleft_perct_list
,
'Down and Right'
:
downright_perct_list
,
'Down and Left'
:
downleft_perct_list
,
'Front'
:
front_perct_list
}
if
(
len
(
phone_perct_list
))
==
len
(
lec_activities
):
corr_data
[
student_activity_labels
[
0
]]
=
phone_perct_list
if
(
len
(
listen_perct_list
))
==
len
(
lec_activities
):
corr_data
[
student_activity_labels
[
1
]]
=
listen_perct_list
if
(
len
(
note_perct_list
))
==
len
(
lec_activities
):
corr_data
[
student_activity_labels
[
2
]]
=
note_perct_list
if
(
len
(
upright_perct_list
))
==
len
(
lec_activities
):
corr_data
[
student_gaze_labels
[
0
]]
=
upright_perct_list
if
(
len
(
upleft_perct_list
))
==
len
(
lec_activities
):
corr_data
[
student_gaze_labels
[
1
]]
=
upleft_perct_list
if
(
len
(
downright_perct_list
))
==
len
(
lec_activities
):
corr_data
[
student_gaze_labels
[
2
]]
=
downright_perct_list
if
(
len
(
downleft_perct_list
))
==
len
(
lec_activities
):
corr_data
[
student_gaze_labels
[
3
]]
=
downleft_perct_list
if
(
len
(
front_perct_list
))
==
len
(
lec_activities
):
corr_data
[
student_gaze_labels
[
4
]]
=
front_perct_list
# corr_data = {'phone checking': phone_perct_list, 'listening': listen_perct_list, 'note taking': note_perct_list,
# 'Up and Right': upright_perct_list, 'Up and Left': upleft_perct_list, 'Down and Right': downright_perct_list,
# 'Down and Left': downleft_perct_list, 'Front': front_perct_list
# }
# create the dataframe
df
=
pd
.
DataFrame
(
corr_data
,
index
=
data_index
)
print
(
df
)
# calculate the correlation
pd_series
=
ut
.
get_top_abs_correlations
(
df
,
limit
)
print
(
pd_series
)
print
(
'length of pd_series: '
,
len
(
pd_series
))
# assign a new value to the 'limit' variable
limit
=
len
(
pd_series
)
if
len
(
pd_series
)
<
limit
else
limit
for
i
in
range
(
limit
):
# this dictionary will get the pandas.Series object's indices and values separately
corr_dict
=
{}
...
...
@@ -146,6 +242,8 @@ def calculate_student_activity_gaze_correlations(lec_activities, lec_gaze):
# append the dictionary to the 'correlations' list
correlations
.
append
(
corr_dict
)
print
(
'correlations: '
,
correlations
)
# return the list
return
correlations
...
...
@@ -155,10 +253,13 @@ def calculate_student_emotion_gaze_correlations(lec_emotions, lec_gaze):
# this variable will be used to store the correlations
correlations
=
[]
limit
=
10
limit
=
len
(
lec_emotions
)
data_index
=
[
'lecture-{}'
.
format
(
i
+
1
)
for
i
in
range
(
len
(
lec_emotions
))]
# this dictionary will contain the correlation data
corr_data
=
{}
student_emotion_labels
=
[
'Happy'
,
'Sad'
,
'Angry'
,
'Surprise'
,
'Neutral'
]
student_gaze_labels
=
[
'Up and Right'
,
'Up and Left'
,
'Down and Right'
,
'Down and Left'
,
'Front'
]
...
...
@@ -180,32 +281,84 @@ def calculate_student_emotion_gaze_correlations(lec_emotions, lec_gaze):
# loop through the lecture emotion data
for
data
in
lec_emotions
:
value
=
int
(
data
[
'happy_perct'
])
value1
=
int
(
data
[
'sad_perct'
])
value2
=
int
(
data
[
'angry_perct'
])
value3
=
int
(
data
[
'surprise_perct'
])
value4
=
int
(
data
[
'neutral_perct'
])
if
value
!=
0
:
happy_perct_list
.
append
(
int
(
data
[
'happy_perct'
]))
if
value1
!=
0
:
sad_perct_list
.
append
(
int
(
data
[
'sad_perct'
]))
if
value2
!=
0
:
angry_perct_list
.
append
(
int
(
data
[
'angry_perct'
]))
if
value3
!=
0
:
surprise_perct_list
.
append
(
int
(
data
[
'surprise_perct'
]))
if
value4
!=
0
:
neutral_perct_list
.
append
(
int
(
data
[
'neutral_perct'
]))
# loop through the lecture gaze data
for
data
in
lec_gaze
:
value
=
int
(
data
[
'looking_up_and_right_perct'
])
value1
=
int
(
data
[
'looking_up_and_left_perct'
])
value2
=
int
(
data
[
'looking_down_and_right_perct'
])
value3
=
int
(
data
[
'looking_down_and_left_perct'
])
value4
=
int
(
data
[
'looking_front_perct'
])
if
value
!=
0
:
upright_perct_list
.
append
(
int
(
data
[
'looking_up_and_right_perct'
]))
if
value1
!=
0
:
upleft_perct_list
.
append
(
int
(
data
[
'looking_up_and_left_perct'
]))
if
value2
!=
0
:
downright_perct_list
.
append
(
int
(
data
[
'looking_down_and_right_perct'
]))
if
value3
!=
0
:
downleft_perct_list
.
append
(
int
(
data
[
'looking_down_and_left_perct'
]))
if
value4
!=
0
:
front_perct_list
.
append
(
int
(
data
[
'looking_front_perct'
]))
corr_data
=
{
'Happy'
:
happy_perct_list
,
'Sad'
:
sad_perct_list
,
'Angry'
:
angry_perct_list
,
'Surprise'
:
surprise_perct_list
,
'Neutral'
:
neutral_perct_list
,
'Up and Right'
:
upright_perct_list
,
'Up and Left'
:
upleft_perct_list
,
'Down and Right'
:
downright_perct_list
,
'Down and Left'
:
downleft_perct_list
,
'Front'
:
front_perct_list
}
if
len
(
happy_perct_list
)
==
len
(
lec_emotions
):
corr_data
[
student_emotion_labels
[
0
]]
=
happy_perct_list
if
len
(
sad_perct_list
)
==
len
(
lec_emotions
):
corr_data
[
student_emotion_labels
[
1
]]
=
sad_perct_list
if
len
(
angry_perct_list
)
==
len
(
lec_emotions
):
corr_data
[
student_emotion_labels
[
2
]]
=
angry_perct_list
if
len
(
surprise_perct_list
)
==
len
(
lec_emotions
):
corr_data
[
student_emotion_labels
[
3
]]
=
surprise_perct_list
if
len
(
neutral_perct_list
)
==
len
(
lec_emotions
):
corr_data
[
student_emotion_labels
[
4
]]
=
neutral_perct_list
if
(
len
(
upright_perct_list
))
==
len
(
lec_emotions
):
corr_data
[
student_gaze_labels
[
0
]]
=
upright_perct_list
if
(
len
(
upleft_perct_list
))
==
len
(
lec_emotions
):
corr_data
[
student_gaze_labels
[
1
]]
=
upleft_perct_list
if
(
len
(
downright_perct_list
))
==
len
(
lec_emotions
):
corr_data
[
student_gaze_labels
[
2
]]
=
downright_perct_list
if
(
len
(
downleft_perct_list
))
==
len
(
lec_emotions
):
corr_data
[
student_gaze_labels
[
3
]]
=
downleft_perct_list
if
(
len
(
front_perct_list
))
==
len
(
lec_emotions
):
corr_data
[
student_gaze_labels
[
4
]]
=
front_perct_list
# corr_data = {'Happy': happy_perct_list, 'Sad': sad_perct_list, 'Angry': angry_perct_list, 'Surprise': surprise_perct_list, 'Neutral': neutral_perct_list,
# 'Up and Right': upright_perct_list, 'Up and Left': upleft_perct_list, 'Down and Right': downright_perct_list,
# 'Down and Left': downleft_perct_list, 'Front': front_perct_list
# }
# create the dataframe
df
=
pd
.
DataFrame
(
corr_data
,
index
=
data_index
)
print
(
df
)
# calculate the correlation
pd_series
=
ut
.
get_top_abs_correlations
(
df
,
limit
)
print
(
pd_series
)
# assign a new value to the 'limit' variable
limit
=
len
(
pd_series
)
if
len
(
pd_series
)
<
limit
else
limit
for
i
in
range
(
limit
):
# this dictionary will get the pandas.Series object's indices and values separately
corr_dict
=
{}
...
...
FirstApp/templates/FirstApp/Home.html
View file @
d28b5572
...
...
@@ -1240,7 +1240,7 @@
function
displayActivityEmotionCorrelations
(
correlations
)
{
let
htmlString
=
""
;
if
(
correlations
.
length
!==
0
)
{
//create the html content for the activity correlation table
for
(
let
i
=
0
;
i
<
correlations
.
length
;
i
++
)
{
let
corr
=
correlations
[
i
];
...
...
@@ -1275,6 +1275,14 @@
htmlString
+=
"
</tr>
"
;
}
}
else
{
htmlString
+=
"
<tr>
"
;
htmlString
+=
"
<td colspan='3'>
"
;
htmlString
+=
"
<span class='font-italic'>No correlations were found</span>
"
;
htmlString
+=
"
</td>
"
;
htmlString
+=
"
</tr>
"
;
}
//append to the
<
tbody
>
$
(
'
#student_activity_emotion_corr_tbody
'
).
append
(
htmlString
);
...
...
@@ -1293,6 +1301,7 @@
let
htmlString
=
""
;
if
(
correlations
.
length
!==
0
)
{
//create the html content for the activity correlation table
for
(
let
i
=
0
;
i
<
correlations
.
length
;
i
++
)
{
let
corr
=
correlations
[
i
];
...
...
@@ -1327,6 +1336,13 @@
htmlString
+=
"
</tr>
"
;
}
}
else
{
htmlString
+=
"
<tr>
"
;
htmlString
+=
"
<td colspan='3'>
"
;
htmlString
+=
"
<span class='font-italic'>No correlations were found</span>
"
;
htmlString
+=
"
</td>
"
;
htmlString
+=
"
</tr>
"
;
}
//append to the
<
tbody
>
$
(
'
#student_activity_gaze_corr_tbody
'
).
append
(
htmlString
);
...
...
@@ -1346,6 +1362,7 @@
let
htmlString
=
""
;
if
(
correlations
.
length
!==
0
)
{
//create the html content for the activity correlation table
for
(
let
i
=
0
;
i
<
correlations
.
length
;
i
++
)
{
let
corr
=
correlations
[
i
];
...
...
@@ -1380,6 +1397,14 @@
htmlString
+=
"
</tr>
"
;
}
}
else
{
htmlString
+=
"
<tr>
"
;
htmlString
+=
"
<td colspan='3'>
"
;
htmlString
+=
"
<span class='font-italic'>No correlations were found</span>
"
;
htmlString
+=
"
</td>
"
;
htmlString
+=
"
</tr>
"
;
}
//append to the
<
tbody
>
$
(
'
#student_emotion_gaze_corr_tbody
'
).
append
(
htmlString
);
...
...
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