for conversation_index in range(NR_OF_CONVERSATIONS): try: current_status = h.status_per_conversation[ conversation_index][utterance_index] except IndexError: continue speakers = h.conversations[conversation_index].all_speakers per_player.append({ speaker: current_status[speaker] >= threshold if speaker in current_status.keys() else False for speaker in speakers }) true, predicted = h.get_true_and_predicted_scores_at_utterance_index( utterance_index, categorize_predicted_scores=True) tp.append(true_positives(true, predicted)) fp.append(false_positives(true, predicted)) for b in BETA_VALUES: fbeta[b].append(fbeta_score(true, predicted, b)) open(folder_name + 'per_player.js', 'w').write(conv_hist_file + '_per_player[' + str(threshold) + '] = ' + dumps(per_player)) open(folder_name + 'tp.js', 'w').write(conv_hist_file + '_tp[' + str(threshold) + '] = ' + dumps(tp)) open(folder_name + 'fp.js', 'w').write(conv_hist_file + '_fp[' + str(threshold) + '] = ' + dumps(fp))
scores_for_this_conversation = [] #We check what scores this means for every threshold for threshold in thresholds: if threshold not in all_scores[detector].keys(): all_scores[detector][threshold] = [] h = Hare() h.add_conversation(conversation) h.status_per_conversation = [conversation_history] h.cut_off_value = threshold for point_in_conversation in INTERESTING_POINTS_IN_CONVERSATION: true, predicted = h.get_true_and_predicted_scores_at_utterance_index(point_in_conversation,categorize_predicted_scores=True) score = fbeta_score(true, predicted, 1) scores_for_this_conversation.append(score) if convo_index == 0: headers.append(detector+':'+str(threshold)+':'+str(point_in_conversation)) all_scores[detector][threshold].append(scores_for_this_conversation[-len(INTERESTING_POINTS_IN_CONVERSATION):]) if convo_index == 0 and PRINT_OUTPUT: print('convo_id',' '.join(headers)) if PRINT_OUTPUT: print(convo_index,' '.join([str(s) for s in scores_for_this_conversation]))