Upload app.py
Browse files
app.py
CHANGED
|
@@ -1,63 +1,71 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
-
import
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
-
|
| 6 |
-
st.
|
| 7 |
-
|
|
|
|
| 8 |
|
| 9 |
Use the sidebar to select input features.
|
| 10 |
""")
|
| 11 |
|
| 12 |
-
@st.
|
| 13 |
def fetch_data():
|
| 14 |
-
df = pd.read_csv('
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
return df
|
| 16 |
|
| 17 |
df = fetch_data()
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
etest_p = st.number_input('Etest Points', 0.0, value=78.00)
|
| 27 |
-
spec = st.selectbox('Specialization', df['specialisation'].unique())
|
| 28 |
-
mba_p = st.number_input('MBA Points', 0.0, value=54.55)
|
| 29 |
|
| 30 |
data = {
|
| 31 |
-
'
|
| 32 |
-
'
|
| 33 |
-
'
|
| 34 |
-
'
|
| 35 |
-
'
|
| 36 |
-
|
| 37 |
-
'workex': workex,
|
| 38 |
-
'etest_p': etest_p,
|
| 39 |
-
'specialisation':spec,
|
| 40 |
-
'mba_p': mba_p
|
| 41 |
}
|
| 42 |
input = pd.DataFrame(data, index=[0])
|
| 43 |
|
| 44 |
st.subheader('User Input')
|
| 45 |
st.write(input)
|
| 46 |
|
| 47 |
-
load_model =
|
|
|
|
|
|
|
| 48 |
|
| 49 |
if st.button('Predict'):
|
| 50 |
prediction = load_model.predict(input)
|
| 51 |
|
| 52 |
if prediction == 1:
|
| 53 |
-
prediction = '
|
| 54 |
else:
|
| 55 |
-
prediction = '
|
| 56 |
|
| 57 |
st.write('Based on user input, the placement model predicted: ')
|
| 58 |
st.write(prediction)
|
| 59 |
|
| 60 |
-
|
| 61 |
-
|
|
|
|
|
|
|
| 62 |
|
| 63 |
-
st.image(image, caption='mantap')
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
+
import pickle
|
| 4 |
+
from sklearn.impute import SimpleImputer
|
| 5 |
+
from sklearn.preprocessing import StandardScaler, MinMaxScaler, OneHotEncoder, OrdinalEncoder
|
| 6 |
+
from sklearn.pipeline import Pipeline
|
| 7 |
+
from sklearn.compose import ColumnTransformer
|
| 8 |
+
from sklearn.ensemble import RandomForestClassifier
|
| 9 |
|
| 10 |
+
|
| 11 |
+
st.sidebar.title('Grade Challange 3')
|
| 12 |
+
st.sidebar.write("""
|
| 13 |
+
Created by Wawan Setiawan S
|
| 14 |
|
| 15 |
Use the sidebar to select input features.
|
| 16 |
""")
|
| 17 |
|
| 18 |
+
@st.cache_resource
|
| 19 |
def fetch_data():
|
| 20 |
+
df = pd.read_csv('h8dsft_P1G3_Wawan_Setiawan.csv')
|
| 21 |
+
df['anaemia'] = df['anaemia'].replace({0: 'no', 1 : 'yes'})
|
| 22 |
+
df['diabetes'] = df['diabetes'].replace({0 : 'no', 1: 'yes'})
|
| 23 |
+
df['high_blood_pressure'] = df['high_blood_pressure'].replace({0 : 'no', 1: 'yes'})
|
| 24 |
+
df['smoking'] = df['smoking'].replace({0 : 'no', 1: 'yes'})
|
| 25 |
+
df['sex'] = df['sex'].replace({0 : 'female', 1: 'male'})
|
| 26 |
+
df['DEATH_EVENT'] = df['DEATH_EVENT'].astype(float)
|
| 27 |
return df
|
| 28 |
|
| 29 |
df = fetch_data()
|
| 30 |
|
| 31 |
+
|
| 32 |
+
creatinine_phosphokinase = st.sidebar.slider('creatinine_phosphokinase', 30,8000)
|
| 33 |
+
serum_creatinine = st.sidebar.slider('serum_creatinine', 0.0,10.0)
|
| 34 |
+
serum_sodium = st.sidebar.slider('serum_sodium', 100., 150.)
|
| 35 |
+
age = st.sidebar.slider('age', 1,100)
|
| 36 |
+
time = st.sidebar.slider('time', 1.0, 300.0)
|
| 37 |
+
|
|
|
|
|
|
|
|
|
|
| 38 |
|
| 39 |
data = {
|
| 40 |
+
'creatinine_phosphokinase': creatinine_phosphokinase,
|
| 41 |
+
'serum_creatinine': serum_creatinine,
|
| 42 |
+
'serum_sodium': serum_sodium,
|
| 43 |
+
'age': age,
|
| 44 |
+
'time': time,
|
| 45 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
}
|
| 47 |
input = pd.DataFrame(data, index=[0])
|
| 48 |
|
| 49 |
st.subheader('User Input')
|
| 50 |
st.write(input)
|
| 51 |
|
| 52 |
+
load_model = pickle.load(open('all_process.pkl','rb'))
|
| 53 |
+
gaussian_columns_cleaned = pickle.load(open('gaussian_columns_cleaned.txt','rb'))
|
| 54 |
+
iqr_columns_1_cleaned = pickle.load(open('iqr_columns_1_cleaned.txt','rb'))
|
| 55 |
|
| 56 |
if st.button('Predict'):
|
| 57 |
prediction = load_model.predict(input)
|
| 58 |
|
| 59 |
if prediction == 1:
|
| 60 |
+
prediction = 'Yes'
|
| 61 |
else:
|
| 62 |
+
prediction = 'No'
|
| 63 |
|
| 64 |
st.write('Based on user input, the placement model predicted: ')
|
| 65 |
st.write(prediction)
|
| 66 |
|
| 67 |
+
chart_data = pd.DataFrame(
|
| 68 |
+
data)
|
| 69 |
+
|
| 70 |
+
st.line_chart(chart_data)
|
| 71 |
|
|
|