Code Monkey home page Code Monkey logo

nlp-projects's Introduction

Sentiment Analysis with Naive Bayes Classifier

Overview

This repository contains a machine learning model for sentiment analysis using a Naive Bayes classifier. The model is trained on a dataset of restaurant reviews and can predict whether a given review is positive or negative.

Dataset

The dataset used for training and testing is "Restaurant_Reviews.tsv". It includes reviews along with their corresponding labels (1 for positive, 0 for negative).

Data Preprocessing

The reviews undergo a series of preprocessing steps, including:

  • Removal of special characters
  • Conversion to lowercase
  • Tokenization
  • Removal of stopwords
  • Stemming

The preprocessed reviews are then transformed into a Bag of Words model using the CountVectorizer from scikit-learn.

Model Training

The Naive Bayes classifier (MultinomialNB) is used for training the model. The dataset is split into training and testing sets, and the model is evaluated based on accuracy, precision, recall, and a confusion matrix.

Hyperparameter Tuning

The alpha hyperparameter of the Naive Bayes classifier is tuned for better performance.

Predictions

A function predict_sentiment is provided to predict the sentiment of new reviews. Examples are included in the code for demonstration.

Results

The best accuracy achieved during hyperparameter tuning is [insert accuracy]% with an alpha value of [insert alpha value].

nlp-projects's People

Contributors

lp-the-coder avatar

Watchers

Kostas Georgiou avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.