This project implements a comprehensive web-based system to predict the risk of heart disease using a machine learning model.
Try it out at heart-disease-prediction.harshbanka.codes
- User Input Form: An intuitive web form for users to enter their health data.
- Machine Learning Model: A trained model that predicts heart disease risk based on the provided input.
- Prediction Display: Clear presentation of the prediction result to the user.
- MongoDB Integration: Stores user input and prediction results in a MongoDB database.
- Prediction History: A history page to view past prediction records.
- Python
- FastAPI
- Jinja2 Templates
- MongoDB
- pymongo
- HTML, CSS, Bootstrap
- JavaScript
-
Clone the Repository:
git clone https://github.com/<your-username>/<project-repository-name>
-
Create a Virtual Environment:
- Recommended: Use a tool like
venv
orconda
. - Example (venv):
python3 -m venv env source env/bin/activate
- Recommended: Use a tool like
-
Install Dependencies:
pip install -r requirements.txt
-
MongoDB Setup
- Local Installation:
- Follow the instructions from the official MongoDB website: https://www.mongodb.com/docs/
- Start the MongoDB server (usually with the
mongod
command).
- Cloud Service (MongoDB Atlas):
- Create a MongoDB Atlas account: https://www.mongodb.com/cloud/atlas
- Set up a cluster and obtain your database connection string.
- Local Installation:
-
Configure MongoDB Connection
- Option 1: Export MONGO_URL in Terminal
-
Set the
MONGO_URL
environment variable in your terminal before running the application:export MONGO_URL="your_mongo_connection_string"
-
- Option 2: Update Manually in the File
- If you prefer not to use environment variables, you can manually update the
MONGO_URL
variable in the file with your MongoDB connection string. - Locate
utils/database.py
or a similar file where you manage database connections. - Update the connection function (e.g.,
connect_to_mongo()
) with your MongoDB connection details:**
# ... other code ... MONGO_URL = os.environ.get('MONGO_URL') or "mongodb://127.0.0.1:27017/" client = pymongo.MongoClient(MONGO_URL) # Replace with your connection string # ... rest of the code ...
- If you prefer not to use environment variables, you can manually update the
- Option 1: Export MONGO_URL in Terminal
-
Run the Application:
uvicorn app:app --reload
Open http://127.0.0.1:8000
in your web browser to use the heart disease prediction system.
The machine learning model used for heart disease prediction is SVM using scikit-learn.
This project is licensed under the MIT License. For more details, see the LICENSE file.