Heart_Disease / app.py
Pranjal-psytech's picture
Add application Model
ab19217
raw
history blame
1.23 kB
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score
from sklearn.linear_model import LogisticRegression
import warnings
warnings.filterwarnings('ignore')
import joblib
import gradio as gr
loaded_model = joblib.load('heart.pkl')
def heart_disease(age, sex, cp, trestbps, chol, fbs, restecg, thalach, exang, oldpeak, slope, ca,thal):
#turning the arguments into a numpy array
x = np.array([age, sex, cp, trestbps, chol, fbs, restecg, thalach, exang, oldpeak, slope, ca,thal])
prediction = loaded_model.predict(x.reshape(1, -1))
if(prediction[0]==0):
return("The person does not have any heart diseases")
else:
return('The person has a heart disease')
outputs = gr.outputs.Textbox()
examples = [
[59, 1, 1, 140, 221, 0, 1, 164, 1, 0.0, 2, 0, 2],
# Add more examples here if you want
]
app = gr.Interface(fn=heart_disease, inputs=['number','number','number','number','number','number','number','number','number','number','number','number','number'], outputs=outputs, examples=examples,description="This is a heart_disease model")
app.launch(share=True)