File size: 1,228 Bytes
ab19217
 
 
 
 
 
 
 
 
 
f082102
 
 
ab19217
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
37
38
39
40
41
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)