{"id":16082123,"url":"https://github.com/varunon9/naive-bayes-classifier","last_synced_at":"2025-03-18T06:30:24.302Z","repository":{"id":93827415,"uuid":"71764348","full_name":"varunon9/naive-bayes-classifier","owner":"varunon9","description":"Implementing Naive Bayes Classification algorithm into PHP to classify given text as ham or spam. This application uses MySql as database.","archived":false,"fork":false,"pushed_at":"2018-01-16T18:32:33.000Z","size":418,"stargazers_count":23,"open_issues_count":1,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-16T17:27:11.318Z","etag":null,"topics":["classifier","ham","mysql-database","naive-bayes-classifier","php","spam"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/varunon9.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-10-24T07:42:30.000Z","updated_at":"2023-12-20T11:07:00.000Z","dependencies_parsed_at":"2023-03-14T22:15:49.441Z","dependency_job_id":null,"html_url":"https://github.com/varunon9/naive-bayes-classifier","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/varunon9%2Fnaive-bayes-classifier","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/varunon9%2Fnaive-bayes-classifier/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/varunon9%2Fnaive-bayes-classifier/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/varunon9%2Fnaive-bayes-classifier/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/varunon9","download_url":"https://codeload.github.com/varunon9/naive-bayes-classifier/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244169175,"owners_count":20409675,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["classifier","ham","mysql-database","naive-bayes-classifier","php","spam"],"created_at":"2024-10-09T11:25:42.335Z","updated_at":"2025-03-18T06:30:24.294Z","avatar_url":"https://github.com/varunon9.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Naive Bayes Classifier\n\nImplementing Naive Bayes Classification algorithm into PHP to classify given text as ham or spam using MySql database.\n\n### How to use\n    \n    \u003c?php\n\n        require_once('NaiveBayesClassifier.php');\n\n        $classifier = new NaiveBayesClassifier();\n        $spam = Category::$SPAM;\n        $ham = Category::$HAM;\n\n        $classifier -\u003e train('Have a pleasurable stay! Get up to 30% off + Flat 20% Cashback on Oyo Room' . \n                ' bookings done via Paytm', $spam);\n        $classifier -\u003e train('Lets Talk Fashion! Get flat 40% Cashback on Backpacks, Watches, Perfumes,' .\n                ' Sunglasses \u0026 more', $spam);\n\n        $classifier -\u003e train('Opportunity with Product firm for Fullstack | Backend | Frontend- Bangalore', $ham);\n        $classifier -\u003e train('Javascript Developer, Fullstack Developer in Bangalore- Urgent Requirement', $ham);\n\n        $category = $classifier -\u003e classify('Scan Paytm QR Code to Pay \u0026 Win 100% Cashback');\n        echo $category; // spam\n        \n        $category = $classifier -\u003e classify('Re: Applying for Fullstack Developer');\n        echo $category; // ham\n\n    ?\u003e\n\n### How to install the project-\n\n1. Download the project and extract zip.\n2. Create database in MySql-\n\n    1. mysql\u003e create database naiveBayes;\n    2. mysql\u003e use naiveBayes;\n    3. mysql\u003e create table trainingSet (S_NO integer primary key auto_increment, document text, category varchar(255));\n    4. mysql\u003e create table wordFrequency (S_NO integer primary key auto_increment, word varchar(255), count integer, category varchar(255));\n\n3. Open a terminal and move to project folder\n4. Edit database connection info in db_connect.php file\n5. Execute main.php `php main.php`\n\n### Database Schema\n    \n![Database Schema](./screenshots/database_schema.png) \n\n#### Blog\nhttps://medium.com/@varunon9/classify-emails-into-ham-and-spam-using-naive-bayes-classifier-ffddd7faa1ef\n\n##### For any bug/mistake you can create github issue. Contact varunon9@gmail.com for suggestion/query. ","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvarunon9%2Fnaive-bayes-classifier","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvarunon9%2Fnaive-bayes-classifier","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvarunon9%2Fnaive-bayes-classifier/lists"}