Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files
server/mentalHealthPatientenv_environment.py
CHANGED
|
@@ -121,7 +121,7 @@ class MentalhealthpatientenvEnvironment(Environment):
|
|
| 121 |
elif action.action_type == "diagnose":
|
| 122 |
# Simulate a diagnosis action by providing feedback based on the patient's state
|
| 123 |
self._state.action_sequence.append(action.action_type)
|
| 124 |
-
curr_diagnosis
|
| 125 |
actual_disorders = self._state.disorder
|
| 126 |
|
| 127 |
reward = calculate_reward(
|
|
|
|
| 121 |
elif action.action_type == "diagnose":
|
| 122 |
# Simulate a diagnosis action by providing feedback based on the patient's state
|
| 123 |
self._state.action_sequence.append(action.action_type)
|
| 124 |
+
curr_diagnosis=action.message.strip().split(',')
|
| 125 |
actual_disorders = self._state.disorder
|
| 126 |
|
| 127 |
reward = calculate_reward(
|
server/reward.py
CHANGED
|
@@ -119,14 +119,28 @@ def calculate_reward(
|
|
| 119 |
# Diagnosis score
|
| 120 |
diagnosis_score = 0.0
|
| 121 |
if action_type == "diagnose" and diagnosis:
|
| 122 |
-
|
|
|
|
| 123 |
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
|
|
|
|
|
|
| 128 |
else:
|
| 129 |
-
diagnosis_score
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
|
| 131 |
# Repetition penalty (converted to positive scale)
|
| 132 |
repeat_penalty = 0.0
|
|
|
|
| 119 |
# Diagnosis score
|
| 120 |
diagnosis_score = 0.0
|
| 121 |
if action_type == "diagnose" and diagnosis:
|
| 122 |
+
if len(diagnosis)==1:
|
| 123 |
+
similarity = disorder_similarity(disorder, diagnosis[-1])
|
| 124 |
|
| 125 |
+
if similarity == "full":
|
| 126 |
+
diagnosis_score = 1.0
|
| 127 |
+
elif similarity == "partial":
|
| 128 |
+
diagnosis_score = 0.5
|
| 129 |
+
else:
|
| 130 |
+
diagnosis_score = 0.0
|
| 131 |
else:
|
| 132 |
+
diagnosis_score=0.0
|
| 133 |
+
for d in diagnosis:
|
| 134 |
+
similarity=disorder_similarity(disorder,d)
|
| 135 |
+
|
| 136 |
+
if similarity=="full":
|
| 137 |
+
diagnosis_score+=0.5
|
| 138 |
+
elif diagnosis_score=="partial":
|
| 139 |
+
diagnosis_score+=0.3
|
| 140 |
+
else:
|
| 141 |
+
diagnosis_score-=0.5
|
| 142 |
+
diagnosis_score=normalize(diagnosis_score,0.0,1.0)
|
| 143 |
+
|
| 144 |
|
| 145 |
# Repetition penalty (converted to positive scale)
|
| 146 |
repeat_penalty = 0.0
|