Spaces:
Build error
Build error
import pandas as pd | |
import pickle | |
import numpy as np | |
from sklearn import tree | |
# Load the Random Forest CLassifier model | |
filename = 'model.pkl' | |
loaded_model = pickle.load(open(filename, 'rb')) | |
print(loaded_model) | |
input = [0.0,0.0,1.0,26.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0,1.0,0.0,3.0,0.0,15.0,0.0,0.0,7.0,5.0,7.0] | |
manualInput =[ | |
[1.0,1.0,1.0,37.0,1.0,1.0,1.0,0.0,0.0,1.0,0.0,1.0,0.0,5.0,0.0,0.0,1.0,1.0,10.0,6.0,5.0] | |
#,[1.0,1.0,1.0,28.0,1.0,0.0,1.0,0.0,0.0,1.0,0.0,1.0,0.0,4.0,0.0,0.0,0.0,1.0,12.0,2.0,4.0] | |
#,[1.0,1.0,1.0,27.0,1.0,0.0,0.0,0.0,1.0,1.0,0.0,1.0,0.0,4.0,20.0,20.0,1.0,0.0,8.0,4.0,7.0] | |
] | |
print(input, manualInput) | |
col=["HighBP","HighChol","CholCheck","BMI","Smoker","Stroke","HeartDiseaseorAttack","PhysActivity","Fruits" | |
,"Veggies","HvyAlcoholConsump","AnyHealthcare","NoDocbcCost","GenHlth","MentHlth","PhysHlth","DiffWalk" | |
,"Sex","Age","Education","Income"] | |
ddf = pd.DataFrame(manualInput, columns=col) | |
print(ddf) | |
result = loaded_model.predict(ddf) | |
print(result) |