Ayslove commited on
Commit
b987c89
1 Parent(s): 5214ce3

Update app.py

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