#Add the precalculated conversation history to hare objects hares = [] for conv_hist_file in CONVERSATION_HISTORY_FILES: status_per_conversation = [] for n, line in enumerate(open(conv_hist_file)): status_per_conversation.append(loads(line)[:CONVERSATION_LENGTH]) if n % 100 == 0: print(conv_hist_file, n) for threshold in THRESHOLDS: h = Hare(name=threshold) h.status_per_conversation = status_per_conversation h.cut_off_value = threshold hares.append(h) #Load the conversations conversations = [] current_conversation = Conversation() for line in open(CONVERSATIONS_FILE): line = line.strip() if len(line) == 0: continue elif line[0] == '#':
#For this conversation, we want to know the conversation history for every detector for detector, thresholds in DETECTOR_THRESHOLDS.items(): conversation_history = loads(open_conversation_history_files[detector].readline()) 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: