Update README.md
Browse files
README.md
CHANGED
@@ -22,20 +22,13 @@ import joblib
|
|
22 |
model = joblib.load(
|
23 |
hf_hub_download("DineshKumar1329/Sentiment_Analysis", "sklearn_model.joblib")
|
24 |
)
|
25 |
-
|
26 |
tfidf_vectorizer = joblib.load('/content/vectorizer_model.joblib') # Replace with your actual filename
|
27 |
-
|
28 |
user_input = input("Enter a sentence: ")
|
29 |
-
|
30 |
cleaned_input = clean_text(user_input)
|
31 |
-
|
32 |
input_matrix = tfidf_vectorizer.transform([cleaned_input])
|
33 |
-
|
34 |
prediction = model.predict(input_matrix)[0]
|
35 |
-
|
36 |
print(f"Predicted Sentiment: {prediction}")
|
37 |
df_result = pd.DataFrame({'User_Input': [user_input], 'Predicted_Sentiment': [prediction]})
|
38 |
-
|
39 |
excel_filename = '/content/output_predictions.xlsx' # Replace with your desired filename
|
40 |
try:
|
41 |
# Load existing predictions from the Excel file
|
@@ -43,9 +36,7 @@ try:
|
|
43 |
|
44 |
# Append the new predictions to the existing DataFrame
|
45 |
df_combined = pd.concat([df_existing, df_result], ignore_index=True)
|
46 |
-
|
47 |
except FileNotFoundError:
|
48 |
# If the file doesn't exist, create a new DataFrame
|
49 |
df_combined = df_result
|
50 |
-
|
51 |
df_combined.to_excel(excel_filename, index=False)
|
|
|
22 |
model = joblib.load(
|
23 |
hf_hub_download("DineshKumar1329/Sentiment_Analysis", "sklearn_model.joblib")
|
24 |
)
|
|
|
25 |
tfidf_vectorizer = joblib.load('/content/vectorizer_model.joblib') # Replace with your actual filename
|
|
|
26 |
user_input = input("Enter a sentence: ")
|
|
|
27 |
cleaned_input = clean_text(user_input)
|
|
|
28 |
input_matrix = tfidf_vectorizer.transform([cleaned_input])
|
|
|
29 |
prediction = model.predict(input_matrix)[0]
|
|
|
30 |
print(f"Predicted Sentiment: {prediction}")
|
31 |
df_result = pd.DataFrame({'User_Input': [user_input], 'Predicted_Sentiment': [prediction]})
|
|
|
32 |
excel_filename = '/content/output_predictions.xlsx' # Replace with your desired filename
|
33 |
try:
|
34 |
# Load existing predictions from the Excel file
|
|
|
36 |
|
37 |
# Append the new predictions to the existing DataFrame
|
38 |
df_combined = pd.concat([df_existing, df_result], ignore_index=True)
|
|
|
39 |
except FileNotFoundError:
|
40 |
# If the file doesn't exist, create a new DataFrame
|
41 |
df_combined = df_result
|
|
|
42 |
df_combined.to_excel(excel_filename, index=False)
|