Code Monkey home page Code Monkey logo

spam-classification-with-count-vectorizer-and-tf-idf-using-multinomial-naive-bayes's Introduction

Spam Classification with Count Vectorizer and TF-IDF using Multinomial Naive Bayes

This repository contains a Python implementation of spam classification using the Count Vectorizer, TF-IDF, and Multinomial Naive Bayes approach. The goal of the project is to classify given messages as either spam or ham (non-spam) using machine learning techniques.

Data

The data used in this project consists of a collection of SMS messages labeled as either spam or ham. The dataset is publicly available and can be found at Link to dataset.

Preprocessing

Before applying the machine learning algorithm, the data was preprocessed to clean and prepare it for modeling. This included removing punctuation, lowercasing all words, and removing stop words.

Count Vectorizer and TF-IDF

The Count Vectorizer and TF-IDF approaches involve converting the messages into a matrix of token counts or TF-IDF values, respectively, where each column represents a unique word in the vocabulary and each row represents a message. The entries in the matrix are the count or TF-IDF value of each word in the corresponding message.

TF-IDF stands for Term Frequency-Inverse Document Frequency and is a weighting scheme that assigns higher weights to words that are more unique to a given document, and lower weights to words that are more common across all documents.

Multinomial Naive Bayes

The Multinomial Naive Bayes classifier is a probabilistic model that makes predictions based on the probability of each word in a message belonging to the spam or ham class. It is called "naive" because it assumes that the presence of a word in a message is independent of the presence of other words in the same message.

Modeling and Evaluation

The Count Vectorizer and TF-IDF approaches were used to transform the preprocessed data into feature matrices, which were then used to train and evaluate the Multinomial Naive Bayes model. The model was evaluated using common metrics such as precision, recall, and f1-score. Conclusion

The results of the analysis show that the combination of Count Vectorizer/TF-IDF and Multinomial Naive Bayes is an effective approach for classifying spam and ham messages. The model achieved good performance on the test set, with high precision and recall scores.

Packages:

  • numpy
  • pandas
  • matplotlib
  • seaborn
  • nltk
  • sklearn

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.