charlie0831 commited on
Commit
82d2ae3
·
verified ·
1 Parent(s): 8c1a563

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +262 -0
README.md ADDED
@@ -0,0 +1,262 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ ```markdown
3
+ ---
4
+ language:
5
+ - en
6
+ license: mit
7
+ library_name: scikit-learn
8
+ tags:
9
+ - text-classification
10
+ - embeddings
11
+ - symptom-routing
12
+ - public-health
13
+ - information-retrieval
14
+ - logistic-regression
15
+ - linear-svm
16
+ - classifier-comparison
17
+ datasets:
18
+ - https://huggingface.co/datasets/charlie0831/english-symptom-routing
19
+ metrics:
20
+ - accuracy
21
+ - f1
22
+ ---
23
+
24
+ # Symptom Routing Embedding Classifier Comparison
25
+
26
+ ## Model Description
27
+
28
+ This repository contains embedding-based classifiers for routing short English symptom descriptions into broad public health information categories. The project was created for an Information Retrieval assignment to test whether frozen text embeddings can support query routing before retrieval.
29
+
30
+ Four classifiers were trained and evaluated on the same train/test split:
31
+
32
+ - Logistic Regression
33
+ - Linear SVM
34
+ - KNN with cosine distance
35
+ - Random Forest
36
+
37
+ The best deployed classifier is Logistic Regression. It achieved **0.957 accuracy** and **0.952 macro F1** on the held-out test set.
38
+
39
+ The model predicts one of six broad routing categories:
40
+
41
+ - `respiratory`
42
+ - `gastrointestinal`
43
+ - `skin`
44
+ - `neurological`
45
+ - `musculoskeletal`
46
+ - `mental_health_sleep`
47
+
48
+ The labels are broad public health information categories, not diagnoses or clinical conditions.
49
+
50
+ **Important safety notice:**
51
+ This model is for teaching information retrieval and text classification. It does not provide medical diagnosis, treatment advice, or emergency guidance.
52
+
53
+ ## Intended Use
54
+
55
+ This model is intended for:
56
+
57
+ - teaching embedding-based text classification
58
+ - routing short symptom descriptions toward broad public health information categories
59
+ - demonstrating information retrieval query routing
60
+ - comparing lightweight classifiers trained on frozen embeddings
61
+ - supporting a Gradio demo for symptom information routing
62
+
63
+ Example use case:
64
+
65
+ ```text
66
+ Input: I have a dry cough and sore throat.
67
+ Output: respiratory
68
+ ```
69
+
70
+ The predicted category can be used as a retrieval signal for selecting broad public health information resources.
71
+
72
+ ## Out-of-Scope Use
73
+
74
+ This model must not be used for:
75
+
76
+ - medical diagnosis
77
+ - treatment recommendation
78
+ - medication advice
79
+ - emergency triage
80
+ - clinical decision-making
81
+ - replacing professional medical review
82
+ - making decisions about real patients
83
+
84
+ If someone has severe, worsening, or urgent symptoms, they should contact a qualified medical professional or emergency service.
85
+
86
+ ## Research Question
87
+
88
+ Can text embeddings classify short symptom descriptions into broad health-information categories for routing users toward relevant public health resources?
89
+
90
+ ## Training Data
91
+
92
+ The classifiers were trained on a custom English symptom routing dataset created for this assignment.
93
+
94
+ Dataset file:
95
+
96
+ ```text
97
+ symptom_routing_expanded_dataset.csv
98
+ ```
99
+
100
+ Dataset size:
101
+
102
+ ```text
103
+ 90 examples
104
+ ```
105
+
106
+ Data split:
107
+
108
+ ```text
109
+ Training rows: 67
110
+ Test rows: 23
111
+ Test size: 0.25
112
+ Random seed: 712
113
+ Stratified by label
114
+ ```
115
+
116
+ Each row contains:
117
+
118
+ | Column | Description |
119
+ |---|---|
120
+ | `text` | A short English symptom description |
121
+ | `label` | A broad public health information category |
122
+
123
+ The dataset contains six balanced categories:
124
+
125
+ | Label | Description |
126
+ |---|---|
127
+ | `respiratory` | cough, sore throat, breathing problems |
128
+ | `gastrointestinal` | stomach pain, nausea, diarrhea |
129
+ | `skin` | rash, itching, swelling |
130
+ | `neurological` | headache, dizziness, numbness |
131
+ | `musculoskeletal` | back pain, joint pain, muscle pain |
132
+ | `mental_health_sleep` | anxiety, insomnia, low mood, sleep problems |
133
+
134
+ Hugging Face Dataset:
135
+
136
+ ```text
137
+ TODO: add your dataset link
138
+ ```
139
+
140
+ ## Method
141
+
142
+ The project uses a frozen embedding model to convert symptom descriptions into vector representations. Downstream classifiers were then trained on these embedding vectors.
143
+
144
+ Pipeline:
145
+
146
+ ```text
147
+ symptom text -> embedding model -> embedding vector -> classifier -> predicted category
148
+ ```
149
+
150
+ Embedding model:
151
+
152
+ ```text
153
+ nicher92/saga-embed_v1
154
+ ```
155
+
156
+ Embedding usage:
157
+
158
+ ```text
159
+ Frozen text encoder; only downstream classifiers were trained.
160
+ ```
161
+
162
+ Compared classifiers:
163
+
164
+ | Classifier | Description |
165
+ |---|---|
166
+ | Logistic Regression | Regularized linear classifier |
167
+ | Linear SVM | Linear support vector classifier |
168
+ | KNN cosine | k-nearest neighbors using cosine distance |
169
+ | Random Forest | Ensemble tree-based classifier |
170
+
171
+ ## Model Files
172
+
173
+ This repository contains:
174
+
175
+ | File | Description |
176
+ |---|---|
177
+ | `model_phase2.joblib` | Best deployed classifier, Logistic Regression |
178
+ | `all_classifiers_phase2.joblib` | All trained classifiers from the comparison experiment |
179
+ | `metrics.json` | Evaluation metrics for all classifiers |
180
+ | `predictions_phase2.csv` | Test set predictions from the selected model |
181
+ | `README.md` | Model card |
182
+
183
+ ## Evaluation
184
+
185
+ The classifiers were evaluated on the held-out test set.
186
+
187
+ | Classifier | Accuracy | Macro F1 | Weighted F1 |
188
+ |---|---:|---:|---:|
189
+ | Logistic Regression | 0.957 | 0.952 | 0.957 |
190
+ | Linear SVM | 0.957 | 0.952 | 0.957 |
191
+ | KNN cosine | 0.783 | 0.763 | 0.764 |
192
+ | Random Forest | 0.913 | 0.903 | 0.909 |
193
+
194
+ Logistic Regression and Linear SVM achieved the same top score. Logistic Regression was selected for deployment because it supports probability scores through `predict_proba`, which makes the demo output more informative.
195
+
196
+ Macro F1 is important because it measures whether the classifier performs consistently across all categories rather than only performing well on the most common category.
197
+
198
+ Detailed results are available in:
199
+
200
+ ```text
201
+ metrics.json
202
+ predictions_phase2.csv
203
+ ```
204
+
205
+ ## Example Predictions
206
+
207
+ Example 1:
208
+
209
+ ```text
210
+ Input: I have a fever, dry cough, and sore throat.
211
+ Predicted category: respiratory
212
+ ```
213
+
214
+ Example 2:
215
+
216
+ ```text
217
+ Input: My stomach hurts after eating and I feel nauseous.
218
+ Predicted category: gastrointestinal
219
+ ```
220
+
221
+ Example 3:
222
+
223
+ ```text
224
+ Input: I cannot sleep and I feel anxious most nights.
225
+ Predicted category: mental_health_sleep
226
+ ```
227
+
228
+ ## Limitations
229
+
230
+ This model was trained on a small educational dataset with 90 manually created examples. It may not generalize well to real-world symptom descriptions, different writing styles, misspellings, slang, or complex multi-symptom cases.
231
+
232
+ Some symptom descriptions can reasonably belong to more than one category. For example, a sentence mentioning both dizziness and sleep problems may be difficult to classify because it contains signals for both `neurological` and `mental_health_sleep`.
233
+
234
+ The model should only be interpreted as a broad routing tool for information retrieval experiments. It should not be interpreted as a clinical or diagnostic system.
235
+
236
+ ## Demo
237
+
238
+ A working Hugging Face Space demo is available here:
239
+
240
+ ```text
241
+ https://huggingface.co/spaces/charlie0831/symptom-routing-embedding-demo
242
+ ```
243
+
244
+ The demo lets users enter a short symptom description and returns the predicted routing category, a retrieval focus, and category probability scores.
245
+
246
+ ## Repository Links
247
+
248
+ | Resource | Link |
249
+ |---|---|
250
+ | GitHub Repository | https://github.com/aa9911220/english-symptom-routing-embeddings/tree/main |
251
+ | Hugging Face Dataset | https://huggingface.co/datasets/charlie0831/english-symptom-routing |
252
+ | Hugging Face Demo Space | https://huggingface.co/spaces/charlie0831/symptom-routing-embedding-demo |
253
+
254
+ ## AI Tool Use
255
+
256
+ AI coding tools were used to support coding, documentation, dataset formatting, training script development, model card writing, and report drafting. The outputs were manually checked and edited, especially the medical safety statements, label definitions, evaluation results, and limitations.
257
+
258
+ Using AI tools helped speed up implementation, but the project still required manual understanding of the data, embedding pipeline, classifier comparison, and evaluation results.
259
+
260
+ ## License
261
+
262
+ This model is released under the MIT License.