|
--- |
|
license: unknown |
|
datasets: |
|
- The-Adnan-Syed/Reddit-Stress-Classification |
|
pipeline_tag: text-classification |
|
--- |
|
## How to Use |
|
|
|
Here is an example of how to use this model to get predictions and convert them back to labels: |
|
|
|
```python |
|
import tensorflow as tf |
|
from transformers import TFAutoModelForSequenceClassification, AutoTokenizer |
|
import joblib |
|
|
|
# Load the model and tokenizer |
|
model = TFAutoModelForSequenceClassification.from_pretrained("NeuEraAI/Stress_Classifier_BERT") |
|
tokenizer = AutoTokenizer.from_pretrained("NeuEraAI/Stress_Classifier_BERT") |
|
|
|
# Load your label encoder |
|
label_encoder = joblib.load("label_encoder.joblib") |
|
|
|
def decode_predictions(predictions): |
|
# Extract predicted indices (assuming predictions is a list of dicts with 'label' keys) |
|
predicted_indices = [int(pred['label'].split('_')[-1]) for pred in predictions] |
|
# Decode the indices to original labels |
|
decoded_labels = label_encoder.inverse_transform(predicted_indices) |
|
return decoded_labels |
|
|
|
# Example usage |
|
text = "Your example input text here." |
|
decode_predictions(model.predict(text)) |