File size: 4,032 Bytes
1fb2cdc 4822bed 1fb2cdc 5bece2c 4822bed 5bece2c 4822bed 5bece2c 4822bed 5bece2c 4822bed 5bece2c 4822bed 5bece2c 4822bed 5bece2c 4822bed 5bece2c 4822bed 5bece2c 4822bed 5bece2c 4822bed 5bece2c 4822bed 5bece2c 4822bed 5bece2c 4822bed 5bece2c 4822bed 5bece2c 4822bed 5bece2c 4822bed 5bece2c 4822bed 5bece2c 4822bed 5bece2c 4822bed 5bece2c 4822bed 5bece2c 4822bed 5bece2c 4822bed 5bece2c 4822bed 5bece2c 4822bed 5bece2c 4822bed 5bece2c 4822bed 5bece2c 4822bed 5bece2c 4822bed 5bece2c 4822bed 5bece2c 4822bed 5bece2c |
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 |
---
license: mit
language:
- en
tags:
- intent-classification
- emotion-detection
- mental-health
- lstm
- sentence-transformers
- sklearn
pipeline_tag: text-classification
---
# π§ MindPadi: Hybrid Classifier Suite
This repository contains auxiliary models for intent and emotion classification used in the **MindPadi** mental health assistant. These models include rule-based, ML-based, and deep learning classifiers trained to detect emotional states, user intent, and conversational cues.
## π¦ Files
| File | Description |
|-------------------------------|----------------------------------------------------------|
| `intent_clf.joblib` | scikit-learn pipeline for intent classification (TF-IDF) |
| `intent_sentence_classifier.pkl` | Sentence-level intent classifier (pickle) |
| `lstm_tfidf.h5` | LSTM model trained on TF-IDF vectors |
| `lstm_bert.h5` | LSTM model trained on BERT embeddings |
| `tfidf_vectorizer.pkl` | TF-IDF vectorizer for preprocessing text |
| `tfidf_embeddings.pkl` | Cached TF-IDF embeddings for faster lookup |
| `bert_embeddings.npy` | Precomputed BERT embeddings used in training/testing |
| `lstm_accuracy_tfidf.png` | Evaluation plot (TF-IDF model) |
| `lstm_accuracy_bert.png` | Evaluation plot (BERT model) |
| `model_configs/` | JSON configs for training and architecture |
## π― Tasks Supported
- **Intent Classification**: Understand what the user is trying to communicate.
- **Emotion Detection**: Identify the emotional tone (e.g., sad, angry).
- **Embedding Generation**: Support vector similarity or hybrid routing.
## π¬ Model Overview
| Model Type | Framework | Notes |
|----------------|-------------|----------------------------------------|
| LSTM + TF-IDF | Keras | Traditional pipeline with good generalization |
| LSTM + BERT | Keras | Handles contextual sentence meanings |
| TF-IDF + SVM | scikit-learn | Lightweight and interpretable intent routing |
| Sentence Classifier | scikit-learn | Quick rule or decision-tree model for sentence-level labels |
---
## π οΈ Usage Example
### Intent Prediction (Joblib)
```python
from joblib import load
clf = load("intent_clf.joblib")
text = ["I feel really anxious today"]
pred = clf.predict(text)
print("Intent:", pred[0])
````
### LSTM Emotion Prediction
```python
from tensorflow.keras.models import load_model
import numpy as np
model = load_model("lstm_bert.h5")
embeddings = np.load("bert_embeddings.npy") # assuming aligned with test set
output = model.predict(embeddings)
print("Predicted emotion class:", output.argmax(axis=1))
```
## π Evaluation
| Model | Accuracy | Dataset Size | Notes |
| ------------------- | -------- | ------------ | -------------------------------- |
| `lstm_bert.h5` | \~88% | 10,000+ | Best for nuanced emotional input |
| `lstm_tfidf.h5` | \~83% | 10,000+ | Lighter, faster |
| `intent_clf.joblib` | \~90% | 8,000+ | Works well with short queries |
Evaluation visualizations:
* 
* 
## β οΈ Limitations
* English only
* May misclassify ambiguous or sarcastic phrases
* LSTM models require matching vectorizer or embeddings
## π§© Integration
These models are invoked in:
* `app/chatbot/intent_classifier.py`
* `app/chatbot/emotion.py`
* `app/utils/embedding_search.py`
## π§ Intended Use
* Mental health journaling feedback
* Chatbot-based emotion understanding
* Offline fallback for heavy transformer models
## π License
MIT License β free for commercial and research use.
*Last updated: May 6, 2025* |