deploy_hck5 / app.py
galihsukmana's picture
Upload 2 files
dba74a7
raw
history blame
1.74 kB
import streamlit as st
import pandas as pd
import joblib
st.header('FTDS Model Deployment')
st.write("""
Created by FTDS Curriculum Team
Use the sidebar to select input features.
""")
@st.cache
def fetch_data():
df = pd.read_csv('https://raw.githubusercontent.com/ardhiraka/PFDS_sources/master/campus.csv')
return df
df = fetch_data()
def user_input():
gender = st.selectbox('Gender', df['gender'].unique())
ssc = st.number_input('Secondary School Points', value=67.00)
hsc = st.number_input('High School Points', 0.0, value=91.0)
hsc_s = st.selectbox('High School Spec', df['hsc_s'].unique())
degree_p = st.number_input('Degree Points', 0.0, value=58.0)
degree_t = st.selectbox('Degree Spec', df['degree_t'].unique())
workex = st.selectbox('Work Experience?', df['workex'].unique())
etest_p = st.number_input('Etest Points', 0.0, value=78.00)
spec = st.selectbox('Specialization', df['specialisation'].unique())
mba_p = st.number_input('MBA Points', 0.0, value=54.55)
data = {
'gender': gender,
'ssc_p': ssc,
'hsc_p': hsc,
'hsc_s': hsc_s,
'degree_p': degree_p,
'degree_t': degree_t,
'workex': workex,
'etest_p': etest_p,
'specialisation':spec,
'mba_p': mba_p
}
features = pd.DataFrame(data, index=[0])
return features
input = user_input()
st.subheader('User Input')
st.write(input)
load_model = joblib.load("my_model.pkl")
if st.button('Predict'):
prediction = load_model.predict(input)
if prediction == 1:
prediction = 'Placed'
else:
prediction = 'Not Placed'
st.write('Based on user input, the placement model predicted: ')
st.write(prediction)