DineshKumar1329 commited on
Commit
eef508e
1 Parent(s): 7cb4396

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +32 -0
README.md CHANGED
@@ -17,4 +17,36 @@ The sentiment analysis model is trained using a Support Vector Machine (SVM) cla
17
 
18
 
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
 
17
 
18
 
19
 
20
+ # Usage :
21
+
22
+ from huggingface_hub import hf_hub_download
23
+ import joblib
24
+ from sklearn.preprocessing import LabelEncoder
25
+
26
+ model = joblib.load(
27
+ hf_hub_download("DineshKumar1329/Sentiment_Analysis", "sklearn_model.joblib")
28
+ )
29
+
30
+ tfidf_vectorizer = joblib.load('/content/vectorizer_model.joblib') # Replace with your path
31
+
32
+ def clean_text(text):
33
+ return text.lower()
34
+
35
+ def predict_sentiment(user_input):
36
+ """Predicts sentiment for a given user input."""
37
+ cleaned_text = clean_text(user_input)
38
+ input_matrix = tfidf_vectorizer.transform([cleaned_text])
39
+ prediction = model.predict(input_matrix)[0]
40
+
41
+ if isinstance(model.classes_, LabelEncoder):
42
+ prediction = model.classes_.inverse_transform([prediction])[0]
43
+
44
+ return prediction
45
+
46
+ user_input = input("Enter a sentence: ")
47
+
48
+ predicted_sentiment = predict_sentiment(user_input)
49
+
50
+ print(f"Predicted Sentiment: {predicted_sentiment}")
51
+
52