Ravinthiran commited on
Commit
19385e3
1 Parent(s): 9f22c2b

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +44 -0
README.md ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ language:
4
+ - en
5
+ pipeline_tag: text-classification
6
+ tags:
7
+ - Sentiment Analysis
8
+ - Language Models
9
+ ---
10
+ ## Model Architecture
11
+ - **Embedding Layer**: Converts input text into dense vectors.
12
+ - **CNN Layers**: Extracts features from text sequences.
13
+ - **RNN, LSTM, and GRU Layers**: Capture temporal dependencies in text.
14
+ - **Dense Layers**: Classify text into sentiment categories.
15
+
16
+ ## Usage
17
+ You can use this model for sentiment analysis on text data. Here's a sample code to load and use the model:
18
+
19
+ ```python
20
+ from huggingface_hub import from_pretrained_keras
21
+ import re
22
+ import numpy as np
23
+ from tensorflow.keras.preprocessing.sequence import pad_sequences
24
+
25
+ # Load model
26
+ model = from_pretrained_keras("Ravinthiran/DistilSenti-Net42M")
27
+
28
+ # Example prediction function
29
+ def predict_sentiment(text, model, tokenizer, label_encoder):
30
+ text = text.lower()
31
+ text = re.sub(r'[^\w\s]', '', text)
32
+ sequence = tokenizer.texts_to_sequences([text])
33
+ padded_sequence = pad_sequences(sequence, maxlen=100)
34
+ pred = model.predict(padded_sequence)
35
+ sentiment = label_encoder.inverse_transform(pred.argmax(axis=1))
36
+ sentiment_score = pred[0]
37
+ return sentiment[0], sentiment_score
38
+
39
+ # Example usage
40
+ new_text = "I recently started a new fitness program at a local wellness center, and it has been an incredibly positive experience."
41
+ predicted_sentiment, sentiment_score = predict_sentiment(new_text, model, tokenizer, label_encoder)
42
+
43
+ print(f"Predicted Sentiment: {predicted_sentiment}")
44
+ print(f"Sentiment Scores: {sentiment_score}")