Downloads · 30 days
20
19% of all-time downloads
keanteng/bert-sentiment-wqd7005
bert-sentiment-wqd7005 is a text classification model from keanteng. Use it when you need a label for a piece of text. It is set up for transformers. The card lists the license as agpl-3.0.
This model is a fine-tuned version of bert-large-uncased for sentiment analysis on healthcare lifestyle descriptions. The model classifies text descriptions of lifestyle and activity levels into three sentiment catego…
Downloads · 30 days
20
19% of all-time downloads
All-time downloads
105
Public
Parameters
335M
1.3 GB on disk
Likes
0
Public
Click a slice to open those files.
.safetensors1.3 GB · 100%
From the Hugging Face model README
This model is a fine-tuned version of bert-large-uncased for sentiment analysis on healthcare lifestyle descriptions. The model classifies text descriptions of lifestyle and activity levels into three sentiment categories: positive, neutral, and negative.
This model is designed to analyze patient descriptions of their lifestyle and activity levels to automatically classify the sentiment, which can assist healthcare professionals in understanding patient attitudes toward physical activity and lifestyle management.
patients_with_ratings.csv) with patient lifestyle descriptionsdescribe_lifestyle - patient descriptions of their lifestyleactivity_sentiment - sentiment labels (positive/neutral/negative)bert-large-uncasedThe model was trained using standard fine-tuning procedures:
The model was evaluated on the validation set with detailed classification reports. Performance metrics include:
Detailed precision, recall, and F1-score metrics are generated for all three sentiment classes (positive, neutral, negative).
from transformers import pipeline
# Create sentiment analysis pipeline
classifier = pipeline("text-classification",
model="keanteng/bert-sentiment-wqd7007")
# Analyze sentiment
result = classifier("I maintain a regular exercise routine and feel great")
print(result)
# Output: [{'label': 'LABEL_0', 'score': 0.9234}]
from transformers import BertTokenizer, BertForSequenceClassification
import torch
# Load the model and tokenizer
tokenizer = BertTokenizer.from_pretrained('google-bert/bert-large-uncased')
model = BertForSequenceClassification.from_pretrained('keanteng/bert-sentiment-wqd7007')
# Prepare input text
text = "I feel energetic and try to exercise every day"
inputs = tokenizer(text, return_tensors="pt", padding=True, truncation=True, max_length=128)
# Get predictions
with torch.no_grad():
outputs = model(**inputs)
predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)
predicted_class = torch.argmax(predictions, dim=-1)
# Map prediction to sentiment
sentiment_map = {0: 'positive', 1: 'neutral', 2: 'negative'}
predicted_sentiment = sentiment_map[predicted_class.item()]
confidence = predictions.max().item()
print(f"Predicted sentiment: {predicted_sentiment}")
print(f"Confidence: {confidence:.4f}")
# For multiple texts
texts = [
"I love staying active and exercising daily",
"My activity level is okay, nothing special",
"I struggle to find motivation for physical activities"
]
# Tokenize all texts
inputs = tokenizer(texts, return_tensors="pt", padding=True, truncation=True, max_length=128)
# Get predictions for all texts
with torch.no_grad():
outputs = model(**inputs)
predictions = torch.nn.functional.softmax(outputs.logits, dim=-1)
predicted_classes = torch.argmax(predictions, dim=-1)
# Process results
for i, text in enumerate(texts):
sentiment = sentiment_map[predicted_classes[i].item()]
confidence = predictions[i].max().item()
print(f"Text: {text}")
print(f"Sentiment: {sentiment} (confidence: {confidence:.4f})")
print()
The model includes training and validation loss curves with best epoch identification, saved as visualizations in the model repository.
This model is intended for research and healthcare support purposes. When used in healthcare settings:
All training was conducted with fixed random seeds (42) for reproducibility across PyTorch and NumPy operations.