Spaces:
Sleeping
Sleeping
File size: 832 Bytes
626fd55 | 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 | # -*- 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() |