File size: 10,132 Bytes
57b018a
568d35d
 
 
 
 
 
 
 
 
 
 
 
57b018a
 
 
 
568d35d
57b018a
 
 
 
 
 
 
568d35d
57b018a
 
 
568d35d
 
 
 
 
57b018a
 
 
568d35d
 
57b018a
 
 
 
568d35d
 
57b018a
568d35d
 
 
57b018a
568d35d
 
 
 
57b018a
 
 
568d35d
57b018a
568d35d
 
 
 
57b018a
 
 
568d35d
57b018a
568d35d
 
 
 
 
57b018a
 
 
568d35d
57b018a
568d35d
 
 
 
 
57b018a
568d35d
57b018a
568d35d
 
 
 
 
57b018a
568d35d
57b018a
568d35d
 
 
 
 
57b018a
568d35d
57b018a
568d35d
57b018a
568d35d
 
 
 
 
57b018a
568d35d
57b018a
568d35d
 
 
57b018a
568d35d
 
 
 
57b018a
568d35d
57b018a
568d35d
 
 
 
 
 
 
 
 
 
57b018a
568d35d
57b018a
568d35d
 
 
 
57b018a
568d35d
57b018a
 
568d35d
 
 
 
 
 
 
 
57b018a
568d35d
57b018a
568d35d
 
 
 
 
 
 
 
 
 
 
 
 
 
57b018a
 
 
 
 
 
568d35d
 
 
 
57b018a
 
568d35d
 
 
 
 
57b018a
 
568d35d
 
 
 
 
57b018a
 
 
568d35d
 
 
 
 
 
 
 
 
 
 
 
 
 
57b018a
 
568d35d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57b018a
 
 
 
 
568d35d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57b018a
 
 
 
 
568d35d
 
 
 
57b018a
 
 
568d35d
 
 
 
 
 
 
57b018a
 
 
568d35d
 
 
 
 
 
 
57b018a
 
 
568d35d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
57b018a
 
568d35d
57b018a
 
568d35d
 
 
 
 
 
 
 
 
 
 
57b018a
 
568d35d
 
 
 
 
 
 
 
 
 
 
 
 
 
57b018a
 
 
 
568d35d
 
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
---
tags:
- pet_Health
- veterinary
license: mit
language:
- en
metrics:
- accuracy
- f1
base_model:
- havocy28/VetBERTDx
pipeline_tag: text-classification
---

# Model Card for Model ID

This model classifies pet health symptoms from text descriptions into predefined health conditions, fine-tuned on VetBERTDx.



## Model Details

### Model Description

Fine-tuned VetBERTDx for sequence classification.

This is the model card of a 🤗 transformers model that has been pushed on the Hub. This model card has been automatically generated.

- **Developed by:** Fatemeh Dastak
- **Model type:** Fine-tuned VetBERTDx for sequence classification
- **Language(s) (NLP):** English
- **License:** MIT
- **Finetuned from model [optional]:** havocy28/VetBERTDx

### Model Sources [optional]

- **Repository:** https://huggingface.co/fdastak/model_classification
- **Dataset:** [Pet Health Symptoms Dataset](https://www.kaggle.com/datasets/yyzz1010/pet-health-symptoms-dataset)

## Uses

### Direct Use
```python
from transformers import AutoModelForSequenceClassification, AutoTokenizer

model = AutoModelForSequenceClassification.from_pretrained("fdastak/model_classification")
tokenizer = AutoTokenizer.from_pretrained("fdastak/model_classification")
```

### Out-of-Scope Use
- Not for actual medical diagnosis
- Not a replacement for veterinary consultation
- Not suitable for emergency medical decisions

### Downstream Use [optional]

This model can be integrated into:

- Veterinary triage systems
- Pet health monitoring applications
- Symptom screening tools
- Educational veterinary platforms

### Out-of-Scope Use

This model should NOT be used for:

- Direct medical diagnosis
- Emergency medical decisions
- Replacement of veterinary consultation
- Legal or insurance decisions
- Automated treatment recommendation

## Bias, Risks, and Limitations

## Technical Limitations

- Limited to 512 token input length
- CPU-only training constraints
- Early stopping at 301 steps
- Batch size limitations (8 training, 20 evaluation)
- Specific to owner-reported symptoms

## Data Biases

- Training data from owner observations only
- English language only
- Limited to common pet conditions
- Potential reporting biases in symptoms
- Class imbalance considerations

### Risk

-Misinterpretation of medical conditions
-Over-reliance on automated classification
-Delayed professional consultation
-False confidence in predictions
-Language and cultural biases

### Recommendations

## Best Practices

- Always verify predictions with professionals
- Use as screening tool only
- Monitor prediction confidence scores
- Implement user warnings
- Regular model evaluation

## How to Get Started with the Model

# Load required libraries
from transformers import AutoModelForSequenceClassification, AutoTokenizer
import torch.nn.functional as F

# Load model and tokenizer
repo_id = "fdastak/model_classification"
model = AutoModelForSequenceClassification.from_pretrained(repo_id)
tokenizer = AutoTokenizer.from_pretrained(repo_id)

# Example usage

def classify_symptoms(text: str):
    # Preprocess and tokenize
    inputs = tokenizer(
        text,
        truncation=True,
        padding=True,
        max_length=512,
        return_tensors="pt"
    )
    

## Training Details

### Training Data
- Source: Pet Health Symptoms Dataset (Kaggle)
- Split: 80% training, 20% validation
- Preprocessing: Text lowercasing, label encoding

### Training Procedure

#### Training Hyperparameters
- Epochs: 5
- Train batch size: 8
- Eval batch size: 20
- Learning rate: 2e-5
- Scheduler: Linear with warmup
- Warmup ratio: 0.1
- Early stopping: At step 301
- Maximum sequence length: 512

### Evaluation

#### Metrics
- Accuracy
- Precision (weighted)
- Recall (weighted)
- F1-score (weighted)
- 
#### Speeds, Sizes, Times
- **Training Duration**: ~1 hour
- **Steps**: 301 (with early stopping)
- **Checkpoint Frequency**: Every 50 steps
- **Batch Processing**:
  - Training: 8 samples/batch
  - Evaluation: 20 samples/batch
- **Model Storage**: Local checkpoints in './model_classification'

## Evaluation

### Testing Data, Factors & Metrics

#### Testing Data
- **Source**: [Pet Health Symptoms Dataset](https://www.kaggle.com/datasets/yyzz1010/pet-health-symptoms-dataset)
- **Split**: 20% of data (validation set)
- **Format**: Text descriptions with condition labels
- **Preprocessing**: Text lowercasing, label encoding

#### Factors
- **Record Types**: Owner observations
- **Text Length**: Maximum 512 tokens
- **Language**: English
- **Conditions**: Multiple pet health conditions
- **Data Balance**: Stratified split for class distribution

#### Metrics
- **Accuracy**: Overall classification accuracy
- **Precision (weighted)**: Measure of exactness
- **Recall (weighted)**: Measure of completeness
- **F1-score (weighted)**: Harmonic mean of precision and recall
- **Confusion Matrix**: Class-wise performance visualization

### Results

#### Performance Summary
- Overall Accuracy: 89%
- Average F1-Score: 0.89
- Class-wise Performance:
  - Class 0: Highest precision (0.97) and F1-score (0.95)
  - Class 1: Perfect recall (1.00)
  - Class 2: Balanced performance (0.93 across metrics)
  - Classes 3 & 4: Similar performance (~0.82-0.83 F1-score)

#### Key Metrics
- **Precision (weighted)**: 0.89
- **Recall (weighted)**: 0.89
- **F1-score (weighted)**: 0.89
- **Support**: 200 validation samples (40 per class)

#### Summary
- Model shows balanced performance across classes
- Early stopping at step 301 prevents overfitting
- Validation performed every 50 steps
- Best model selected based on eval_loss
- Confusion matrix shows class-wise performance


## Model Examination 

### Validation Results
The model's performance was examined using several evaluation methods:

1. **Classification Metrics**
- Computed using sklearn's classification_report
- Includes precision, recall, and F1-score
- Evaluated on validation dataset
- Weighted averages to handle class imbalance

2. **Confusion Matrix Analysis**
```python
# Visualization code
from sklearn.metrics import confusion_matrix, ConfusionMatrixDisplay
import matplotlib.pyplot as plt

model.eval()
with torch.no_grad():
    # Prediction collection
    true_labels = []
    pred_labels = []
    pred_scores = []
    # ...evaluation logic
```

3. **Prediction Confidence**
- Softmax probabilities for class predictions
- Confidence scores tracked for each prediction
- Score distribution analysis for reliability

4. **Early Stopping Analysis**
- Training stopped at step 301
- Monitored eval_loss for best model selection
- Used custom StopAtStepCallback for controlled training

### Model Interpretability
- Base model: VetBERTDx (domain-specific veterinary BERT)
- Fine-tuned for pet symptom classification
- Uses attention mechanisms for text understanding
- Maximum sequence length: 512 tokens

### Limitations
- CPU-only training might affect model capacity
- Limited to predefined condition categories
- Performance varies by symptom complexity
- Early stopping may affect final performance

## Environmental Impact

Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).

- **Hardware Type:** CPU (Personal Computer)
- **Hours used:** ~2 hours (301 steps with early stopping)
- **Cloud Provider:** None (Local training)
- **Compute Region:** USA (Colorado)
- **Power Mix:** Rocky Mountain Power Grid
- **Training Configuration:**
  - 301 steps with early stopping
  - CPU-based training
  - Batch size: 8 samples
  - Epochs: 5
  - Local machine execution

Environmental considerations:
- Used CPU instead of GPU for lower power consumption
- Implemented early stopping at step 301
- Leveraged pre-trained model (VetBERTDx)
- Local training to minimize data center impact
- Efficient batch size selection

## Technical Specifications [optional]

### Model Architecture and Objective

- Base model: VetBERTDx
- Task: Sequence classification
- Input: Text descriptions of pet symptoms
- Output: Classification among health conditions

### Compute Infrastructure

- Framework: PyTorch
- Training device: GPU
- Python dependencies:
  - transformers
  - torch
  - numpy
  - scikit-learn

#### Hardware

The model was trained using:
- Training Device: CPU
- Batch Configuration:
  - Training batch size: 8
  - Evaluation batch size: 20
- Training Steps: Limited to 301 (early stopping)
- Local Storage: Required for model checkpoints in './model_classification'

#### Software

Training environment specifications:
- Python 3.11
- Core Libraries:
  ```python
  torch>=2.0.0
  transformers>=4.30.0
  numpy>=1.24.0
  pandas>=1.5.0
  scikit-learn>=1.0.0
  sentence-transformers>=2.2.0
  ```
- Training Components:
  - Framework: 🤗 Transformers
  - Base Model: havocy28/VetBERTDx
  - Tokenizer: AutoTokenizer
  - Model Class: AutoModelForSequenceClassification
  - Training API: Transformers Trainer with custom callbacks
- Logging: Python's built-in logging module
  
## Citation [optional]

If you use this model in your research, please cite it using the following:

**BibTeX:**
```bibtex
@misc{dastak2024pethealthclassifier,
    title={Pet Health Symptoms Classification Model},
    author={Dastak, Fatemeh},
    year={2024},
    publisher={Hugging Face},
    howpublished={\url{https://huggingface.co/fdastak/model_classification}},
    note={Based on VetBERTDx by Havocy28},
    keywords={veterinary-nlp, text-classification, pet-health}
}
```

**APA:**
```
Dastak, F. (2025). Pet Health Symptoms Classification Model [Machine learning model]. Hugging Face Model Hub. https://huggingface.co/fdastak/model_classification
```

Please also cite the base model:
```
@misc{havocy282023vetbertdx,
    title={VetBERTDx: A Domain-Specific Language Model for Veterinary Medicine},
    author={Havocy28},
    year={2023},
    publisher={Hugging Face},
    howpublished={\url{https://huggingface.co/havocy28/VetBERTDx}}
}
```


## Model Card Contact

Author: Fatemeh Dastak
Repository: https://huggingface.co/fdastak/model_classification