Update README.md
Browse files
README.md
CHANGED
|
@@ -22,31 +22,20 @@ import joblib
|
|
| 22 |
model = joblib.load(
|
| 23 |
hf_hub_download("DineshKumar1329/Sentiment_Analysis", "sklearn_model.joblib")
|
| 24 |
)
|
| 25 |
-
# only load pickle files from sources you trust
|
| 26 |
-
# read more about it here https://skops.readthedocs.io/en/stable/persistence.html
|
| 27 |
|
| 28 |
-
# Load the TF-IDF vectorizer used during training
|
| 29 |
tfidf_vectorizer = joblib.load('/content/vectorizer_model.joblib') # Replace with your actual filename
|
| 30 |
|
| 31 |
-
|
| 32 |
-
# Take user input
|
| 33 |
user_input = input("Enter a sentence: ")
|
| 34 |
|
| 35 |
-
# Clean the user input
|
| 36 |
cleaned_input = clean_text(user_input)
|
| 37 |
|
| 38 |
-
# Transform the cleaned text data using the TF-IDF vectorizer
|
| 39 |
input_matrix = tfidf_vectorizer.transform([cleaned_input])
|
| 40 |
|
| 41 |
-
# Make prediction
|
| 42 |
prediction = model.predict(input_matrix)[0]
|
| 43 |
|
| 44 |
-
# Display the prediction
|
| 45 |
print(f"Predicted Sentiment: {prediction}")
|
| 46 |
-
# Create a DataFrame with the results
|
| 47 |
df_result = pd.DataFrame({'User_Input': [user_input], 'Predicted_Sentiment': [prediction]})
|
| 48 |
|
| 49 |
-
# Save the DataFrame to an Excel file (append if the file already exists)
|
| 50 |
excel_filename = '/content/output_predictions.xlsx' # Replace with your desired filename
|
| 51 |
try:
|
| 52 |
# Load existing predictions from the Excel file
|
|
@@ -59,5 +48,4 @@ except FileNotFoundError:
|
|
| 59 |
# If the file doesn't exist, create a new DataFrame
|
| 60 |
df_combined = df_result
|
| 61 |
|
| 62 |
-
# Save the combined DataFrame to the Excel file
|
| 63 |
df_combined.to_excel(excel_filename, index=False)
|
|
|
|
| 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
|
|
|
|
| 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)
|