Giter Site home page Giter Site logo

sms-spam-detection's Introduction

What's SMS Spam Detection

It is the final project for the course "Data Science. NLP". The main goal of the project was to build a detection system for a Ukrainian user. Presentation from the project defense can be accessed here and downloaded from here.

Table of Contens

Data Collection

The data was collected in multiple ways and labeled manually since there is no open dataset with labeled SMS messages from Ukrainian users. Here are the results:

  • 269 responses for Google Form with ~62% spam rate
  • ~5800 self-annotated SMS messages from multiple devices with ~18% spam rate

So, here is basic statistics about the final data set:

  • ~6100 SMS messages
  • ~20% spam rate (imbalancement)
  • Two classes (spam and ham)
  • Multiple languages - Ukrainian, Russian, translit (Cyrillic letters are encoded with Latin ones), English

Machine Learning Pipeline

ML Pipeline and Transformers were built on top of scikit's Pipeline/TransformerMixin classes. Transformers and Pipeline can be accessed here and here respectively. Pipeline consists of several steps:

  • Data loading and preparation
    • Text cleaning
    • Tokenization
  • Feature building (will be discussed in the next section)
  • Stratified CV splitting
  • Grid search with 5-fold CV

After determining the best model and parameters, it is fitted to a whole data set and dumped altogether with detailed metadata (performance on folds) here.

Model Description

Estimator

Logistic regression with L2 penalty was selected as the best performing model.

Features

Here is the final set of features (please see here):

  • TF-IDF character 4-grams with top 4000 features
  • Pattern based features:
    • dot included?
    • uppercased/lowercased word? (+ratios)
    • bunch of RegExes (phone number, custom spam words, currency symbols, dates, etc.)
    • emoji included?
  • Length based features:
    • No. of words
    • No. of chars
    • No. of N-grams

Evaluation Metrics

Averaged across folds metrics and confusion matrix:

  • ROC-AUC: 99.5%

  • Accuracy: 98.4%

  • Precision: 96.4%

  • F1: 96.03%

  • Recall: 95.6%

  • Confusion matrix:

    Ham Spam
    Pred Ham 968.8 10.6
    Pred Spam 8.6 232.6

Getting Started

  1. Clone from the git repository:

     $ git clone https://github.com/KarimLulu/sms-spam-detection.git
    
  2. Change directory to sms-spam-detection and start up the application:

     $ cd sms-spam-detection
     $ docker-compose up
    
  3. Go to http://localhost:8000 and submit text messages to test the system

  4. Enjoy!

License

SMS Spam Detector is released under the MIT License.

sms-spam-detection's People

Contributors

karimlulu avatar dependabot[bot] avatar

Watchers

James Cloos avatar

Forkers

chanduindela123

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.