Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -2,6 +2,8 @@ import streamlit as st
|
|
2 |
import numpy as np
|
3 |
import pickle
|
4 |
import streamlit.components.v1 as components
|
|
|
|
|
5 |
|
6 |
# Load the pickled model
|
7 |
def load_model():
|
@@ -12,6 +14,10 @@ def model_prediction(model, features):
|
|
12 |
predicted = str(model.predict(features)[0])
|
13 |
return predicted
|
14 |
|
|
|
|
|
|
|
|
|
15 |
def app_design():
|
16 |
# Add input fields for High, Open, and Low values
|
17 |
image = '22.png' #change
|
@@ -25,10 +31,13 @@ def app_design():
|
|
25 |
Sex = 1
|
26 |
else:
|
27 |
Sex = 0
|
28 |
-
bmi = st.number_input("
|
29 |
-
children = st.number_input("
|
30 |
-
smoker = st.
|
31 |
-
|
|
|
|
|
|
|
32 |
|
33 |
|
34 |
|
|
|
2 |
import numpy as np
|
3 |
import pickle
|
4 |
import streamlit.components.v1 as components
|
5 |
+
from sklearn.preprocessing import LabelEncoder
|
6 |
+
le = LabelEncoder()
|
7 |
|
8 |
# Load the pickled model
|
9 |
def load_model():
|
|
|
14 |
predicted = str(model.predict(features)[0])
|
15 |
return predicted
|
16 |
|
17 |
+
def transform(text):
|
18 |
+
text = le.fit_transform(text)
|
19 |
+
return text[0]
|
20 |
+
|
21 |
def app_design():
|
22 |
# Add input fields for High, Open, and Low values
|
23 |
image = '22.png' #change
|
|
|
31 |
Sex = 1
|
32 |
else:
|
33 |
Sex = 0
|
34 |
+
bmi = st.number_input("BMI")
|
35 |
+
children = st.number_input("Children")
|
36 |
+
smoker = st.text_input("Smoker")
|
37 |
+
smoker = transform(['smoker'])
|
38 |
+
region = st.text_input("Region")
|
39 |
+
region= transform(['region'])
|
40 |
+
|
41 |
|
42 |
|
43 |
|