Skip to content

Commit 119a979

Browse files
Merge pull request #405 from Shravanidorle/diseasePredictor
Added Disease predictor
2 parents 15d0651 + b205c00 commit 119a979

11 files changed

Lines changed: 5353 additions & 0 deletions

File tree

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
**Contributor:** shravanidorle
2+
3+
# Disease Predictor Web Service
4+
5+
## 🩺 Project Overview
6+
7+
This is a simple Flask-based web service that utilizes a pre-trained machine learning model to predict a disease based on a list of symptoms provided by the user. It provides both a simple web interface (assuming the necessary templates exist) and a dedicated API endpoint for programmatic access.
8+
9+
---
10+
11+
## ✨ Features
12+
13+
- **RESTful API Endpoint:** A dedicated `/predict` endpoint for JSON-based predictions.
14+
- **Machine Learning Integration:** Uses `joblib` to load and utilize a pre-trained model.
15+
- **Web Interface:** Serves simple front-end pages (`/`, `/about`, `/services`) using Flask templating (requires `index.html`, `about.html`, and `services.html`).
16+
17+
---
18+
19+
## 🛠️ Prerequisites
20+
21+
Before running the application, ensure you have the following installed:
22+
23+
- **Python 3.x**
24+
- **Flask**
25+
- **joblib**
26+
27+
---
28+
29+
## 🚀 Setup and Installation
30+
31+
### 1. File Structure
32+
33+
Your project directory should be structured as follows:
34+
35+
disease-predictor/ ├── app.py ├── disease_predictor_model_5000.pkl <-- Your trained model file (REQUIRED) ├── templates/ │ ├── index.html <-- Home page template (REQUIRED) │ ├── about.html <-- About page template (REQUIRED) │ └── services.html <-- Services page template (REQUIRED) └── README.md
36+
37+
### 2. Install Dependencies
38+
39+
You can install the required Python packages using `pip`:
40+
41+
```bash
42+
pip install Flask joblib
43+
44+
```
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from flask import Flask, request, jsonify, render_template
2+
import joblib
3+
4+
app = Flask(__name__)
5+
model = joblib.load('disease_predictor_model_5000.pkl')
6+
7+
@app.route('/')
8+
def home():
9+
return render_template('index.html')
10+
11+
@app.route('/about')
12+
def about():
13+
return render_template('about.html')
14+
15+
@app.route('/services')
16+
def services():
17+
return render_template('services.html')
18+
19+
@app.route('/predict', methods=['POST'])
20+
def predict():
21+
data = request.json
22+
symptoms = data.get('symptoms', '')
23+
prediction = model.predict([symptoms])
24+
return jsonify({'disease': prediction[0]})
25+
26+
if __name__ == '__main__':
27+
app.run(debug=True)
Binary file not shown.

0 commit comments

Comments
 (0)