nyomanyudisdeveloper commited on
Commit
58f46f5
·
verified ·
1 Parent(s): 19d677f

Upload 5 files

Browse files
Files changed (5) hide show
  1. app.py +10 -0
  2. eda.py +56 -0
  3. model_svr.pkl +3 -0
  4. predict.py +57 -0
  5. requirement.txt +7 -0
app.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import eda
3
+ import predict
4
+
5
+ navigation = st.slidebar.selectbox('Pilih Halaman:', {'EDA':'Predict'})
6
+
7
+ if navigation == 'EDA':
8
+ eda.run()
9
+ else:
10
+ predict.run()
eda.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import seaborn as sns
4
+ import matplotlib.pyplot as plt
5
+ import plotly.express as px
6
+
7
+ st.set_page_config(
8
+ page_title = 'FIFA 2022 - EDA',
9
+ layout = 'wide',
10
+ initial_sidebar_state = 'expanded'
11
+ )
12
+
13
+ def run():
14
+ st.title("FIFA 2022 Player Rating Prediction")
15
+
16
+ st.subheader('EDA untuk Analisis Dataset FIFA 2022')
17
+
18
+ st.image('https://e2e85xpajrr.exactdn.com/wp-content/uploads/2022/09/21190008/shutterstock_2190840355-scaled.jpg?strip=all&lossy=1&ssl=1',
19
+ caption='World Cup Champion')
20
+
21
+ st.write('Page ini dibuat oleh Vincent')
22
+ st.write('# Head')
23
+ st.write('## SubHeader')
24
+ st.write('### SubsubHeader')
25
+
26
+ st.markdown('---')
27
+
28
+ '''
29
+ Pada page ini, penulis akan melakukan eksplorasi sederhana, Dataset yang digunakan adalah dataset FIFA 2022.
30
+ Dataset ini berasal dari web [sofia.com](www.google.com)
31
+ '''
32
+
33
+ # Show dataframe
34
+ df = pd.read_csv('https://raw.githubusercontent.com/FTDS-learning-materials/phase-1/master/w1/P1W1D1PM%20-%20Machine%20Learning%20Problem%20Framing.csv')
35
+ st.dataframe(df)
36
+
37
+ st.write('### Plot AttackingWorkRate')
38
+ fig = plt.figure(figsize=(15,5))
39
+ sns.countplot(x= 'AttackingWorkRate', data=df)
40
+ st.pyplot(fig)
41
+
42
+ # Membuat histogram berdasarkan input user
43
+ st.write(' ### Histogram berdasarkan pilihan-mu')
44
+ pilihan = st.selectbox('Pilih feature: ',('Age','Height','Weight'))
45
+ fig = plt.figure(figsize= (15,5))
46
+ sns.histplot(df[pilihan], bins = 30, kde = True)
47
+ st.pyplot(fig)
48
+
49
+ # Membuat plotlt plot
50
+ st.write('### Plot antara ValueEur dengan Price')
51
+ fig = px.scatter(df,x='ValueEUR',y='Overall', hover_data=['Name','Age'])
52
+ st.plotly_chart(fig)
53
+
54
+ if __name__ == '__main__':
55
+ run()
56
+
model_svr.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2b675bcdf0b49515c8d6d6b211db0f270dd85bcbf079ea8e6c1da1ef28a7cd5f
3
+ size 1579177
predict.py ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import numpy as np
4
+ import pickle
5
+ with open('model_svr.pkl', 'rb') as file_6:
6
+ model = pickle.load(file_6)
7
+
8
+ def run():
9
+ with st.form("my_form"):
10
+
11
+ nama = st.text_input('masukan nama player', value='nama')
12
+ age = st.number_input('masukan usia player', min_value=15, max_value= 40, value=20)
13
+ height = st.slider('Height',50, 250, 170)
14
+ weight = st.number_input('Weight',50,100,70)
15
+ price = st.number_input('Price',0,1000000,10000, help="Harga Pemain dalam euro " )
16
+ # Every form must have a submit button.
17
+ st.write('-'*50)
18
+ attack = st.selectbox('Attacking Work Rate', {'Low','Medium','High'},index=1)
19
+ defense = st.radio('Defensive Work Rate', {'Low','Medium','High'},index=1)
20
+ st.markdown('---')
21
+
22
+ pace = st.number_input('Pace',0,100,50)
23
+ shoot = st.number_input('Shoot',0,100,50)
24
+ passing = st.number_input('Passing',0,100,50)
25
+ dribble = st.number_input('Dribble',0,100,50)
26
+ defend = st.number_input('Defend',0,100,50)
27
+ physicality = st.number_input('Physicality',0,100,50)
28
+ submitted = st.form_submit_button("Submit")
29
+
30
+ st.write("Outside the form")
31
+
32
+ data_inf = {
33
+ 'Name': nama,
34
+ 'Age' : age,
35
+ 'Height' : height,
36
+ 'Weight' : weight,
37
+ 'Price' : price,
38
+ 'AttackingWorkRate': attack,
39
+ 'DefensiveWorkRate': defense,
40
+ 'PaceTotal': pace,
41
+ 'ShootingTotal': shoot,
42
+ 'PassingTotal': passing,
43
+ 'DribblingTotal': dribble,
44
+ 'DefendingTotal': defend,
45
+ 'PhysicalityTotal': physicality
46
+ }
47
+
48
+ data_inf = pd.DataFrame([data_inf])
49
+
50
+ if submitted:
51
+ result= model.predict(data_inf)
52
+ st.write(f'## Player Rating: {round(result[0])}')
53
+ st.balloons()
54
+ st.snow()
55
+
56
+ if __name__ == '__main__':
57
+ run()
requirement.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ streamlit
2
+ pandas
3
+ seaborn
4
+ matplotlib
5
+ numpy
6
+ scikit-learn==1.3.0
7
+ plotyly