Spaces:
Build error
Build error
File size: 1,272 Bytes
92de636 97ba311 242a3da 97ba311 242a3da 97ba311 242a3da 97ba311 242a3da 97ba311 242a3da 97ba311 |
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 42 43 44 |
import pandas as pd
import pickle
import numpy as np
from sklearn import tree
import gradio as gr
# Load the Random Forest CLassifier model
filename = 'model.pkl'
loaded_model = pickle.load(open(filename, 'rb'))
print(loaded_model)
def multiline(textData):
print("inp", textData)
col=["HighBP","HighChol","CholCheck","BMI","Smoker","Stroke","HeartDiseaseorAttack","PhysActivity","Fruits"
,"Veggies","HvyAlcoholConsump","AnyHealthcare","NoDocbcCost","GenHlth","MentHlth","PhysHlth","DiffWalk"
,"Sex","Age","Education","Income"]
#empty_array = []
empty_array = np.empty((0, 21), float)
for line in textData.split("\n"):
abc = list(map(float, line.split(",")));
print(abc)
empty_array = np.append(empty_array, np.array([abc]), axis=0)
print("empty_array")
print(empty_array)
ddf = pd.DataFrame(empty_array, columns=col)
print("ddf")
print(ddf)
#print(loaded_model.predict(ddf))
return ddf
def predict2(content):
multiple_records = multiline(content)
result = classifier.predict(multiple_records)
print(result)
iface = gr.Interface(fn=predict2, inputs="text", outputs="text")
iface.launch()
|