GithubHelp home page GithubHelp logo

kennethkaane / email_spam_filter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from stevenavery/email_spam_filter

0.0 1.0 0.0 20.49 MB

Final project for Artificial Intelligence class (group #3)

Python 100.00%

email_spam_filter's Introduction

Email_Spam_Filter

  • trainBayes.py: is used to train the spam filter, by using Bayes algorithm, which is done in the following steps:

    1. load the spam labels to know if each training email is ham or spam
    2. count occurrences of spam, and ham in the training set
    3. build a vocabulary of all words in the emails, and their frequencies
    4. take the n most frequent words
    5. determine the probability a word is in spam and ham
      • for example: "deal" might occur in 63 of the 100 spam emails, giving it a probability of 0.63
    6. clean the resulting probabilities of 0.0s and 1.0s, because they will cause a zero-frequency problem later on
    7. verify the results make sense (for example. no probability should be less than zero)
    8. save the results as our spam filter
  • spamFilter.py: determines if the given email is spam or not, by using the Bayes filter from trainBayes.py, which is done in the following steps:

    1. load the Bayes filter
    2. get the vocabulary of the current email
    3. convert that into an attribute list in the Bayes vocabulary
    4. calculate P(Email|Spam), and P(Email|Ham)
    5. use Baye's theorem to find p(Spam|Email)
  • testFilter.py: runs the spamFilter an given number of times to determine its accuracy.

    • currently this is at 88%

Demo

# train the Bayes filter
python2.7 trainBayes.py 50 100

# check if a given email is spam
python2.7 spamFilter.py build/spam_filter_results50.npz data/training/TRAIN_04232.eml

# determine the accuracy of the filter
python2.7 testFilter.py 50 100

email_spam_filter's People

Contributors

stevenavery avatar khirthana avatar

Watchers

James Cloos 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.