Spaces:
Runtime error
Runtime error
corrects cr calc
Browse files- src/read_logs.py +13 -10
src/read_logs.py
CHANGED
@@ -74,7 +74,7 @@ class LogAnalyser:
|
|
74 |
def get_c1_plot(self):
|
75 |
# c2_threshold=0
|
76 |
c1_threshold_list = np.arange(0, 1, 0.01)
|
77 |
-
c1_reaction_weight_list = np.arange(0, 1, 0.1)
|
78 |
|
79 |
# reaction_weight=0.5
|
80 |
list_stories = self.df.Story.unique()
|
@@ -118,7 +118,7 @@ class LogAnalyser:
|
|
118 |
df_c1.at[index, 'c1'] = reaction_show
|
119 |
review = df_c1.e_review[index]
|
120 |
df_c1.at[index, 'c1r'] = self.get_criteria_review(
|
121 |
-
reaction_show, review=review)
|
122 |
c1r_sum = df_c1['c1r'].sum()
|
123 |
c1r_sum_list.append(c1r_sum)
|
124 |
c1_analysis_dict['c1_threshold']=c1_threshold
|
@@ -162,11 +162,11 @@ class LogAnalyser:
|
|
162 |
subset_condition = self.get_subset_condition(df_c2, story_id)
|
163 |
dfs = df_c2[subset_condition]
|
164 |
for i, (index, row) in enumerate(dfs.iterrows()):
|
165 |
-
c2 = row.
|
166 |
df_c2.at[index, 'c2'] = c2
|
167 |
review = df_c2.e_review[index]
|
168 |
df_c2.at[index, 'c2r'] = self.get_criteria_review(
|
169 |
-
c2, review=review)
|
170 |
c2r_sum_list.append(df_c2['c2r'].sum())
|
171 |
fig = px.line(x=c2_threshold_list, y=c2r_sum_list)
|
172 |
fig.update_layout(
|
@@ -188,12 +188,15 @@ class LogAnalyser:
|
|
188 |
return (data.Story == story_id) & (data.Turn == 'user')
|
189 |
|
190 |
@staticmethod
|
191 |
-
def get_criteria_review(c, review):
|
192 |
# printj.green(f'{c} {type(c)}')
|
193 |
# printj.green(f'{review} {type(review)}')
|
194 |
-
|
195 |
-
|
196 |
-
|
|
|
|
|
|
|
197 |
# return str(np.round(result, 0))
|
198 |
|
199 |
def get_ngram_pattern(self, s, n=2):
|
@@ -269,9 +272,9 @@ class LogAnalyser:
|
|
269 |
self.df.at[index, 'c2'] = c2
|
270 |
review = self.df.e_review[index]
|
271 |
self.df.at[index, 'c1r'] = self.get_criteria_review(
|
272 |
-
reaction_show, review=review)
|
273 |
self.df.at[index, 'c2r'] = self.get_criteria_review(
|
274 |
-
c2, review=review)
|
275 |
s = ''
|
276 |
df_edit = self.df[self.get_subset_condition(
|
277 |
self.df, story_id)].reaction_show.copy()
|
|
|
74 |
def get_c1_plot(self):
|
75 |
# c2_threshold=0
|
76 |
c1_threshold_list = np.arange(0, 1, 0.01)
|
77 |
+
c1_reaction_weight_list = np.arange(0, 1.1, 0.1)
|
78 |
|
79 |
# reaction_weight=0.5
|
80 |
list_stories = self.df.Story.unique()
|
|
|
118 |
df_c1.at[index, 'c1'] = reaction_show
|
119 |
review = df_c1.e_review[index]
|
120 |
df_c1.at[index, 'c1r'] = self.get_criteria_review(
|
121 |
+
reaction_show, review=review, neutral_emotion=row.Emotion == 'neutral')
|
122 |
c1r_sum = df_c1['c1r'].sum()
|
123 |
c1r_sum_list.append(c1r_sum)
|
124 |
c1_analysis_dict['c1_threshold']=c1_threshold
|
|
|
162 |
subset_condition = self.get_subset_condition(df_c2, story_id)
|
163 |
dfs = df_c2[subset_condition]
|
164 |
for i, (index, row) in enumerate(dfs.iterrows()):
|
165 |
+
c2 = row.Score > c2_threshold
|
166 |
df_c2.at[index, 'c2'] = c2
|
167 |
review = df_c2.e_review[index]
|
168 |
df_c2.at[index, 'c2r'] = self.get_criteria_review(
|
169 |
+
c2, review=review, neutral_emotion=row.Emotion == 'neutral')
|
170 |
c2r_sum_list.append(df_c2['c2r'].sum())
|
171 |
fig = px.line(x=c2_threshold_list, y=c2r_sum_list)
|
172 |
fig.update_layout(
|
|
|
188 |
return (data.Story == story_id) & (data.Turn == 'user')
|
189 |
|
190 |
@staticmethod
|
191 |
+
def get_criteria_review(c, review, neutral_emotion=False):
|
192 |
# printj.green(f'{c} {type(c)}')
|
193 |
# printj.green(f'{review} {type(review)}')
|
194 |
+
review_bool = True if (review == 'o' or review == None) else False if (c == False and review == 'x') else None
|
195 |
+
if neutral_emotion and review_bool:
|
196 |
+
result = True
|
197 |
+
else:
|
198 |
+
result = (c and review_bool) or (not c and not review_bool)
|
199 |
+
return np.round(int(result), 0)
|
200 |
# return str(np.round(result, 0))
|
201 |
|
202 |
def get_ngram_pattern(self, s, n=2):
|
|
|
272 |
self.df.at[index, 'c2'] = c2
|
273 |
review = self.df.e_review[index]
|
274 |
self.df.at[index, 'c1r'] = self.get_criteria_review(
|
275 |
+
reaction_show, review=review, neutral_emotion=row.Emotion == 'neutral')
|
276 |
self.df.at[index, 'c2r'] = self.get_criteria_review(
|
277 |
+
c2, review=review, neutral_emotion=row.Emotion == 'neutral')
|
278 |
s = ''
|
279 |
df_edit = self.df[self.get_subset_condition(
|
280 |
self.df, story_id)].reaction_show.copy()
|