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():
|
|
@@ -11,6 +13,10 @@ def load_model():
|
|
| 11 |
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
|
|
@@ -20,14 +26,20 @@ def app_design():
|
|
| 20 |
st.subheader("Enter the following values:")
|
| 21 |
|
| 22 |
Age = st.number_input("Age")
|
| 23 |
-
Workclass = st.
|
|
|
|
| 24 |
Final_weight = st.number_input("Final_weight")
|
| 25 |
-
Education = st.
|
|
|
|
| 26 |
Education_Num = st.number_input("Education_Num")
|
| 27 |
-
Marital_status = st.
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
Sex = st.selectbox("Sex",('Male','Female'))
|
| 32 |
if Sex == 'Male':
|
| 33 |
Sex = 1
|
|
@@ -36,7 +48,8 @@ def app_design():
|
|
| 36 |
Capital_gain = st.number_input("Capital_gain")
|
| 37 |
Capital_loss = st.number_input("Capital_loss")
|
| 38 |
Hours_per_week = st.number_input("Hours_per_week")
|
| 39 |
-
Native_country = st.
|
|
|
|
| 40 |
|
| 41 |
|
| 42 |
# Create a feature list from the user inputs
|
|
|
|
| 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():
|
|
|
|
| 13 |
def model_prediction(model, features):
|
| 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
|
|
|
|
| 26 |
st.subheader("Enter the following values:")
|
| 27 |
|
| 28 |
Age = st.number_input("Age")
|
| 29 |
+
Workclass = st.text_input("Workclass")
|
| 30 |
+
Wrokclass = transform([Workclass])
|
| 31 |
Final_weight = st.number_input("Final_weight")
|
| 32 |
+
Education = st.text_input("Education")
|
| 33 |
+
Education=transform([Education])
|
| 34 |
Education_Num = st.number_input("Education_Num")
|
| 35 |
+
Marital_status = st.text_input("Marital_status")
|
| 36 |
+
Marital_status=transform([Marital_status])
|
| 37 |
+
Occupation = st.text_input("Occupation")
|
| 38 |
+
Occupation=transform([Occupation])
|
| 39 |
+
Relationship = st.text_input("Relationship")
|
| 40 |
+
Relationship=transform([Relationship])
|
| 41 |
+
Race = st.text_input("Race")
|
| 42 |
+
Race=transform([Race])
|
| 43 |
Sex = st.selectbox("Sex",('Male','Female'))
|
| 44 |
if Sex == 'Male':
|
| 45 |
Sex = 1
|
|
|
|
| 48 |
Capital_gain = st.number_input("Capital_gain")
|
| 49 |
Capital_loss = st.number_input("Capital_loss")
|
| 50 |
Hours_per_week = st.number_input("Hours_per_week")
|
| 51 |
+
Native_country = st.text_input("Native_country")
|
| 52 |
+
Native_country=transform([Native_country])
|
| 53 |
|
| 54 |
|
| 55 |
# Create a feature list from the user inputs
|