Spaces:
Runtime error
Runtime error
Commit
·
a5c06cc
1
Parent(s):
f576a59
Upload app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import pandas as pd
|
| 3 |
+
import joblib
|
| 4 |
+
|
| 5 |
+
st.header('FTDS Model Deployment')
|
| 6 |
+
st.write("""
|
| 7 |
+
Created by FTDS Curriculum Team
|
| 8 |
+
|
| 9 |
+
Use the sidebar to select input features.
|
| 10 |
+
""")
|
| 11 |
+
|
| 12 |
+
@st.cache
|
| 13 |
+
def fetch_data():
|
| 14 |
+
df = pd.read_csv('https://raw.githubusercontent.com/ardhiraka/PFDS_sources/master/campus.csv')
|
| 15 |
+
return df
|
| 16 |
+
|
| 17 |
+
df = fetch_data()
|
| 18 |
+
st.write(df)
|
| 19 |
+
|
| 20 |
+
st.sidebar.header('User Input Features')
|
| 21 |
+
|
| 22 |
+
def user_input():
|
| 23 |
+
gender = st.sidebar.selectbox('Gender', df['gender'].unique())
|
| 24 |
+
ssc = st.sidebar.number_input('Secondary School Points', value=67.00)
|
| 25 |
+
hsc = st.sidebar.number_input('High School Points', 0.0, value=91.0)
|
| 26 |
+
hsc_s = st.sidebar.selectbox('High School Spec', df['hsc_s'].unique())
|
| 27 |
+
degree_p = st.sidebar.number_input('Degree Points', 0.0, value=58.0)
|
| 28 |
+
degree_t = st.sidebar.selectbox('Degree Spec', df['degree_t'].unique())
|
| 29 |
+
workex = st.sidebar.selectbox('Work Experience?', df['workex'].unique())
|
| 30 |
+
etest_p = st.sidebar.number_input('Etest Points', 0.0, value=78.00)
|
| 31 |
+
spec = st.sidebar.selectbox('Specialization', df['specialisation'].unique())
|
| 32 |
+
mba_p = st.sidebar.number_input('MBA Points', 0.0, value=54.55)
|
| 33 |
+
|
| 34 |
+
data = {
|
| 35 |
+
'gender': gender,
|
| 36 |
+
'ssc_p': ssc,
|
| 37 |
+
'hsc_p': hsc,
|
| 38 |
+
'hsc_s': hsc_s,
|
| 39 |
+
'degree_p': degree_p,
|
| 40 |
+
'degree_t': degree_t,
|
| 41 |
+
'workex': workex,
|
| 42 |
+
'etest_p': etest_p,
|
| 43 |
+
'specialisation':spec,
|
| 44 |
+
'mba_p': mba_p
|
| 45 |
+
}
|
| 46 |
+
features = pd.DataFrame(data, index=[0])
|
| 47 |
+
return features
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
input = user_input()
|
| 51 |
+
|
| 52 |
+
st.subheader('User Input')
|
| 53 |
+
st.write(input)
|
| 54 |
+
|
| 55 |
+
load_model = joblib.load("my_model.pkl")
|
| 56 |
+
|
| 57 |
+
if st.button("Predict"):
|
| 58 |
+
prediction = load_model.predict(input)
|
| 59 |
+
|
| 60 |
+
if prediction == 1:
|
| 61 |
+
prediction = 'Placed'
|
| 62 |
+
else:
|
| 63 |
+
prediction = 'Not Placed'
|
| 64 |
+
|
| 65 |
+
st.write('Based on user input, the placement model predicted: ')
|
| 66 |
+
st.write(prediction)
|