https://github.com/iamyourdre/naive-bayes-classifier-js
Naive Bayes classifier developed with MySQL, ExpressJS, and NodeJS by @iamyourdre.
https://github.com/iamyourdre/naive-bayes-classifier-js
backend data data-science expressjs javascript mysql naive-bayes naive-bayes-algorithm naive-bayes-classifier nodejs
Last synced: 8 months ago
JSON representation
Naive Bayes classifier developed with MySQL, ExpressJS, and NodeJS by @iamyourdre.
- Host: GitHub
- URL: https://github.com/iamyourdre/naive-bayes-classifier-js
- Owner: iamyourdre
- Created: 2023-08-22T12:11:42.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-08-24T07:27:54.000Z (about 2 years ago)
- Last Synced: 2025-02-14T21:33:03.645Z (9 months ago)
- Topics: backend, data, data-science, expressjs, javascript, mysql, naive-bayes, naive-bayes-algorithm, naive-bayes-classifier, nodejs
- Language: JavaScript
- Homepage:
- Size: 24.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Naive Bayes Classifier JS
### With Node JS, Express and MySQL

## A. How to Configure:
### 1. Install Backend Prerequisite.
- Move to `cd backend`
- Run `npm i express mysql2 sequelize cors mathjs`
### 2. Configure Database.
- Set the database connection in "backend/config/Database.js"
- Import "sample.sql" to 'naive_bayes_js' database.
### 3. Run Server.
- Check `nodemon -v`. If you have not installed yet, run `npm i -g nodemon`
- Start backend server with `nodemon index` (Make sure your terminal path is on "your-project/backend")
## ___________________
## B. How to Use:
- First of all, you need to calculate "sample" table with Naive Bayes algorithm first, then it will be summarized as "NB_dataclass" table. You can use Rest Client or POSTMAN. Run it once.
```
POST http://localhost:5000/CreateNaiveBayesDataset
Content-Type: application/json
```
- Then, put your input on x1, x2, x3, and x4 and run it. It will classify the genre from your input.
```
POST http://localhost:5000/NaiveBayesClassifier
Content-Type: application/json
{
"x1": 30, "x2": 922001, "x3": 3631, "x4": 3726
}
```
After process completed, the output will be like this:
```
{
"msg": "Calculation Completed! Your input is classified as:",
"result": [
{
"genreIs": "Hardrock",
"probability": 0.024855977439682212
}
]
}
```