-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproject_algorthims.py
More file actions
83 lines (69 loc) · 3.82 KB
/
project_algorthims.py
File metadata and controls
83 lines (69 loc) · 3.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
from project_functions import zscore
#stepwise frequency gating
def StepWise(user_past_score, current_batch_score, average_time_score, current_threshold, past_time_centroids, deltas, base):
past_threshold = past_time_centroids[1,0]
time_threshold = past_time_centroids[1,1]
num_bf_gold = base
if user_past_score > past_threshold:
num_bf_gold += base*deltas["Past"]
if current_batch_score > current_threshold:
num_bf_gold += base*deltas["Current"]
if average_time_score < time_threshold:
num_bf_gold += base*deltas["Time"]
return int(num_bf_gold)
#stepwise frequency gating with Penalty (in terms of z)
def StepWisePenalty(user_past_score, current_batch_score, average_time_score, current_threshold, past_time_centroids, deltas, base, penalty):
past_threshold = past_time_centroids[1,0]
time_threshold = past_time_centroids[1,1]
num_bf_gold = base
if user_past_score > past_threshold:
num_bf_gold += base*deltas["Past"]
if user_past_score < (past_threshold - penalty):
num_bf_gold -= base*deltas["Past"]
if current_batch_score > current_threshold:
num_bf_gold += base*deltas["Current"]
if current_batch_score < (current_threshold - penalty):
num_bf_gold -= base*deltas["Current"]
if average_time_score < time_threshold:
num_bf_gold += base*deltas["Time"]
if average_time_score > (time_threshold + penalty):
num_bf_gold -= base*deltas["Time"]
return int(num_bf_gold)
#attenuated frequency algorthim
def Attenuated(user_past_score, current_batch_score, average_time_score, current_threshold, past_time_centroids, deltas, base):
past_threshold = past_time_centroids[1,0]
time_threshold = past_time_centroids[1,1]
num_bf_gold = base
if user_past_score > past_threshold:
num_bf_gold += base*deltas["Past"]*(user_past_score-past_threshold)
if current_batch_score > current_threshold:
num_bf_gold += base*deltas["Current"]*(current_batch_score - current_threshold)
#time would need a weighting constant
if average_time_score < time_threshold:
num_bf_gold += -1*base*deltas["Time"]*(average_time_score - time_threshold)
return int(num_bf_gold)
def AttenuatedContinous(user_past_score, current_batch_score, average_time_score, current_threshold, past_time_centroids, deltas, base):
past_threshold = past_time_centroids[1,0]
time_threshold = past_time_centroids[1,1]
num_bf_gold = base
num_bf_gold += num_bf_gold*deltas["Past"]*(user_past_score-past_threshold) + num_bf_gold*deltas["Current"]*(current_batch_score - current_threshold) + (-1*num_bf_gold*deltas["Time"]*(average_time_score - time_threshold))
return int(num_bf_gold)
def centroidThreshold(user_past_score, current_batch_score, average_time_score, current_threshold, past_time_centroids, deltas, base):
num_bf_gold = base
# See if current batch is above accuracy threshold
num_bf_gold += base*deltas["Current"]*(current_batch_score - current_threshold)
# Set Good, Bad, Average user performance for time and past performance based on number of centroids used
last_centroid = 2
if len(past_time_centroids) == 2:
last_centroid = 1
#adjust number of gold questions if they are above of below the first or third centroid respectively for past performance
if user_past_score < past_time_centroids[0,0]:
num_bf_gold += base*deltas["Past"]*(user_past_score-past_time_centroids[0,0])
if user_past_score > past_time_centroids[last_centroid,0]:
num_bf_gold += base*deltas["Past"]*(user_past_score-past_time_centroids[last_centroid,0])
#adjust number of gold questions if they are faster than the first or third centroid respectively for time
if average_time_score < past_time_centroids[0,1]:
num_bf_gold += -1*base*deltas["Current"]*(average_time_score - past_time_centroids[0,1])
if average_time_score > past_time_centroids[last_centroid,1]:
num_bf_gold += -1*base*deltas["Current"]*(average_time_score - past_time_centroids[last_centroid,1])
return int(num_bf_gold)