I have a bug. I'm running the script with "all" (NOT just test data) but only a…
- User
I have a bug. I'm running the script with "all" (NOT just test data) but only a selection of the discussion are being processed. Whats wrong?
""" from time import sleep import pandas as pd import os from openai import OpenAI import json from sklearn.model_selection import train_test_split import matplotlib.pyplot as plt from scipy.stats import pearsonr, spearmanr
from prompts.participation import PARTICIPATION_SYS from prompts.responsivity import RESPONSIVITY_SYS from prompts.internal_cohesion import IN_COHESION_SYS from prompts.social_impact import SOCIAL_IMPACT_SYS from prompts.newness import NEWNESS_SYS from prompts.communication_density import COMMUNICATION_DENSE_SYS
""" Evaluate each GCA aspect using LLM as a judge.
First, for each discussion and participant, create a text file in the following
""" API_KEY_OPENAI = "sk-proj-XXX" os.environ[ "OPENAI_API_KEY"] = API_KEY_OPENAI
SEED = 30 TEST_PATH = "/home/esther/PycharmProjects/Dialogos/role_discovery/group_discussion_analysis_rep/evalGCA/test_data.csv" DATA_PATH = "/home/esther/PycharmProjects/Dialogos/role_discovery/data"
MODELS = {"GPT4_1": "gpt-4.1-2025-04-14", }
PROMPTS = { "participation": PARTICIPATION_SYS, "responsivity": RESPONSIVITY_SYS, "internal_cohesion": IN_COHESION_SYS, "social_impact": SOCIAL_IMPACT_SYS, "newness": NEWNESS_SYS, "communication_density": COMMUNICATION_DENSE_SYS }
def extract_score(response_text: str): """ Parse model response and extract rationale + score. If parsing fails, fall back to raw text. """ try: # Try to parse JSON data = json.loads(response_text) score = int(data.get("score")) rationale = data.get("rationale", "") return score, rationale
codeexcept Exception as e: print(f"Response in unexpected format: {response_text}.") return None, response_text.strip()def load_data(path: str) -> pd.DataFrame: """ load the csv with all discussion turns :param path: :return: """ return pd.read_csv(path)
def create_judge_files(df: pd.DataFrame, output_dir: str): """ Create text files for each discussion and participant for LLM judging in the format: Discussion: <discussion_name> Participant: <participant_name> Text:
code - Assistant
Looking carefully at your code, the most likely reason only a subset of discussions is being processed when you run split="all" is in your create_test_split function, specifically in this block: pythonCopy code# filter out discussions with at least 3 participants and at least 15 contributions valid_discussions = [] for disc, g in df.groupby("discussion"): n_participants = g["author"].nunique() n_cont = len(g) if n_participants >= 3 and n_cont >= 15: valid_discussions.append(disc)