File size: 1,547 Bytes
19385e3 |
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 |
---
license: apache-2.0
language:
- en
pipeline_tag: text-classification
tags:
- Sentiment Analysis
- Language Models
---
## Model Architecture
- **Embedding Layer**: Converts input text into dense vectors.
- **CNN Layers**: Extracts features from text sequences.
- **RNN, LSTM, and GRU Layers**: Capture temporal dependencies in text.
- **Dense Layers**: Classify text into sentiment categories.
## Usage
You can use this model for sentiment analysis on text data. Here's a sample code to load and use the model:
```python
from huggingface_hub import from_pretrained_keras
import re
import numpy as np
from tensorflow.keras.preprocessing.sequence import pad_sequences
# Load model
model = from_pretrained_keras("Ravinthiran/DistilSenti-Net42M")
# Example prediction function
def predict_sentiment(text, model, tokenizer, label_encoder):
text = text.lower()
text = re.sub(r'[^\w\s]', '', text)
sequence = tokenizer.texts_to_sequences([text])
padded_sequence = pad_sequences(sequence, maxlen=100)
pred = model.predict(padded_sequence)
sentiment = label_encoder.inverse_transform(pred.argmax(axis=1))
sentiment_score = pred[0]
return sentiment[0], sentiment_score
# Example usage
new_text = "I recently started a new fitness program at a local wellness center, and it has been an incredibly positive experience."
predicted_sentiment, sentiment_score = predict_sentiment(new_text, model, tokenizer, label_encoder)
print(f"Predicted Sentiment: {predicted_sentiment}")
print(f"Sentiment Scores: {sentiment_score}") |