call_of_duty_reviews_50000.csv
: The dataset containing 50,000 reviews of the Call of Duty game.logistic_regression_model.pkl
: The trained Logistic Regression model.naive_bayes_model.pkl
: The trained Naive Bayes model.tfidf_vectorizer.pkl
: The trained TF-IDF vectorizer.Sklrean_sentiment_analysisis_using_Naive_byes_and_logistic_regression.ipynb
: Jupyter notebook for training and evaluating the sentiment analysis models.Text_analysis.ipynb
: Jupyter notebook for additional text analysis and visualization.
- Python 3.x
- Jupyter Notebook
- pandas
- numpy
- scikit-learn
- nltk
- matplotlib
- seaborn
- tqdm
- langdetect
- emoji
-
Clone the repository:
git clone <repository-url> cd cod_data
-
Install the required packages:
pip install -r requirements.txt
-
Download NLTK data:
import nltk nltk.download('stopwords') nltk.download('punkt') nltk.download('vader_lexicon')
-
Open the Jupyter notebooks:
jupyter notebook
-
Run the cells in Sklrean_sentiment_analysisis_using_Naive_byes_and_logistic_regression.ipynb to train and evaluate the sentiment analysis models.
-
Run the cells in Text_analysis.ipynb for additional text analysis and visualization.
# Load models and vectorizer
with open('naive_bayes_model.pkl', 'rb') as f:
loaded_nb_model = pickle.load(f)
with open('logistic_regression_model.pkl', 'rb') as f:
loaded_lr_model = pickle.load(f)
with open('tfidf_vectorizer.pkl', 'rb') as f:
loaded_vectorizer = pickle.load(f)
# Example usage of the loaded models
new_review = ["I used to love this game It's not very fantastic! don't ever try this game very bad"]
# Preprocess and transform the new review
new_review_tfidf = loaded_vectorizer.transform([preprocess_text(new_review[0])])
# Predict sentiment using Naive Bayes
predicted_sentiment_nb = loaded_nb_model.predict(new_review_tfidf)
print(f"Predicted Sentiment (Naive Bayes): {predicted_sentiment_nb[0]}")
# Predict sentiment using Logistic Regression
predicted_sentiment_lr = loaded_lr_model.predict(new_review_tfidf)
print(f"Predicted Sentiment (Logistic Regression): {predicted_sentiment_lr[0]}")