Spaces:
Sleeping
Sleeping
File size: 3,846 Bytes
fb5dff5 e6ccabf | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | ---
title: Spam Email Classifier
emoji: 🦀
colorFrom: yellow
colorTo: red
sdk: docker
pinned: false
---
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
---
# Spam Email Classifier
A simple Machine Learning project to classify spam email and normal email. This project is to understand basic concepts of LLM and deploy a model on a server using fastapi and interact with HTML UI
## Dataset
This project utilizes the [Spam Emails Dataset](https://www.kaggle.com/datasets/ashfakyeafi/spam-email-classification/data), a dataset in machine learning that contains many samples of Emails and messages, each classifier into two classes: ham(for legit email) and spam (for spam email)
## Installation & Setup
### Prerequisites
- Python 3.8+
- FastAPI
- Scikit-learn
- Pandas
- HTML
## Export classification model
- To re-train or export new models run command:
```bash
python export_model.py
```
### Running Steps using Docker (Port 8888)
1. **Clone the repository**
Clone the project repository to your local machine.
```bash
git clone <repository-url>
cd <repository-folder>
```
2. **Install dependencies**
Install the required Python dependencies.
```bash
pip install -r requirements.txt
```
3. **Build Docker Image**
```bash
docker build -t app .
```
4. **Run Docker Image**
```bash
docker run -p 8888:8888 app
```
### Running Steps Locally (If run locally, default port will be 8000)
1. **Clone the repository**
Clone the project repository to your local machine.
```bash
git clone <repository-url>
cd <repository-folder>
```
2. **Install dependencies**
Install the required Python dependencies.
```bash
pip install -r requirements.txt
```
3. **Start the FastAPI server**
Run the FastAPI server to serve the model (default port 8000).
```bash
127.0.0.1:8000
```
```bash
uvicorn server:app --reload
```
or
```bash
python -m uvicorn server:app --reload
```
4. **Access API Documentation**
Open the following API documentation in your browser:
- Local Server:
- Swagger UI: [http://127.0.0.1:8000/docs](http://127.0.0.1:8000/docs)
- Redoc: [http://127.0.0.1:8000/redoc](http://127.0.0.1:8000/redoc)
- Remote Sever using Hugging Face: [https://dangminh214-spam-email-classifier.hf.space/docs](https://dangminh214-spam-email-classifier.hf.space/docs)
5. **Run the client-side application**
Open web/index.html in web browser
## API Endpoints
### **POST** `/predict`
Predicts the E-Mail if it is a Spam E-Mail or not
- **Request Body (JSON):**
```json
{
"text": "Hi I am Minh"
}
```
- **Response:**
```json
{
"prediction": "ham"
}
```
### **GET** `/`
Give the information of project to user
- **Response:**
```json
{
"info": "Welcome to Dang Minh EMail Spam Classifier Model, this is a personal project to practice my knowledge in NLP and MLops"
}
```
### Deploy remotely on HF
Server URL
```bash
https://dangminh214-spam-email-classifier.hf.space
```
## Expandability
This project can be expanded beyond just the provided HTML file. It can be integrated with other web frameworks, such as ReactJS, to create an even more interactive and user-friendly interface. This will further enhance the usability and scalability of the application.
## Demo Usage


## Contributing
Contributions are welcome! If you find any issues or want to suggest improvements, feel free to open an issue or submit a pull request.
## License
[](https://opensource.org/licenses/MIT)
This project is licensed under the MIT License.
|