https://github.com/kartikchugh/spam-classifier
ML-powered Flask app to perform spam classification of SMS messages. Uses TFIDF vectorization + logistic regression to achieve ~98% accuracy.
https://github.com/kartikchugh/spam-classifier
bootstrap flask logistic-regression machine-learning spam-filtering
Last synced: 5 months ago
JSON representation
ML-powered Flask app to perform spam classification of SMS messages. Uses TFIDF vectorization + logistic regression to achieve ~98% accuracy.
- Host: GitHub
- URL: https://github.com/kartikchugh/spam-classifier
- Owner: KartikChugh
- Created: 2020-04-17T16:44:44.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-08T04:02:52.000Z (over 3 years ago)
- Last Synced: 2025-08-31T14:43:38.055Z (10 months ago)
- Topics: bootstrap, flask, logistic-regression, machine-learning, spam-filtering
- Language: HTML
- Homepage: https://ml-spam-classifier.herokuapp.com/
- Size: 616 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 9
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Spam Classification App
Built with [Flask](https://flask.palletsprojects.com/), powered by [Scikit-Learn](https://scikit-learn.org/), styled via [Bootstrap](https://getbootstrap.com/), and deployed through [Heroku](https://ml-spam-classifier.herokuapp.com/).
Spam Classifier uses a logistic regression model to classify messages (preferably SMS) as spam or not spam with 98.21% accuracy.

## Prerequisites
Make sure that you have the following:
* Python 3+ and pip (which comes with Python 3+)
* A Unix command line (e.g. Git Bash).
## Running the App
What each file does:
* `server.py` - runs the server and loads the user interface.
* `templates/layout.html` - contains the base HTML
* `templates/index.html` - contains the body of the HTML
* `models/saved/` - contains all locally saved models and dataframes for future loading
* `models/save_df.py` - cleans the dataframe and saves the new dataframe to local file structure.
* `models/model.py` - builds and saves the logistic regression model.
To run the app, complete the following steps:
1. Make sure you have Python 3 and a text editor installed.
2. Install the `virtualenv` package using `pip install virtualenv`.
3. Install the required packages using `pip install -r requirements.txt`. You can manually install them as you come across them if need be, but this will install them all for you. Note that if you add more packages, run `pip freeze > requirements.txt` to save them to your requirements file.
4. Create a virtual environment using `virtualenv ` and start it using `source .//Scripts/activate`. Note that the activate script directory might change depending on your operating system.
5. Run the `models/save_df.py` file. This will save the cleaned dataframe as a csv under the `models/saved` directory.
6. Run the `models/model.py` file. This will build the model and save it as a `.joblib` file under the `models/saved` directory.
7. Run the `server.py` file. Make sure that the `saved/` directory contains both the `dataframe.csv` and `model.joblib` files.
## More Info
To learn how to build your own spam classifier, refer to the [MLC@UVA tutorial](https://github.com/dylankfernandes/spam-classifier/blob/hosting/hosting.md)