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
4aaa0934
Commit
4aaa0934
authored
4 years ago
by
Antonio Andriella
Browse files
Options
Downloads
Patches
Plain Diff
New persona model and test class
parent
f9c97845
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bn_persona_model/persona_model_test.bif
+162
-0
162 additions, 0 deletions
bn_persona_model/persona_model_test.bif
test.py
+21
-0
21 additions, 0 deletions
test.py
with
183 additions
and
0 deletions
bn_persona_model/persona_model_test.bif
0 → 100644
+
162
−
0
View file @
4aaa0934
network persona_model {
}
%VARIABLES DEFINITION
variable robot_assistance {
type discrete [ 6 ] { lev_0, lev_1, lev_2, lev_3, lev_4, lev_5 };
}
variable attempt_t0 {
type discrete [ 4 ] { att_1, att_2, att_3, att_4 };
}
variable game_state_t0 {
type discrete [ 3 ] { beg, mid, end };
}
variable attempt_t1 {
type discrete [ 4 ] { att_1, att_2, att_3, att_4 };
}
variable game_state_t1 {
type discrete [ 3 ] { beg, mid, end };
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
variable user_action {
type discrete [ 3 ] { correct, wrong, timeout };
}
%INDIVIDUAL PROBABILITIES DEFINITION
probability ( robot_assistance ) {
table 0.17, 0.16, 0.16, 0.17, 0.17, 0.17;
}
probability ( game_state_t0 ) {
table 0.34, 0.33, 0.33;
}
probability ( attempt_t0 ) {
table 0.25, 0.25, 0.25, 0.25;
}
probability ( game_state_t1 ) {
table 0.34, 0.33, 0.33;
}
probability ( attempt_t1 ) {
table 0.25, 0.25, 0.25, 0.25;
}
probability ( user_action ) {
table 0.33, 0.33, 0.34;
}
probability (robot_assistance | game_state_t0, attempt_t0){
(beg, att_1) 0.0, 0.2, 0.2, 0.2, 0.2, 0.2;
(beg, att_2) 0.05, 0.15, 0.2, 0.2, 0.2, 0.2;
(beg, att_3) 0.1, 0.2, 0.2, 0.2, 0.2, 0.1;
(beg, att_4) 0.15, 0.05, 0.2, 0.2, 0.2, 0.2;
(mid, att_1) 0.0, 0.2, 0.2, 0.2, 0.2, 0.2;
(mid, att_2) 0.05, 0.15, 0.2, 0.2, 0.2, 0.2;
(mid, att_3) 0.1, 0.2, 0.2, 0.2, 0.2, 0.1;
(mid, att_4) 0.15, 0.05, 0.2, 0.2, 0.2, 0.2;
(end, att_1) 0.0, 0.2, 0.2, 0.2, 0.2, 0.2;
(end, att_2) 0.05, 0.15, 0.2, 0.2, 0.2, 0.2;
(end, att_3) 0.1, 0.2, 0.2, 0.2, 0.2, 0.1;
(end, att_4) 0.15, 0.05, 0.2, 0.2, 0.2, 0.2;
}
probability (user_action | game_state_t0, attempt_t0, robot_assistance){
(beg, att_1, lev_0) 0.1, 0.9, 0.0;
(beg, att_2, lev_0) 0.2, 0.8, 0.0;
(beg, att_3, lev_0) 0.3, 0.7, 0.0;
(beg, att_4, lev_0) 0.4, 0.6, 0.0;
(beg, att_1, lev_1) 0.1, 0.9, 0.0;
(beg, att_2, lev_1) 0.2, 0.8, 0.0;
(beg, att_3, lev_1) 0.3, 0.7, 0.0;
(beg, att_4, lev_1) 0.4, 0.6, 0.0;
(beg, att_1, lev_2) 0.1, 0.9, 0.0;
(beg, att_2, lev_2) 0.2, 0.8, 0.0;
(beg, att_3, lev_2) 0.3, 0.7, 0.0;
(beg, att_4, lev_2) 0.4, 0.6, 0.0;
(beg, att_1, lev_3) 0.1, 0.9, 0.0;
(beg, att_2, lev_3) 0.2, 0.8, 0.0;
(beg, att_3, lev_3) 0.3, 0.7, 0.0;
(beg, att_4, lev_3) 0.4, 0.6, 0.0;
(beg, att_1, lev_4) 0.1, 0.9, 0.0;
(beg, att_2, lev_4) 0.2, 0.8, 0.0;
(beg, att_3, lev_4) 0.3, 0.7, 0.0;
(beg, att_4, lev_4) 0.4, 0.6, 0.0;
(beg, att_1, lev_5) 0.1, 0.9, 0.0;
(beg, att_2, lev_5) 0.2, 0.8, 0.0;
(beg, att_3, lev_5) 0.3, 0.7, 0.0;
(beg, att_4, lev_5) 0.4, 0.6, 0.0;
(mid, att_1, lev_0) 0.1, 0.9, 0.0;
(mid, att_2, lev_0) 0.2, 0.8, 0.0;
(mid, att_3, lev_0) 0.3, 0.7, 0.0;
(mid, att_4, lev_0) 0.4, 0.6, 0.0;
(mid, att_1, lev_1) 0.1, 0.9, 0.0;
(mid, att_2, lev_1) 0.2, 0.8, 0.0;
(mid, att_3, lev_1) 0.3, 0.7, 0.0;
(mid, att_4, lev_1) 0.4, 0.6, 0.0;
(mid, att_1, lev_2) 0.1, 0.9, 0.0;
(mid, att_2, lev_2) 0.2, 0.8, 0.0;
(mid, att_3, lev_2) 0.3, 0.7, 0.0;
(mid, att_4, lev_2) 0.4, 0.6, 0.0;
(mid, att_1, lev_3) 0.1, 0.9, 0.0;
(mid, att_2, lev_3) 0.2, 0.8, 0.0;
(mid, att_3, lev_3) 0.3, 0.7, 0.0;
(mid, att_4, lev_3) 0.4, 0.6, 0.0;
(mid, att_1, lev_4) 0.1, 0.9, 0.0;
(mid, att_2, lev_4) 0.2, 0.8, 0.0;
(mid, att_3, lev_4) 0.3, 0.7, 0.0;
(mid, att_4, lev_4) 0.4, 0.6, 0.0;
(mid, att_1, lev_5) 0.1, 0.9, 0.0;
(mid, att_2, lev_5) 0.2, 0.8, 0.0;
(mid, att_3, lev_5) 0.3, 0.7, 0.0;
(mid, att_4, lev_5) 0.4, 0.6, 0.0;
(end, att_1, lev_0) 0.1, 0.9, 0.0;
(end, att_2, lev_0) 0.2, 0.8, 0.0;
(end, att_3, lev_0) 0.2, 0.8, 0.0;
(end, att_4, lev_0) 0.4, 0.6, 0.0;
(end, att_1, lev_1) 0.1, 0.9, 0.0;
(end, att_2, lev_1) 0.2, 0.8, 0.0;
(end, att_3, lev_1) 0.4, 0.6, 0.0;
(end, att_4, lev_1) 0.4, 0.6, 0.0;
(end, att_1, lev_2) 0.1, 0.9, 0.0;
(end, att_2, lev_2) 0.2, 0.8, 0.0;
(end, att_3, lev_2) 0.4, 0.6, 0.0;
(end, att_4, lev_2) 0.4, 0.6, 0.0;
(end, att_1, lev_3) 0.1, 0.9, 0.0;
(end, att_2, lev_3) 0.2, 0.8, 0.0;
(end, att_3, lev_3) 0.5, 0.5, 0.0;
(end, att_4, lev_3) 0.4, 0.6, 0.0;
(end, att_1, lev_4) 0.1, 0.9, 0.0;
(end, att_2, lev_4) 0.2, 0.8, 0.0;
(end, att_3, lev_4) 0.7, 0.3, 0.0;
(end, att_4, lev_4) 0.4, 0.6, 0.0;
(end, att_1, lev_5) 0.1, 0.9, 0.0;
(end, att_2, lev_5) 0.2, 0.8, 0.0;
(end, att_3, lev_5) 0.3, 0.7, 0.0;
(end, att_4, lev_5) 0.4, 0.6, 0.0;
}
probability (game_state_t1 | user_action) {
(correct) 0.2, 0.3, 0.5;
(wrong) 0.5, 0.3, 0.2;
(timeout) 0.33, 0.34, 0.33;
}
probability (attempt_t1 | user_action) {
(correct) 0.1, 0.2, 0.3, 0.4;
(wrong) 0.4, 0.3, 0.2, 0.1;
(timeout) 0.25, 0.25, 0.25, 0.25;
}
probability (user_action | robot_assistance){
(lev_0) 0.1, 0.6, 0.3;
(lev_1) 0.2, 0.5, 0.3;
(lev_2) 0.3, 0.5, 0.2;
(lev_3) 0.5, 0.3, 0.2;
(lev_4) 0.9, 0.1, 0.0;
(lev_5) 0.9, 0.1, 0.0;
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
test.py
0 → 100644
+
21
−
0
View file @
4aaa0934
import
bnlearn
as
bn
DAG
=
bn
.
import_DAG
(
'
bn_persona_model/persona_model_test.bif
'
)
#df = bn.sampling(DAG, n=1000, verbose=2)
#model = bn.structure_learning.fit(df)
#G = bn.plot(model)
#DAGnew = bn.parameter_learning.fit(model, df, methodtype="bayes")
#bn.print_CPD(DAGnew)
q1
=
bn
.
inference
.
fit
(
DAG
,
variables
=
[
'
user_action
'
],
evidence
=
{
'
game_state_t0
'
:
1
,
'
attempt_t0
'
:
0
,
'
robot_assistance
'
:
5
,
'
game_state_t1
'
:
1
,
'
attempt_t0
'
:
1
,
})
print
(
q1
.
variables
)
print
(
q1
.
values
)
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