Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
BN_GenerativeModel
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Antonio Andriella
BN_GenerativeModel
Commits
f0838c5b
Commit
f0838c5b
authored
4 years ago
by
Antonio Andriella
Browse files
Options
Downloads
Patches
Plain Diff
clean folder
parent
cab83093
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
bn_persona/persona_model.bif
+0
-103
0 additions, 103 deletions
bn_persona/persona_model.bif
bn_persona/utilities.py
+0
-70
0 additions, 70 deletions
bn_persona/utilities.py
user_model.bif
+0
-103
0 additions, 103 deletions
user_model.bif
with
0 additions
and
276 deletions
bn_persona/persona_model.bif
deleted
100644 → 0
+
0
−
103
View file @
cab83093
network persona_model {
}
%VARIABLES DEFINITION
variable reactivity {
type discrete [3] {slow, medium, fast};
}
variable memory {
type discrete[3] {low, medium, high};
}
variable attention {
type discrete[3] {low, medium, high};
}
variable robot_assistance {
type discrete [ 5 ] { lev_0, lev_1, lev_2, lev_3, lev_4 };
}
variable attempt {
type discrete [ 4 ] { att_1, att_2, att_3, att_4 };
}
variable game_state {
type discrete [ 3 ] { beg, mid, end };
}
variable robot_feedback {
type discrete [ 2 ] { yes, no };
}
variable user_action {
type discrete [ 3 ] { correct, wrong, timeout };
}
%INDIVIDUAL PROBABILITIES DEFINITION
probability ( robot_assistance ) {
table 0.2, 0.2, 0.2, 0.2, 0.2;
}
probability ( game_state ) {
table 0.34, 0.33, 0.33;
}
probability ( attempt ) {
table 0.25, 0.25, 0.25, 0.25;
}
probability ( user_action ) {
table 0.33, 0.33, 0.34;
}
#CPDS 4 #SPECIFICALLY FOR THE GIVEN PATIENT
probability ( reactivity ) {
table 0.34, 0.33, 0.33;
}
#CPDS 3 #SPECIFICALLY FOR THE GIVEN PATIENT
probability ( memory ) {
table 0.33, 0.33, 0.34;
}
#CPDS 1 #SPECIFICALLY FOR THE GIVEN PATIENT
probability ( attention ) {
table 0.33, 0.33, 0.34;
}
probability ( robot_feedback ) {
table 0.5, 0.5;
}
probability ( reactivity | attention ) {
(low) 0.7, 0.2, 0.1;
(medium) 0.2, 0.5, 0.3;
(high) 0.1, 0.2, 0.7;
}
#CPDS 7
probability (user_action | memory, reactivity) {
(low, slow) 0.2, 0.5, 0.3;
(low, medium) 0.3, 0.5, 0.2;
(low, fast) 0.4, 0.5, 0.1;
(medium, slow) 0.5, 0.3, 0.2;
(medium, medium) 0.55, 0.35, 0.1;
(medium, fast) 0.6, 0.4, 0.0;
(high, slow) 0.5, 0.4, 0.1;
(high, medium) 0.6, 0.3, 0.1;
(high, fast) 0.8, 0.2, 0.0;
}
#CPDS 5
probability (robot_feedback | user_action) {
(correct) 0.8, 0.2;
(wrong) 0.5, 0.5;
(timeout) 0.2, 0.8;
}
#CPDS 6
probability (robot_assistance | user_action) {
(correct) 0.05 0.1 0.15 0.3 0.4;
(wrong) 0.4 0.3 0.2 0.05 0.05;
(timeout) 0.4 0.4 0.1 0.05 0.05;
}
#CPDS 2
probability (game_state | user_action) {
(correct) 0.2, 0.4, 0.4;
(wrong) 0.4, 0.4, 0.2;
(timeout) 0.6, 0.3, 0.1;
}
#CPDS 0
probability (attempt | user_action) {
(correct) 0.1, 0.2, 0.3, 0.4;
(wrong) 0.5, 0.3, 0.15, 0.05;
(timeout) 0.4, 0.3, 0.2, 0.1;
}
#CPDS 5
probability (robot_assistance | robot_feedback) {
(yes) 0.5 0.3 0.1 0.1 0.0;
(no) 0.0 0.1 0.1 0.3 0.5;
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
bn_persona/utilities.py
deleted
100644 → 0
+
0
−
70
View file @
cab83093
import
random
import
bn_functions
def
compute_next_state
(
user_action
,
task_evolution
,
attempt_counter
,
correct_move_counter
,
wrong_move_counter
,
timeout_counter
):
'''
The function computes given the current state and action of the user, the next state
Args:
user_action: 0,1,2
task_evolution: beg, mid, end
correct_move_counter:
attempt_counter:
wrong_move_counter:
timeout_counter:
Return:
the counters updated according to the user_action
'''
if
user_action
==
0
:
attempt_counter
=
0
task_evolution
+=
1
correct_move_counter
+=
1
# if the user made a wrong move and still did not reach the maximum number of attempts
elif
user_action
==
1
and
attempt_counter
<
3
:
attempt_counter
+=
1
wrong_move_counter
+=
1
# if the user did not move any token and still did not reach the maximum number of attempts
elif
user_action
==
2
and
attempt_counter
<
3
:
attempt_counter
+=
1
timeout_counter
+=
1
# the robot or therapist makes the correct move on the patient's behalf
else
:
attempt_counter
=
0
task_evolution
+=
1
correct_move_counter
+=
1
return
task_evolution
,
attempt_counter
,
correct_move_counter
,
wrong_move_counter
,
timeout_counter
def
get_user_action_prob
():
def
get_stochatic_action
(
actions_prob
):
'''
Select one of the actions according to the actions_prob
Args:
actions_prob: the probability of the Persona based on the BN to make a correct move, wrong move, timeout
Return:
the id of the selected action
N.B:
'''
action_id
=
None
correct_action_from_BN
=
actions_prob
[
0
]
wrong_action_from_BN
=
actions_prob
[
1
]
timeout_action_from_BN
=
actions_prob
[
2
]
rnd_val
=
random
.
uniform
(
0
,
1
)
#if user_prob is lower than the correct action prob then is the correct one
if
rnd_val
<=
correct_action_from_BN
:
action_id
=
0
#if rnd is larger than the correct action prob and lower than wrong
# action prob then is the wrong one
elif
rnd_val
>
correct_action_from_BN
\
and
rnd_val
<
(
correct_action_from_BN
+
wrong_action_from_BN
):
action_id
=
1
#timeout
else
:
action_id
=
2
return
action_id
This diff is collapsed.
Click to expand it.
user_model.bif
deleted
100644 → 0
+
0
−
103
View file @
cab83093
network persona_model_4 {
}
%VARIABLES DEFINITION
variable reactivity {
type discrete [3] {slow, medium, fast};
}
variable memory {
type discrete[3] {low, medium, high};
}
variable attention {
type discrete[3] {low, medium, high};
}
variable robot_assistance {
type discrete [ 5 ] { lev_0, lev_1, lev_2, lev_3, lev_4 };
}
variable attempt {
type discrete [ 4 ] { att_1, att_2, att_3, att_4 };
}
variable game_state {
type discrete [ 3 ] { beg, mid, end };
}
variable robot_feedback {
type discrete [ 2 ] { yes, no };
}
variable user_action {
type discrete [ 3 ] { correct, wrong, timeout };
}
%INDIVIDUAL PROBABILITIES DEFINITION
probability ( robot_assistance ) {
table 0.2, 0.2, 0.2, 0.2, 0.2;
}
probability ( game_state ) {
table 0.34, 0.33, 0.33;
}
probability ( attempt ) {
table 0.25, 0.25, 0.25, 0.25;
}
probability ( user_action ) {
table 0.33, 0.33, 0.34;
}
#CPDS 4 #SPECIFICALLY FOR THE GIVEN PATIENT
probability ( reactivity ) {
table 0.34, 0.33, 0.33;
}
#CPDS 3 #SPECIFICALLY FOR THE GIVEN PATIENT
probability ( memory ) {
table 0.33, 0.33, 0.34;
}
#CPDS 1 #SPECIFICALLY FOR THE GIVEN PATIENT
probability ( attention ) {
table 0.33, 0.33, 0.34;
}
probability ( robot_feedback ) {
table 0.5, 0.5;
}
probability ( reactivity | attention ) {
(low) 0.5, 0.4, 0.1;
(medium) 0.3, 0.5, 0.2;
(high) 0.1, 0.2, 0.7;
}
#CPDS 7
probability (user_action | memory, reactivity) {
(low, slow) 0.2, 0.5, 0.3;
(low, medium) 0.3, 0.5, 0.2;
(low, fast) 0.4, 0.5, 0.1;
(medium, slow) 0.5, 0.3, 0.2;
(medium, medium) 0.55, 0.35, 0.1;
(medium, fast) 0.6, 0.4, 0.0;
(high, slow) 0.5, 0.4, 0.1;
(high, medium) 0.6, 0.3, 0.1;
(high, fast) 0.8, 0.2, 0.0;
}
#CPDS 5
probability (robot_feedback | user_action) {
(correct) 0.5, 0.5;
(wrong) 0.5, 0.5;
(timeout) 0.5, 0.5;
}
#CPDS 6
probability (robot_assistance | user_action) {
(correct) 0.05 0.1 0.15 0.3 0.4;
(wrong) 0.4 0.2 0.2 0.1 0.1;
(timeout) 0.4 0.2 0.2 0.1 0.1;
}
#CPDS 2
probability (game_state | user_action) {
(correct) 0.2, 0.4, 0.4;
(wrong) 0.4, 0.4, 0.2;
(timeout) 0.6, 0.3, 0.1;
}
#CPDS 0
probability (attempt | user_action) {
(correct) 0.1, 0.2, 0.3, 0.4;
(wrong) 0.7, 0.2, 0.1, 0.0;
(timeout) 0.6, 0.3, 0.1, 0.0;
}
#CPDS 5
probability (robot_assistance | robot_feedback) {
(yes) 0.5 0.3 0.1 0.1 0.0;
(no) 0.0 0.1 0.1 0.3 0.5;
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment