Heart Disease Prediction Using Machine Learning
Heart Disease Prediction Using Machine Learning
1. Supervised Learning
2. Unsupervised Learning
5. Self-Supervised Learning
Software Requirements
The development of this project relies on the following software
and tools:
1. Programming Language: Python (version 3.8 or higher).
2. Frameworks:
oFlask: For building the web application.
o Scikit-learn: For machine learning model
implementation.
3. Dependencies:
o Pandas: For data manipulation.
Code Explanation
app.py
The app.py file serves as the entry point for the Flask
application. Below is a breakdown of its functionality:
1. Importing Libraries:
o Flask: Used to create the web application.
input form.
o Prediction Route (/predict): Processes user input and
makes predictions.
Example of the prediction logic:
@app.route('/predict', methods=['POST'])
def predict():
input_features = [float(x) for x in request.form.values()]
final_features = [np.array(input_features)]
prediction = model.predict(final_features)
output = 'High Risk' if prediction[0] == 1 else 'Low Risk'
return render_template('result.html',
prediction_text=f'Heart Disease Risk: {output}')
5. Templates: HTML templates in the templates folder (e.g.,
index.html and result.html) are used to render input forms
and display results.
prediction.py
The prediction.py file focuses on processing data and predicting
outcomes using the KNN model. Below is a summary:
1. Loading Data:
2. import pandas as pd
3. data = pd.read_csv('heart_cleveland_upload.csv')
4. Preprocessing:
o Handling missing values.
Literature review