Git Product home page Git Product logo

mail_classification's Introduction

Spam Classification using Logistic Regression

This is a Python code for a spam classification system that can predict whether an email is spam or not using Logistic Regression.

Dependencies The following dependencies are required to run the code:

numpy pandas scikit-learn

Data Collection & Pre-Processing

The data was gotten from https://github.com/akashdeep364/Spam-Mail-Prediction/blob/main/mail_data.csv. The code starts by loading the email data from a csv file into a pandas dataframe. It then prints out some information about the data, including the number of rows and columns, and any null values.

Next, the code replaces any null values with an empty string, and then performs label encoding to label spam emails as 0 and ham emails as 1.

Finally, the code splits the data into training and test sets, with a test size of 20%.

Feature Extraction

The code then transforms the text data to feature vectors that can be used as input to the Logistic Regression model using the TfidfVectorizer function from scikit-learn.

Training the Model

The code trains a Logistic Regression model with the training data, and then evaluates the model's accuracy on both the training and test data.

Model Evaluation

The model performed very well with an accuracy of 0.967 but it seems to overfits.

Building a Predictive System

Finally, the code includes a sample input email to demonstrate how the model can be used to predict whether an email is spam or not.

To use this code, you can replace the input email with your own text and run the code to see whether it is classified as spam or ham.

mail_classification's People

Contributors

dominion-john1 avatar

Watchers

 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.