Heart-Risk / app.py
praveen1209's picture
Upload app.py
626fd55 verified
raw
history blame contribute delete
832 Bytes
# -*- coding: utf-8 -*-
"""app.ipynb
Automatically generated by Colab.
Original file is located at
https://colab.research.google.com/drive/12dUkowcCMVR7rhN2GdQVka92l9SM_0tI
"""
import gradio as gr
import numpy as np
import pickle
# Load model
with open("model.pkl", "rb") as f:
model = pickle.load(f)
# Prediction function
def predict_risk(bp, cholesterol):
input_data = np.array([[bp, cholesterol]])
prediction = model.predict(input_data)
return "Risk" if prediction[0] == 1 else "No Risk"
# Gradio interface
iface = gr.Interface(
fn=predict_risk,
inputs=[
gr.Number(label="Blood Pressure (BP)"),
gr.Number(label="Cholesterol")
],
outputs="text",
title="Heart Risk Prediction",
description="Enter BP and Cholesterol to check heart risk using KNN."
)
iface.launch()