How to use get_group method in localstack

Best Python code snippet using localstack_python

agreement_score.py

Source:agreement_score.py Github

copy

Full Screen

...101 total_agreement = 0102 total_messages = 0103 skipped = 0104 try:105 annot1threads = annotationDataset.groupby("annotator1Name").get_group(annotatorname).thread.unique()106 except:107 annot1threads = []108 try:109 annot2threads = annotationDataset.groupby("annotator2Name").get_group(annotatorname).thread.unique()110 except:111 annot2threads = []112 try:113 annot3threads = annotationDataset.groupby("annotator3Name").get_group(annotatorname).thread.unique()114 except:115 annot3threads =[]116 for thread in annot1threads:117 if not annotationDataset.groupby('thread').get_group(thread).annotator2Name.unique()[0] in removedAnnotators \118 and type(annotationDataset.groupby('thread').get_group(thread).annotator2Name.unique()[0]) == str:119 comp12emp = annotationDataset.groupby('thread').get_group(thread).annotator1IsEmpathy == \120 annotationDataset.groupby('thread').get_group(thread).annotator2IsEmpathy121 comp12askemp = annotationDataset.groupby('thread').get_group(thread).annotator1AskEmpathy == \122 annotationDataset.groupby('thread').get_group(thread).annotator2AskEmpathy123 comp12cta = annotationDataset.groupby('thread').get_group(thread).annotator1CallToAction == \124 annotationDataset.groupby('thread').get_group(thread).annotator2CallToAction125 comp12isans = annotationDataset.groupby('thread').get_group(thread).annotator1IsAnswer == \126 annotationDataset.groupby('thread').get_group(thread).annotator2IsAnswer127 comp12isq = annotationDataset.groupby('thread').get_group(thread).annotator1IsQuestion == \128 annotationDataset.groupby('thread').get_group(thread).annotator2IsQuestion129 multiplier12 = scoredict[annotationDataset.groupby('thread').get_group(thread).annotator2Name.unique()[0]]130 for i, _ in enumerate(comp12emp):131 if type(list(annotationDataset.groupby('thread').get_group(thread).annotator1AskEmpathy)[i]) == float:132 comp12askemp[i] = False # don't count nan as agreeing133 total_messages -= 1134 if type(list(annotationDataset.groupby('thread').get_group(thread).annotator1CallToAction)[i]) == float:135 comp12cta[i] = False136 total_messages -= 1137 if type(list(annotationDataset.groupby('thread').get_group(thread).annotator1IsAnswer)[i]) == float:138 comp12isans[i] = False139 total_messages -= 1140 if type(list(annotationDataset.groupby('thread').get_group(thread).annotator1IsQuestion)[i]) == float:141 comp12isq[i] = False142 total_messages -= 1143 if type(list(annotationDataset.groupby('thread').get_group(thread).annotator1IsEmpathy)[i]) == float:144 comp12emp[i] = False145 total_messages -= 1146 total_agreement += sum([sum(x) * multiplier12 for x in [comp12askemp, comp12cta, comp12isans, comp12isq, comp12emp]])147 total_messages += sum([x.__len__() for x in [comp12askemp, comp12cta, comp12isans, comp12isq, comp12emp]])148 if not annotationDataset.groupby('thread').get_group(thread).annotator3Name.unique()[0] in removedAnnotators \149 and type(annotationDataset.groupby('thread').get_group(thread).annotator3Name.unique()[0]) == str:150 comp13emp = annotationDataset.groupby('thread').get_group(thread).annotator1IsEmpathy == \151 annotationDataset.groupby('thread').get_group(thread).annotator3IsEmpathy152 comp13askemp = annotationDataset.groupby('thread').get_group(thread).annotator1AskEmpathy == \153 annotationDataset.groupby('thread').get_group(thread).annotator3AskEmpathy154 comp13cta = annotationDataset.groupby('thread').get_group(thread).annotator1CallToAction == \155 annotationDataset.groupby('thread').get_group(thread).annotator3CallToAction156 comp13isans = annotationDataset.groupby('thread').get_group(thread).annotator1IsAnswer == \157 annotationDataset.groupby('thread').get_group(thread).annotator3IsAnswer158 comp13isq = annotationDataset.groupby('thread').get_group(thread).annotator1IsQuestion == \159 annotationDataset.groupby('thread').get_group(thread).annotator3IsQuestion160 # comp13 = annotationDataset.groupby('thread').get_group(thread).annotator1IsEmpathy == \161 # annotationDataset.groupby('thread').get_group(thread).annotator3IsEmpathy162 multiplier13 = scoredict[annotationDataset.groupby('thread').get_group(thread).annotator3Name.unique()[0]]163 for i, _ in enumerate(comp13emp):164 if type(list(annotationDataset.groupby('thread').get_group(thread).annotator1AskEmpathy)[i]) == float:165 comp13askemp[i] = False # don't count nan as agreeing166 total_messages -= 1167 if type(list(annotationDataset.groupby('thread').get_group(thread).annotator1CallToAction)[i]) == float:168 comp13cta[i] = False169 total_messages -= 1170 if type(list(annotationDataset.groupby('thread').get_group(thread).annotator1IsAnswer)[i]) == float:171 comp13isans[i] = False172 total_messages -= 1173 if type(list(annotationDataset.groupby('thread').get_group(thread).annotator1IsQuestion)[i]) == float:174 comp13isq[i] = False175 total_messages -= 1176 if type(list(annotationDataset.groupby('thread').get_group(thread).annotator1IsEmpathy)[i]) == float:177 comp13emp[i] = False178 total_messages -= 1179 total_agreement += sum([sum(x) * multiplier13 for x in [comp13askemp, comp13cta, comp13isans, comp13isq, comp13emp]])180 total_messages += sum([x.__len__() for x in [comp13askemp, comp13cta, comp13isans, comp13isq, comp13emp]])181 for thread in annot2threads:182 if not annotationDataset.groupby('thread').get_group(thread).annotator1Name.unique()[0] in removedAnnotators \183 and type(annotationDataset.groupby('thread').get_group(thread).annotator1Name.unique()[0]) == str:184 comp21emp = annotationDataset.groupby('thread').get_group(thread).annotator2IsEmpathy == \185 annotationDataset.groupby('thread').get_group(thread).annotator1IsEmpathy186 comp21askemp = annotationDataset.groupby('thread').get_group(thread).annotator2AskEmpathy == \187 annotationDataset.groupby('thread').get_group(thread).annotator1AskEmpathy188 comp21cta = annotationDataset.groupby('thread').get_group(thread).annotator2CallToAction == \189 annotationDataset.groupby('thread').get_group(thread).annotator1CallToAction190 comp21isans = annotationDataset.groupby('thread').get_group(thread).annotator2IsAnswer == \191 annotationDataset.groupby('thread').get_group(thread).annotator1IsAnswer192 comp21isq = annotationDataset.groupby('thread').get_group(thread).annotator2IsQuestion == \193 annotationDataset.groupby('thread').get_group(thread).annotator1IsQuestion194 # comp21 = annotationDataset.groupby('thread').get_group(thread).annotator2IsEmpathy == annotationDataset.groupby('thread').get_group(thread).annotator1IsEmpathy195 multiplier21 = scoredict[annotationDataset.groupby('thread').get_group(thread).annotator1Name.unique()[0]]196 for i, _ in enumerate(comp21emp):197 if type(list(annotationDataset.groupby('thread').get_group(thread).annotator2AskEmpathy)[i]) == float:198 comp21askemp[i] = False # don't count nan as agreeing199 total_messages -= 1200 if type(list(annotationDataset.groupby('thread').get_group(thread).annotator2CallToAction)[i]) == float:201 comp21cta[i] = False202 total_messages -= 1203 if type(list(annotationDataset.groupby('thread').get_group(thread).annotator2IsAnswer)[i]) == float:204 comp21isans[i] = False205 total_messages -= 1206 if type(list(annotationDataset.groupby('thread').get_group(thread).annotator2IsQuestion)[i]) == float:207 comp21isq[i] = False208 total_messages -= 1209 if type(list(annotationDataset.groupby('thread').get_group(thread).annotator2IsEmpathy)[i]) == float:210 comp21emp[i] = False211 total_messages -= 1212 # comp21[i] = False213 total_agreement += sum([sum(x) * multiplier21 for x in [comp21askemp, comp21cta, comp21isans, comp21isq, comp21emp]])214 total_messages += sum([x.__len__() for x in [comp21askemp, comp21cta, comp21isans, comp21isq, comp21emp]])215 if not annotationDataset.groupby('thread').get_group(thread).annotator3Name.unique()[0] in removedAnnotators \216 and type(annotationDataset.groupby('thread').get_group(thread).annotator3Name.unique()[0]) == str:217 comp23emp = annotationDataset.groupby('thread').get_group(thread).annotator2IsEmpathy == \218 annotationDataset.groupby('thread').get_group(thread).annotator3IsEmpathy219 comp23askemp = annotationDataset.groupby('thread').get_group(thread).annotator2AskEmpathy == \220 annotationDataset.groupby('thread').get_group(thread).annotator3AskEmpathy221 comp23cta = annotationDataset.groupby('thread').get_group(thread).annotator2CallToAction == \222 annotationDataset.groupby('thread').get_group(thread).annotator3CallToAction223 comp23isans = annotationDataset.groupby('thread').get_group(thread).annotator2IsAnswer == \224 annotationDataset.groupby('thread').get_group(thread).annotator3IsAnswer225 comp23isq = annotationDataset.groupby('thread').get_group(thread).annotator2IsQuestion == \226 annotationDataset.groupby('thread').get_group(thread).annotator3IsQuestion227 # comp23 = annotationDataset.groupby('thread').get_group(thread).annotator2IsEmpathy == annotationDataset.groupby('thread').get_group(thread).annotator3IsEmpathy228 multiplier23 = scoredict[annotationDataset.groupby('thread').get_group(thread).annotator3Name.unique()[0]]229 for i, _ in enumerate(comp23emp):230 if type(list(annotationDataset.groupby('thread').get_group(thread).annotator2AskEmpathy)[i]) == float:231 comp23askemp[i] = False # don't count nan as agreeing232 total_messages -= 1233 if type(list(annotationDataset.groupby('thread').get_group(thread).annotator2CallToAction)[i]) == float:234 comp23cta[i] = False235 total_messages -= 1236 if type(list(annotationDataset.groupby('thread').get_group(thread).annotator2IsAnswer)[i]) == float:237 comp23isans[i] = False238 total_messages -= 1239 if type(list(annotationDataset.groupby('thread').get_group(thread).annotator2IsQuestion)[i]) == float:240 comp23isq[i] = False241 total_messages -= 1242 if type(list(annotationDataset.groupby('thread').get_group(thread).annotator2IsEmpathy)[i]) == float:243 comp23emp[i] = False244 total_messages -= 1245 total_agreement += sum([sum(x) * multiplier23 for x in [comp23askemp, comp23cta, comp23isans, comp23isq, comp23emp]])246 total_messages += sum([x.__len__() for x in [comp23askemp, comp23cta, comp23isans, comp23isq, comp23emp]])247 for thread in annot3threads:248 if not annotationDataset.groupby('thread').get_group(thread).annotator1Name.unique()[0] in removedAnnotators \249 and type(annotationDataset.groupby('thread').get_group(thread).annotator1Name.unique()[0]) == str:250 comp31emp = annotationDataset.groupby('thread').get_group(thread).annotator3IsEmpathy == \251 annotationDataset.groupby('thread').get_group(thread).annotator1IsEmpathy252 comp31askemp = annotationDataset.groupby('thread').get_group(thread).annotator3AskEmpathy == \253 annotationDataset.groupby('thread').get_group(thread).annotator1AskEmpathy254 comp31cta = annotationDataset.groupby('thread').get_group(thread).annotator3CallToAction == \255 annotationDataset.groupby('thread').get_group(thread).annotator1CallToAction256 comp31isans = annotationDataset.groupby('thread').get_group(thread).annotator3IsAnswer == \257 annotationDataset.groupby('thread').get_group(thread).annotator1IsAnswer258 comp31isq = annotationDataset.groupby('thread').get_group(thread).annotator3IsQuestion == \259 annotationDataset.groupby('thread').get_group(thread).annotator1IsQuestion260 # comp31 = annotationDataset.groupby('thread').get_group(thread).annotator3IsEmpathy == annotationDataset.groupby('thread').get_group(thread).annotator1IsEmpathy261 multiplier31 = scoredict[annotationDataset.groupby('thread').get_group(thread).annotator1Name.unique()[0]]262 for i, _ in enumerate(comp31emp):263 if type(list(annotationDataset.groupby('thread').get_group(thread).annotator3AskEmpathy)[i]) == float:264 comp31askemp[i] = False # don't count nan as agreeing265 total_messages -= 1266 if type(list(annotationDataset.groupby('thread').get_group(thread).annotator3CallToAction)[i]) == float:267 comp31cta[i] = False268 total_messages -= 1269 if type(list(annotationDataset.groupby('thread').get_group(thread).annotator3IsAnswer)[i]) == float:270 comp31isans[i] = False271 total_messages -= 1272 if type(list(annotationDataset.groupby('thread').get_group(thread).annotator3IsQuestion)[i]) == float:273 comp31isq[i] = False274 total_messages -= 1275 if type(list(annotationDataset.groupby('thread').get_group(thread).annotator3IsEmpathy)[i]) == float:276 comp31emp[i] = False277 total_messages -= 1278 # comp31[i] = False279 total_agreement += sum([sum(x) * multiplier31 for x in [comp31askemp, comp31cta, comp31isans, comp31isq, comp31emp]])280 total_messages += sum([x.__len__() for x in [comp31askemp, comp31cta, comp31isans, comp31isq, comp31emp]])281 if not annotationDataset.groupby('thread').get_group(thread).annotator2Name.unique()[0] in removedAnnotators \282 and type(annotationDataset.groupby('thread').get_group(thread).annotator2Name.unique()[0]) == str:283 comp32emp = annotationDataset.groupby('thread').get_group(thread).annotator3IsEmpathy == \284 annotationDataset.groupby('thread').get_group(thread).annotator2IsEmpathy285 comp32askemp = annotationDataset.groupby('thread').get_group(thread).annotator3AskEmpathy == \286 annotationDataset.groupby('thread').get_group(thread).annotator2AskEmpathy287 comp32cta = annotationDataset.groupby('thread').get_group(thread).annotator3CallToAction == \288 annotationDataset.groupby('thread').get_group(thread).annotator2CallToAction289 comp32isans = annotationDataset.groupby('thread').get_group(thread).annotator3IsAnswer == \290 annotationDataset.groupby('thread').get_group(thread).annotator2IsAnswer291 comp32isq = annotationDataset.groupby('thread').get_group(thread).annotator3IsQuestion == \292 annotationDataset.groupby('thread').get_group(thread).annotator2IsQuestion293 # comp32 = annotationDataset.groupby('thread').get_group(thread).annotator3IsEmpathy == annotationDataset.groupby('thread').get_group(thread).annotator2IsEmpathy294 multiplier32 = scoredict[annotationDataset.groupby('thread').get_group(thread).annotator2Name.unique()[0]]295 for i, _ in enumerate(comp32emp):296 if type(list(annotationDataset.groupby('thread').get_group(thread).annotator3AskEmpathy)[i]) == float:297 comp32askemp[i] = False # don't count nan as agreeing298 total_messages -= 1299 if type(list(annotationDataset.groupby('thread').get_group(thread).annotator3CallToAction)[i]) == float:300 comp32cta[i] = False301 total_messages -= 1302 if type(list(annotationDataset.groupby('thread').get_group(thread).annotator3IsAnswer)[i]) == float:303 comp32isans[i] = False304 total_messages -= 1305 if type(list(annotationDataset.groupby('thread').get_group(thread).annotator3IsQuestion)[i]) == float:306 comp32isq[i] = False307 total_messages -= 1308 if type(list(annotationDataset.groupby('thread').get_group(thread).annotator3IsEmpathy)[i]) == float:309 comp32emp[i] = False310 total_messages -= 1311 total_agreement += sum([sum(x) * multiplier32 for x in [comp32askemp, comp32cta, comp32isans, comp32isq, comp32emp]])312 total_messages += sum([x.__len__() for x in [comp32askemp, comp32cta, comp32isans, comp32isq, comp32emp]])313 if total_messages == 0:314 agreement_factor = scoredict[annotatorname]315 print('annotator {} has no co annotators left!'.format(annotatorname))316 else:317 agreement_factor =(total_agreement/total_messages)318 with open('data\\agreementscore_with_nan_correction_6.csv', 'a') as file:319 writer = csv.writer(file)320 writer.writerow([iteration, annotatorname, agreement_factor])321 nextiterationscoredict[annotatorname] = 2* agreement_factor322 print(nextiterationscoredict[annotatorname])

Full Screen

Full Screen

test_core.py

Source:test_core.py Github

copy

Full Screen

...66def test_no_mags():67 rat = '1'68 for cue in ['light', 'sound']:69 for trial in [1, 2, 3, 4]:70 this_df = (df.groupby(['rat']).get_group(rat).groupby(['cue_type']).get_group(cue).71 groupby(['trial_type']).get_group(str(trial))[['measure', 'value']])72 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Duration']['value']), 0.0))73 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Count']['value']), 0.0))74 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Latency']['value']), 10.0))75 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'AtLeastOne']['value']), 0.0))76def test_all_mags():77 rat = '2'78 for cue in ['light', 'sound']:79 for trial in [1, 2, 3, 4]:80 this_df = (df.groupby(['rat']).get_group(rat).groupby(['cue_type']).get_group(cue).81 groupby(['trial_type']).get_group(str(trial))[['measure', 'value']])82 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Duration']['value']), 10.0))83 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Count']['value']), 1.0))84 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Latency']['value']), 0.0))85 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'AtLeastOne']['value']), 1.0))86def test_sound_only():87 rat = '3'88 cue = 'sound'89 for trial in [1, 2, 3, 4]:90 this_df = (df.groupby(['rat']).get_group(rat).groupby(['cue_type']).get_group(cue).91 groupby(['trial_type']).get_group(str(trial))[['measure', 'value']])92 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Duration']['value']), 10.0))93 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Count']['value']), 1.0))94 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Latency']['value']), 0.0))95 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'AtLeastOne']['value']), 1.0))96 cue = 'light'97 for trial in [1, 2, 3, 4]:98 this_df = (df.groupby(['rat']).get_group(rat).groupby(['cue_type']).get_group(cue).99 groupby(['trial_type']).get_group(str(trial))[['measure', 'value']])100 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Duration']['value']), 0.0))101 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Count']['value']), 0.0))102 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Latency']['value']), 10.0))103 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'AtLeastOne']['value']), 0.0))104def test_light_only():105 rat = '4'106 cue = 'sound'107 for trial in [1, 2, 3, 4]:108 this_df = (df.groupby(['rat']).get_group(rat).groupby(['cue_type']).get_group(cue).109 groupby(['trial_type']).get_group(str(trial))[['measure', 'value']])110 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Duration']['value']), 0.0))111 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Count']['value']), 0.0))112 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Latency']['value']), 10.0))113 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'AtLeastOne']['value']), 0.0))114 cue = 'light'115 for trial in [1, 2, 3, 4]:116 this_df = (df.groupby(['rat']).get_group(rat).groupby(['cue_type']).get_group(cue).117 groupby(['trial_type']).get_group(str(trial))[['measure', 'value']])118 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Duration']['value']), 10.0))119 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Count']['value']), 1.0))120 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Latency']['value']), 0.0))121 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'AtLeastOne']['value']), 1.0))122def test_rewarded_sound():123 rat = '5'124 cue = 'light'125 for trial in [1, 2, 3, 4]:126 this_df = (df.groupby(['rat']).get_group(rat).groupby(['cue_type']).get_group(cue).127 groupby(['trial_type']).get_group(str(trial))[['measure', 'value']])128 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Duration']['value']), 0.0))129 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Count']['value']), 0.0))130 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Latency']['value']), 10.0))131 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'AtLeastOne']['value']), 0.0))132 cue = 'sound'133 for trial in [2, 3]:134 this_df = (df.groupby(['rat']).get_group(rat).groupby(['cue_type']).get_group(cue).135 groupby(['trial_type']).get_group(str(trial))[['measure', 'value']])136 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Duration']['value']), 0.0))137 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Count']['value']), 0.0))138 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Latency']['value']), 10.0))139 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'AtLeastOne']['value']), 0.0))140 for trial in [1, 4]:141 this_df = (df.groupby(['rat']).get_group(rat).groupby(['cue_type']).get_group(cue).142 groupby(['trial_type']).get_group(str(trial))[['measure', 'value']])143 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Duration']['value']), 10.0))144 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Count']['value']), 1.0))145 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Latency']['value']), 0.0))146 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'AtLeastOne']['value']), 1.0))147def test_iti_only():148 rat = '6'149 for cue in ['light', 'sound']:150 for trial in [1, 2, 3, 4]:151 this_df = (df.groupby(['rat']).get_group(rat).groupby(['cue_type']).get_group(cue).152 groupby(['trial_type']).get_group(str(trial))[['measure', 'value']])153 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Duration']['value']), 0.0))154 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Count']['value']), 0.0))155 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Latency']['value']), 10.0))156 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'AtLeastOne']['value']), 0.0))157def test_half_light():158 rat = '7'159 cue = 'sound'160 for trial in [1, 2, 3, 4]:161 this_df = (df.groupby(['rat']).get_group(rat).groupby(['cue_type']).get_group(cue).162 groupby(['trial_type']).get_group(str(trial))[['measure', 'value']])163 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Duration']['value']), 0.0))164 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Count']['value']), 0.0))165 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Latency']['value']), 10.0))166 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'AtLeastOne']['value']), 0.0))167 cue = 'light'168 for trial in [1, 4]:169 this_df = (df.groupby(['rat']).get_group(rat).groupby(['cue_type']).get_group(cue).170 groupby(['trial_type']).get_group(str(trial))[['measure', 'value']])171 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Duration']['value']), 5.0))172 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Count']['value']), 1.0))173 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Latency']['value']), 5.0))174 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'AtLeastOne']['value']), 1.0))175 for trial in [2, 3]:176 this_df = (df.groupby(['rat']).get_group(rat).groupby(['cue_type']).get_group(cue).177 groupby(['trial_type']).get_group(str(trial))[['measure', 'value']])178 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Duration']['value']), 5.0))179 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Count']['value']), 1.0))180 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Latency']['value']), 0.0))181 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'AtLeastOne']['value']), 1.0))182def test_complex():183 rat = '8'184 trial = 1185 cue = 'light'186 this_df = (df.groupby(['rat']).get_group(rat).groupby(['cue_type']).get_group(cue).187 groupby(['trial_type']).get_group(str(trial))[['measure', 'value']])188 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Duration']['value']), 1.0))189 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Count']['value']), 1.0))190 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Latency']['value']), 9.0))191 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'AtLeastOne']['value']), 1.0))192 cue = 'sound'193 this_df = (df.groupby(['rat']).get_group(rat).groupby(['cue_type']).get_group(cue).194 groupby(['trial_type']).get_group(str(trial))[['measure', 'value']])195 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Duration']['value']), 1.98))196 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Count']['value']), 1.0))197 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Latency']['value']), 0.0))198 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'AtLeastOne']['value']), 1.0))199 trial = 2200 cue = 'light'201 this_df = (df.groupby(['rat']).get_group(rat).groupby(['cue_type']).get_group(cue).202 groupby(['trial_type']).get_group(str(trial))[['measure', 'value']])203 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Duration']['value']), 0.0))204 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Count']['value']), 0.0))205 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Latency']['value']), 10.0))206 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'AtLeastOne']['value']), 0.0))207 cue = 'sound'208 this_df = (df.groupby(['rat']).get_group(rat).groupby(['cue_type']).get_group(cue).209 groupby(['trial_type']).get_group(str(trial))[['measure', 'value']])210 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Duration']['value']), 10.0))211 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Count']['value']), 1.0))212 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Latency']['value']), 0.0))213 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'AtLeastOne']['value']), 1.0))214 trial = 3215 cue = 'light'216 this_df = (df.groupby(['rat']).get_group(rat).groupby(['cue_type']).get_group(cue).217 groupby(['trial_type']).get_group(str(trial))[['measure', 'value']])218 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Duration']['value']), 2.5))219 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Count']['value']), 2.0))220 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Latency']['value']), 0.0))221 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'AtLeastOne']['value']), 1.0))222 cue = 'sound'223 this_df = (df.groupby(['rat']).get_group(rat).groupby(['cue_type']).get_group(cue).224 groupby(['trial_type']).get_group(str(trial))[['measure', 'value']])225 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Duration']['value']), 10.0))226 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Count']['value']), 1.0))227 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Latency']['value']), 0.0))228 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'AtLeastOne']['value']), 1.0))229 trial = 4230 cue = 'light'231 this_df = (df.groupby(['rat']).get_group(rat).groupby(['cue_type']).get_group(cue).232 groupby(['trial_type']).get_group(str(trial))[['measure', 'value']])233 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Duration']['value']), 0.0))234 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Count']['value']), 0.0))235 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Latency']['value']), 10.0))236 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'AtLeastOne']['value']), 0.0))237 cue = 'sound'238 this_df = (df.groupby(['rat']).get_group(rat).groupby(['cue_type']).get_group(cue).239 groupby(['trial_type']).get_group(str(trial))[['measure', 'value']])240 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Duration']['value']), 0.0))241 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Count']['value']), 0.0))242 assert (np.allclose(np.mean(this_df[this_df['measure'] == 'Latency']['value']), 10.0))...

Full Screen

Full Screen

manual_annotator_compare.py

Source:manual_annotator_compare.py Github

copy

Full Screen

...14 total_agreement = 015 total_messages = 016 skipped = 017 try:18 annot1threads = annotationDataset.groupby("annotator1Name").get_group(annotatorname).thread.unique()19 except:20 annot1threads = []21 try:22 annot2threads = annotationDataset.groupby("annotator2Name").get_group(annotatorname).thread.unique()23 except:24 annot2threads = []25 try:26 annot3threads = annotationDataset.groupby("annotator3Name").get_group(annotatorname).thread.unique()27 except:28 annot3threads =[]29 for thread in annot1threads:30 if annotationDataset.groupby('thread').get_group(thread).annotator2Name.unique().__len__()>0 and \31 annotationDataset.groupby('thread').get_group(thread).annotator3Name.unique().__len__()>0:32 if not annotationDataset.groupby('thread').get_group(thread).annotator2Name.unique()[0] in removedAnnotators and \33 not annotationDataset.groupby('thread').get_group(thread).annotator3Name.unique()[0] in removedAnnotators:34 otherscompEmph = annotationDataset.groupby('thread').get_group(thread).annotator2IsEmpathy == \35 annotationDataset.groupby('thread').get_group(thread).annotator3IsEmpathy36 annotcompEmph = annotationDataset.groupby('thread').get_group(thread).annotator1IsEmpathy == \37 [x if list(otherscompEmph)[i] else list(annotationDataset.groupby('thread').get_group(thread).annotator1IsEmpathy)[i] for i, x in enumerate(annotationDataset.groupby('thread').get_group(thread).annotator2IsEmpathy)]38 for i, text in enumerate(annotationDataset.groupby('thread').get_group(thread).text):39 if not type(list(annotationDataset.groupby('thread').get_group(thread).annotator1IsEmpathy)[i]) == float:40 if agreemode:41 if not list(annotcompEmph)[i]:42 print(text, annotatorname,43 list(annotationDataset.groupby('thread').get_group(thread).annotator1IsEmpathy)[i])44 if list(annotationDataset.groupby('thread').get_group(thread).annotator1IsEmpathy)[i] == True:45 print(list(annotationDataset.groupby('thread').get_group(thread).annotator1EmpathyType)[46 i],47 list(annotationDataset.groupby('thread').get_group(48 thread).annotator1EmpathyValence)[i])49 # else:50 # continue51 inp = input('1 to agree, 0 to disagree, 2 to switch agreemode')52 if int(inp) == 2:53 agreemode = not agreemode54 continue55 total_messages += 156 total_agreement += int(inp)57 else:58 skipped+=159 # if not list(annotcompEmph)[i]:60 else:61 print(text, annotatorname, list(annotationDataset.groupby('thread').get_group(thread).annotator1IsEmpathy)[i])62 if list(annotationDataset.groupby('thread').get_group(thread).annotator1IsEmpathy)[i] == True:63 print(list(annotationDataset.groupby('thread').get_group(thread).annotator1EmpathyType)[i],64 list(annotationDataset.groupby('thread').get_group(thread).annotator1EmpathyValence)[i])65 else:66 continue67 inp = input('1 to agree, 0 to disagree, 2 to switch agreemode')68 if int(inp) == 2:69 agreemode = not agreemode70 continue71 total_messages += 172 total_agreement += int(inp)73 # else:74 # skipped+=175 print("intermediary result: {} agreed out of {} for annotator {}".format(total_agreement, total_messages,76 annotatorname))77 for thread in annot2threads:78 if annotationDataset.groupby('thread').get_group(thread).annotator1Name.unique().__len__()>0 and \79 annotationDataset.groupby('thread').get_group(thread).annotator3Name.unique().__len__()>0:80 if not annotationDataset.groupby('thread').get_group(thread).annotator1Name.unique()[0] in removedAnnotators and \81 not annotationDataset.groupby('thread').get_group(thread).annotator3Name.unique()[0] in removedAnnotators:82 otherscompEmph = annotationDataset.groupby('thread').get_group(thread).annotator1IsEmpathy == annotationDataset.groupby('thread').get_group(thread).annotator3IsEmpathy83 annotcompEmph = annotationDataset.groupby('thread').get_group(thread).annotator2IsEmpathy == \84 [x if list(otherscompEmph)[i] else list(annotationDataset.groupby('thread').get_group(thread).annotator2IsEmpathy)[i] for i, x in enumerate(annotationDataset.groupby('thread').get_group(thread).annotator1IsEmpathy)]85 for i, text in enumerate(annotationDataset.groupby('thread').get_group(thread).text):86 if not type(list(annotationDataset.groupby('thread').get_group(thread).annotator2IsEmpathy)[i]) == float:87 if agreemode:88 if not list(annotcompEmph)[i]:89 print(text, annotatorname, list(annotationDataset.groupby('thread').get_group(thread).annotator2IsEmpathy)[i])90 if list(annotationDataset.groupby('thread').get_group(thread).annotator2IsEmpathy)[i] == True:91 print(list(annotationDataset.groupby('thread').get_group(thread).annotator2EmpathyType)[i],92 list(annotationDataset.groupby('thread').get_group(thread).annotator2EmpathyValence)[i])93 # else:94 # continue95 inp = input('1 to agree, 0 to disagree, 2 to switch agreemode')96 if int(inp) == 2:97 agreemode = not agreemode98 continue99 total_messages += 1100 total_agreement += int(inp)101 else:102 skipped+=1103 else:104 print(text, annotatorname,105 list(annotationDataset.groupby('thread').get_group(thread).annotator2IsEmpathy)[i])106 if list(annotationDataset.groupby('thread').get_group(thread).annotator2IsEmpathy)[i] == True:107 print(list(annotationDataset.groupby('thread').get_group(thread).annotator2EmpathyType)[108 i],109 list(annotationDataset.groupby('thread').get_group(110 thread).annotator2EmpathyValence)[i])111 else:112 continue113 inp = input('1 to agree, 0 to disagree, 2 to switch agreemode')114 if int(inp) == 2:115 agreemode = not agreemode116 continue117 total_messages += 1118 total_agreement += int(inp)119 print("intermediary result: {} agreed out of {} for annotator {}".format(total_agreement, total_messages, annotatorname))120 for thread in annot3threads:121 if annotationDataset.groupby('thread').get_group(thread).annotator1Name.unique().__len__()>0 and \122 annotationDataset.groupby('thread').get_group(thread).annotator2Name.unique().__len__()>0:123 if not annotationDataset.groupby('thread').get_group(thread).annotator1Name.unique()[0] in removedAnnotators and \124 not annotationDataset.groupby('thread').get_group(thread).annotator2Name.unique()[0] in removedAnnotators:125 otherscompEmph = annotationDataset.groupby('thread').get_group(thread).annotator1IsEmpathy == annotationDataset.groupby('thread').get_group(thread).annotator2IsEmpathy126 annotcompEmph = annotationDataset.groupby('thread').get_group(thread).annotator3IsEmpathy == \127 [x if list(otherscompEmph)[i] else list(annotationDataset.groupby('thread').get_group(thread).annotator3IsEmpathy)[i] for i, x in enumerate(annotationDataset.groupby('thread').get_group(thread).annotator1IsEmpathy)]128 for i, text in enumerate(annotationDataset.groupby('thread').get_group(thread).text):129 if not type(list(annotationDataset.groupby('thread').get_group(thread).annotator3IsEmpathy)[i]) == float:130 if agreemode:131 if not list(annotcompEmph)[i]:132 print(text, annotatorname, list(annotationDataset.groupby('thread').get_group(thread).annotator3IsEmpathy)[i])133 if list(annotationDataset.groupby('thread').get_group(thread).annotator3IsEmpathy)[i] == True:134 print(list(annotationDataset.groupby('thread').get_group(thread).annotator3EmpathyType)[i],135 list(annotationDataset.groupby('thread').get_group(thread).annotator3EmpathyValence)[i])136 # else:137 # continue138 inp = input('1 to agree, 0 to disagree, 2 to switch agreemode')139 if int(inp) == 2:140 agreemode = not agreemode141 continue142 total_messages += 1143 total_agreement += int(inp)144 else:145 skipped += 1146 else:147 print(text, annotatorname,148 list(annotationDataset.groupby('thread').get_group(thread).annotator3IsEmpathy)[i])149 if list(annotationDataset.groupby('thread').get_group(thread).annotator3IsEmpathy)[i] == True:150 print(list(annotationDataset.groupby('thread').get_group(thread).annotator3EmpathyType)[151 i],152 list(annotationDataset.groupby('thread').get_group(153 thread).annotator3EmpathyValence)[i])154 else:155 continue156 inp = input('1 to agree, 0 to disagree, 2 to switch agreemode')157 if int(inp) == 2:158 agreemode = not agreemode159 continue160 total_messages += 1161 total_agreement += int(inp)162 print("{} agreed out of {} for annotator {}".format(total_agreement,total_messages, annotatorname))163 print("{} skipped".format(skipped))164 with open('manual_annotator_compare.csv', 'a') as file:165 writer = csv.writer(file)166 writer.writerow([annotatorname,total_agreement,total_messages])

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful