Skip to content

Commit 994816d

Browse files
authored
coachiness added to the esteemer (#379)
1 parent 40e4a99 commit 994816d

File tree

2 files changed

+27
-7
lines changed

2 files changed

+27
-7
lines changed

esteemer/esteemer.py

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,37 @@
1111
from utils.settings import settings
1212

1313
MPM = {
14-
"social worse": {Comparison.signal_type: 0.5, History.signal_type: -0.5},
15-
"social better": {Comparison.signal_type: 0.5, History.signal_type: -0.1},
16-
"improving": {Trend.signal_type: 0.8, History.signal_type: -0.1},
17-
"worsening": {Trend.signal_type: 0.8, History.signal_type: -0.5},
14+
"social worse": {Comparison.signal_type: 0.5, History.signal_type: -0.5, "coachiness": 1.0},
15+
"social better": {Comparison.signal_type: 0.5, History.signal_type: -0.1, "coachiness":0.0},
16+
"improving": {Trend.signal_type: 0.8, History.signal_type: -0.1, "coachiness": 0.5},
17+
"worsening": {Trend.signal_type: 0.8, History.signal_type: -0.5, "coachiness": 1.0},
1818
"goal gain": {
1919
Comparison.signal_type: 0.5,
2020
Trend.signal_type: 0.8,
2121
"achievement_recency": 0.5,
2222
History.signal_type: -0.1,
23+
"coachiness": 0.5
2324
},
2425
"goal loss": {
2526
Comparison.signal_type: 0.5,
2627
Trend.signal_type: 0.8,
2728
"loss_recency": 0.5,
2829
History.signal_type: -0.5,
30+
"coachiness": 1.0
2931
},
3032
"social gain": {
3133
Comparison.signal_type: 0.5,
3234
Trend.signal_type: 0.8,
3335
"achievement_recency": 0.5,
3436
History.signal_type: -0.1,
37+
"coachiness": 0.5
3538
},
3639
"social loss": {
3740
Comparison.signal_type: 0.5,
3841
Trend.signal_type: 0.8,
3942
"loss_recency": 0.5,
4043
History.signal_type: -0.5,
44+
"coachiness": 1.0
4145
},
4246
}
4347

@@ -89,18 +93,26 @@ def score(candidate: Resource, history: dict, preferences: dict) -> Resource:
8993
candidate[URIRef("preference_score")] = Literal(
9094
preference_score, datatype=XSD.double
9195
)
96+
97+
# coachiness
98+
coachiness_score = MPM[causal_pathway.value]["coachiness"] / 10
99+
candidate[URIRef("coachiness_score")] = Literal(
100+
coachiness_score, datatype=XSD.double
101+
)
92102

93-
final_calculated_score = final_score((mi_score + history_score), preference_score)
103+
final_calculated_score = final_score(mi_score, history_score, preference_score, coachiness_score)
94104

95105
candidate[SLOWMO.Score] = Literal(final_calculated_score, datatype=XSD.double)
96106

97107
return candidate
98108

99109

100-
def final_score(s, p):
110+
def final_score(m, h, p, c):
101111
"""
102112
the function, final_score, takes two inputs, s and p. the range for s is 0 to 1. the range for p is -2 to +2. The function f(s,p) increases with either s or p increasing. The function should have the following constraints: f(1,-2) == f(.5, 0) == f(0,2) and f(0.5, -2) == f(0.25, -1) == f(0, 0).
103113
"""
114+
115+
s = m + h
104116
# Define the scaling factors for s and p
105117
scale_s = 4 # default to stated range of p
106118
scale_p = 1 # default to stated range of 2
@@ -110,7 +122,12 @@ def final_score(s, p):
110122
base_value = scale_s * 0.5 + scale_p * 0 # default to mid-points of stated ranges
111123

112124
# Adjust the function to increase with either s or p increasing
113-
return (scale_s * s + scale_p * p + base_value) / (scale_s + scale_p + base_value)
125+
score = (scale_s * s + scale_p * p + base_value) / (scale_s + scale_p + base_value)
126+
127+
#apply coachiness factor
128+
score = score + c
129+
130+
return score
114131

115132

116133
def score_social_better(

esteemer/utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ def candidates_records(performer_graph: Graph) -> List[List]:
122122
"motivating_score",
123123
"history_score",
124124
"preference_score",
125+
"coachiness_score",
125126
"name",
126127
"acceptable_by",
127128
"selected",
@@ -151,6 +152,8 @@ def candidate_as_record(a_candidate: Resource) -> List:
151152
representation.append(a_candidate.value(URIRef("history_score")))
152153

153154
representation.append(a_candidate.value(URIRef("preference_score")))
155+
representation.append(a_candidate.value(URIRef("coachiness_score")))
156+
154157

155158
representation.append(a_candidate.value(SLOWMO.name))
156159
representation.append(a_candidate.value(SLOWMO.AcceptableBy))

0 commit comments

Comments
 (0)