Giter Site home page Giter Site logo

spam-detector's Introduction

Email Logo.png

Spam Detector

COMP 6721 - Artificial Intelligence

Project Assignment 2 - Concordia University (Winter 2020)

Animated gif pacman game

I have developed a spam detector program in Python which classifies given emails as spam or ham using the Naive Bayes approach.

๐Ÿ’พ Project Files Description

This Project includes 3 executable files, 3 text files as well as 2 directories as follows:

Executable Files:

  • spam_detector.py - Includes all functions required for classification operations.
  • train.py - Uses the functions defined in the spam_detector.py file and generates the model.txt file after execution.
  • test.py - Uses the functions defined in the spam_detector.py file and, after execution, generates the result.txt as well as evaluation.txt files.

Output Files:

  • model.txt - Contains information about the vocabularies of the train set, such as the frequency and conditional probability of each word in Spam and Ham classes.
  • result.txt - Contains information about the classified emails of the test set.
  • evaluation.txt - Contains evaluation results table as well as Confusion Matrix of Spam and Ham classes.

Source Directories:

  • train directory - Includes all emails for the training phase of the program.
  • test directory - Includes all emails for the testing phase of the program.

-----------------------------------------------------

๐Ÿ“– Naive Bayes

In machine learning, naive Bayes classifiers are a family of simple "probabilistic classifiers" based on applying Bayes' theorem with strong (naive) independence assumptions between the features. Abstractly, naive Bayes is a conditional probability model: given a problem instance to be classified, represented by a vector Formula 1

representing some n features (independent variables), it assigns to this instance probabilities Formula 2

The problem with the above formulation is that if the number of features n is large or if a feature can take on a large number of values, then basing such a model on probability tables is infeasible. We therefore reformulate the model to make it more tractable. Using Bayes' theorem, the conditional probability can be decomposed as Formula 3

-----------------------------------------------------

๐Ÿ“‹ Execution Instruction

The order of execution of the program files is as follows:

1) spam_detector.py

First, the spam_detector.py file must be executed to define all the functions and variables required for classification operations.

2) train.py

Then, the train.py file must be executed, which leads to the production of the model.txt file. At the beginning of this file, the spam_detector has been imported so that the functions defined in it can be used.

3) test.py

Finally, the test.py file must be executed to create the result.txt and evaluation.txt files. Just like the train.py file, at the beginning of this file, the spam_detector has been imported so that the functions defined in it can be used.

-----------------------------------------------------

๐Ÿ“š References

-----------------------------------------------------

๐Ÿ“œ Credits

Mohammad Amin Shamshiri

GitHub Badge Twitter Badge LinkedIn Badge

spam-detector's People

Contributors

ciangallagher avatar ma-shamshiri 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.