Update README.md
Browse files
README.md
CHANGED
@@ -19,30 +19,5 @@ The sentiment analysis model is trained using a Support Vector Machine (SVM) cla
|
|
19 |
|
20 |
# Usage :
|
21 |
|
22 |
-
|
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 |
-
tfidf_vectorizer = joblib.load('/content/vectorizer_model.joblib') # Replace with your path
|
30 |
-
|
31 |
-
def clean_text(text):
|
32 |
-
return text.lower()
|
33 |
-
|
34 |
-
def predict_sentiment(user_input):
|
35 |
-
"""Predicts sentiment for a given user input."""
|
36 |
-
cleaned_text = clean_text(user_input)
|
37 |
-
input_matrix = tfidf_vectorizer.transform([cleaned_text])
|
38 |
-
prediction = model.predict(input_matrix)[0]
|
39 |
-
if isinstance(model.classes_, LabelEncoder):
|
40 |
-
prediction = model.classes_.inverse_transform([prediction])[0]
|
41 |
-
return prediction
|
42 |
-
|
43 |
-
user_input = input("Enter a sentence: ")
|
44 |
-
predicted_sentiment = predict_sentiment(user_input)
|
45 |
-
print(f"Predicted Sentiment: {predicted_sentiment}")
|
46 |
-
|
47 |
-
|
48 |
|
|
|
19 |
|
20 |
# Usage :
|
21 |
|
22 |
+

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|