Spaces:
Sleeping
Sleeping
File size: 17,275 Bytes
a3934b1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 |
# test_datasets.py
"""
Test dataset management for Verification Mode.
Provides predefined test datasets with messages pre-classified as GREEN, YELLOW, or RED
for verifying the spiritual distress classifier's accuracy.
"""
from typing import Dict, List
from src.core.verification_models import TestDataset, TestMessage
class TestDatasetManager:
"""Manages predefined test datasets for verification."""
# Dataset 1: Suicidal Ideation Messages
SUICIDAL_IDEATION_DATASET = TestDataset(
dataset_id="dataset_suicidal_ideation",
name="🔴 Suicidal Ideation Messages",
description="Messages from patients expressing suicidal thoughts or severe hopelessness",
messages=[
TestMessage(
message_id="suicidal_001",
text="I don't see any point in living anymore. Everything feels hopeless and I can't go on.",
pre_classified_label="red",
),
TestMessage(
message_id="suicidal_002",
text="I've been thinking about ending it all. I have a plan and I'm ready.",
pre_classified_label="red",
),
TestMessage(
message_id="suicidal_003",
text="My family would be better off without me. I'm just a burden to everyone.",
pre_classified_label="red",
),
TestMessage(
message_id="suicidal_004",
text="I've already said goodbye to my loved ones. I'm going to do it tonight.",
pre_classified_label="red",
),
TestMessage(
message_id="suicidal_005",
text="Nothing matters anymore. I'm tired of fighting. I just want the pain to stop.",
pre_classified_label="red",
),
TestMessage(
message_id="suicidal_006",
text="I've been researching ways to hurt myself. I think I'm ready to try.",
pre_classified_label="red",
),
TestMessage(
message_id="suicidal_007",
text="Everyone would be happier if I was gone. I'm a failure and a disappointment.",
pre_classified_label="red",
),
TestMessage(
message_id="suicidal_008",
text="I can't take this anymore. The pain is unbearable and I see no way out.",
pre_classified_label="red",
),
TestMessage(
message_id="suicidal_009",
text="I've written a note. I'm going to do it. Please don't try to stop me.",
pre_classified_label="red",
),
TestMessage(
message_id="suicidal_010",
text="I'm standing on the edge right now. I'm about to jump.",
pre_classified_label="red",
),
TestMessage(
message_id="suicidal_011",
text="I have the pills in my hand. This is it. Goodbye.",
pre_classified_label="red",
),
TestMessage(
message_id="suicidal_012",
text="My life is meaningless. I'm just taking up space. It's time to end this.",
pre_classified_label="red",
),
],
)
# Dataset 2: Anxiety and Worry Messages
ANXIETY_WORRY_DATASET = TestDataset(
dataset_id="dataset_anxiety_worry",
name="🟡 Anxiety and Worry Messages",
description="Messages from patients expressing anxiety, worry, or moderate distress",
messages=[
TestMessage(
message_id="anxiety_001",
text="I've been feeling really anxious lately. My heart races and I can't sleep.",
pre_classified_label="yellow",
),
TestMessage(
message_id="anxiety_002",
text="I'm worried about my health. I keep thinking something is wrong with me.",
pre_classified_label="yellow",
),
TestMessage(
message_id="anxiety_003",
text="I'm having panic attacks at work. I don't know what's triggering them.",
pre_classified_label="yellow",
),
TestMessage(
message_id="anxiety_004",
text="I feel overwhelmed by everything. There's too much going on in my life.",
pre_classified_label="yellow",
),
TestMessage(
message_id="anxiety_005",
text="I'm stressed about my upcoming surgery. I keep imagining things going wrong.",
pre_classified_label="yellow",
),
TestMessage(
message_id="anxiety_006",
text="I'm having trouble concentrating because I'm so worried about finances.",
pre_classified_label="yellow",
),
TestMessage(
message_id="anxiety_007",
text="I feel like something bad is going to happen, but I don't know what.",
pre_classified_label="yellow",
),
TestMessage(
message_id="anxiety_008",
text="My anxiety is affecting my relationships. I'm pushing people away.",
pre_classified_label="yellow",
),
TestMessage(
message_id="anxiety_009",
text="I'm afraid of having another panic attack. It's controlling my life.",
pre_classified_label="yellow",
),
TestMessage(
message_id="anxiety_010",
text="I'm worried about my child's health. I check on them constantly.",
pre_classified_label="yellow",
),
TestMessage(
message_id="anxiety_011",
text="I'm nervous about starting my new job. What if I'm not good enough?",
pre_classified_label="yellow",
),
TestMessage(
message_id="anxiety_012",
text="I've been having chest pain and I'm scared it's my heart.",
pre_classified_label="yellow",
),
],
)
# Dataset 3: Mild Concerns and Sadness Messages
MILD_CONCERNS_DATASET = TestDataset(
dataset_id="dataset_mild_concerns",
name="🟡 Mild Concerns and Sadness Messages",
description="Messages from patients expressing mild concerns, sadness, or minor distress",
messages=[
TestMessage(
message_id="mild_001",
text="I've been feeling a bit down lately. I think I need to talk to someone.",
pre_classified_label="yellow",
),
TestMessage(
message_id="mild_002",
text="I'm sad about my breakup. It's been hard adjusting to being alone.",
pre_classified_label="yellow",
),
TestMessage(
message_id="mild_003",
text="I'm struggling with my faith. I don't feel connected to God anymore.",
pre_classified_label="yellow",
),
TestMessage(
message_id="mild_004",
text="I feel lonely even when I'm around people. I don't know why.",
pre_classified_label="yellow",
),
TestMessage(
message_id="mild_005",
text="I'm disappointed with how my life turned out. I had different dreams.",
pre_classified_label="yellow",
),
TestMessage(
message_id="mild_006",
text="I'm grieving the loss of my parent. Some days are harder than others.",
pre_classified_label="yellow",
),
TestMessage(
message_id="mild_007",
text="I feel guilty about something I did. I can't stop thinking about it.",
pre_classified_label="yellow",
),
TestMessage(
message_id="mild_008",
text="I'm struggling with my identity. I don't know who I am anymore.",
pre_classified_label="yellow",
),
TestMessage(
message_id="mild_009",
text="I feel disconnected from my family. We don't understand each other.",
pre_classified_label="yellow",
),
TestMessage(
message_id="mild_010",
text="I'm worried about my future. I don't know what path to take.",
pre_classified_label="yellow",
),
TestMessage(
message_id="mild_011",
text="I feel ashamed about my past mistakes. I'm trying to move forward.",
pre_classified_label="yellow",
),
TestMessage(
message_id="mild_012",
text="I'm struggling with my purpose. I feel like I'm just going through the motions.",
pre_classified_label="yellow",
),
],
)
# Dataset 4: Healthy and Positive Messages
HEALTHY_POSITIVE_DATASET = TestDataset(
dataset_id="dataset_healthy_positive",
name="🟢 Healthy and Positive Messages",
description="Messages from patients expressing wellness, gratitude, or positive outlook",
messages=[
TestMessage(
message_id="healthy_001",
text="I'm feeling great today! The weather is beautiful and I'm enjoying life.",
pre_classified_label="green",
),
TestMessage(
message_id="healthy_002",
text="I'm grateful for my family and friends. They mean so much to me.",
pre_classified_label="green",
),
TestMessage(
message_id="healthy_003",
text="I just finished a great workout. I feel energized and healthy.",
pre_classified_label="green",
),
TestMessage(
message_id="healthy_004",
text="I got promoted at work! I'm so excited about this new opportunity.",
pre_classified_label="green",
),
TestMessage(
message_id="healthy_005",
text="I'm looking forward to my vacation next month. I need some rest and relaxation.",
pre_classified_label="green",
),
TestMessage(
message_id="healthy_006",
text="My faith is strong. I feel connected to God and at peace.",
pre_classified_label="green",
),
TestMessage(
message_id="healthy_007",
text="I'm proud of myself for overcoming my challenges. I'm stronger now.",
pre_classified_label="green",
),
TestMessage(
message_id="healthy_008",
text="I love spending time with my children. They bring so much joy to my life.",
pre_classified_label="green",
),
TestMessage(
message_id="healthy_009",
text="I'm doing well with my recovery. I'm taking it one day at a time.",
pre_classified_label="green",
),
TestMessage(
message_id="healthy_010",
text="I'm excited about my new hobby. It's helping me relax and have fun.",
pre_classified_label="green",
),
TestMessage(
message_id="healthy_011",
text="I'm feeling optimistic about the future. I have hope and dreams.",
pre_classified_label="green",
),
TestMessage(
message_id="healthy_012",
text="I'm grateful for my health. I'm taking good care of myself.",
pre_classified_label="green",
),
],
)
# Dataset 5: Mixed Scenarios
MIXED_SCENARIOS_DATASET = TestDataset(
dataset_id="dataset_mixed_scenarios",
name="🎯 Mixed Scenarios",
description="A diverse mix of messages across all classification levels",
messages=[
TestMessage(
message_id="mixed_001",
text="I'm having a good day today. Work went well.",
pre_classified_label="green",
),
TestMessage(
message_id="mixed_002",
text="I'm feeling a bit stressed about the upcoming deadline.",
pre_classified_label="yellow",
),
TestMessage(
message_id="mixed_003",
text="I'm worried about my health. I've been having chest pains.",
pre_classified_label="yellow",
),
TestMessage(
message_id="mixed_004",
text="I'm grateful for my supportive family.",
pre_classified_label="green",
),
TestMessage(
message_id="mixed_005",
text="I can't stop thinking about harming myself. I need help.",
pre_classified_label="red",
),
TestMessage(
message_id="mixed_006",
text="I'm enjoying my new hobby. It's really helping me relax.",
pre_classified_label="green",
),
TestMessage(
message_id="mixed_007",
text="I'm feeling overwhelmed by everything. I don't know how to cope.",
pre_classified_label="yellow",
),
TestMessage(
message_id="mixed_008",
text="I'm at peace with my life. I feel fulfilled.",
pre_classified_label="green",
),
TestMessage(
message_id="mixed_009",
text="I'm having thoughts of ending my life. I'm scared.",
pre_classified_label="red",
),
TestMessage(
message_id="mixed_010",
text="I'm struggling with my faith, but I'm trying to stay positive.",
pre_classified_label="yellow",
),
TestMessage(
message_id="mixed_011",
text="I'm doing well. My medication is helping.",
pre_classified_label="green",
),
TestMessage(
message_id="mixed_012",
text="I'm terrified. I don't think I can go on anymore.",
pre_classified_label="red",
),
TestMessage(
message_id="mixed_013",
text="I'm worried about my job security.",
pre_classified_label="yellow",
),
TestMessage(
message_id="mixed_014",
text="I'm grateful for another day of life.",
pre_classified_label="green",
),
TestMessage(
message_id="mixed_015",
text="I'm planning to end this. I've made my decision.",
pre_classified_label="red",
),
],
)
@classmethod
def get_all_datasets(cls) -> Dict[str, TestDataset]:
"""Get all available test datasets."""
return {
cls.SUICIDAL_IDEATION_DATASET.dataset_id: cls.SUICIDAL_IDEATION_DATASET,
cls.ANXIETY_WORRY_DATASET.dataset_id: cls.ANXIETY_WORRY_DATASET,
cls.MILD_CONCERNS_DATASET.dataset_id: cls.MILD_CONCERNS_DATASET,
cls.HEALTHY_POSITIVE_DATASET.dataset_id: cls.HEALTHY_POSITIVE_DATASET,
cls.MIXED_SCENARIOS_DATASET.dataset_id: cls.MIXED_SCENARIOS_DATASET,
}
@classmethod
def get_dataset(cls, dataset_id: str) -> TestDataset:
"""Get a specific dataset by ID."""
datasets = cls.get_all_datasets()
if dataset_id not in datasets:
raise ValueError(f"Dataset {dataset_id} not found")
return datasets[dataset_id]
@classmethod
def get_dataset_list(cls) -> List[Dict[str, str]]:
"""Get a list of all datasets with metadata."""
datasets = cls.get_all_datasets()
return [
{
"dataset_id": dataset.dataset_id,
"name": dataset.name,
"description": dataset.description,
"message_count": dataset.message_count,
}
for dataset in datasets.values()
]
@classmethod
def load_dataset(cls, dataset_id: str) -> TestDataset:
"""Load a dataset and return it with all messages."""
return cls.get_dataset(dataset_id)
@classmethod
def get_messages_from_dataset(cls, dataset_id: str) -> List[TestMessage]:
"""Get all messages from a specific dataset."""
dataset = cls.get_dataset(dataset_id)
return dataset.messages
|