Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/wchunt/naive-bayes-spam-filter

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/wchunt/naive-bayes-spam-filter

  • v0.0.0-20230324025813-dfcd8f539099
  • Source
  • Go
  • Socket score

Version published
Created
Source

Naive-Bayes-Spam-Filter Makefile CI Go

Description

This is a Naive Bayes classifier for spam detection in Go. It uses a simple bag-of-words model to train on a dataset of spam and non-spam (ham) emails and then classify new emails as either spam or ham. The algorithm assumes that each word in an email is independent of the other words, which is clearly not true, hence the "naive" in the name of the algorithm.

This project was originally a school assignment that I enjoyed, written in C++, but was later ported to Go to practice writing Go code and to experiment with parallelization.

The project solves the problem of classifying a given text file as either spam or ham. The model is trained on a dataset of known spam and real text files and then applied to new a new text file to determine it's classification.

The classifier works as follows:

  1. Read in a dataset of text files labeled as real and spam.

  2. Tokenize the text files by splitting them into individual words and storing the frequency of each word in the dataset.

  3. Calculate the prior probabilities of each class (spam and real) and the conditional probabilities of each word given each class.

  4. To classify a new text file, tokenize it, calculate the log-probability of it belonging to each class using the prior and conditional probabilities, and choose the class with the highest probability.

To use the classifier, clone the repository and follow the instructions in the README.md file.

FAQs

Package last updated on 24 Mar 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc