Gigisghifari commited on
Commit
9a005e8
1 Parent(s): 4e7dbba

Upload 5 files

Browse files
Files changed (5) hide show
  1. app.py +10 -0
  2. eda.py +63 -0
  3. model_svr.pkl +3 -0
  4. predict.py +58 -0
  5. requirements.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.sidebar.selectbox('Pilih Halaman:', ('EDA','Predict'))
6
+
7
+ if navigation == 'EDA':
8
+ eda.run()
9
+ else:
10
+ predict.run()
eda.py ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ # Membuat title
15
+ st.title('Fifa 2022 Player Rating Prediction')
16
+
17
+ # Membuat Subheader
18
+ st.subheader('EDA untuk Analisis Dataset FIFA 2022')
19
+
20
+ # Menambah Gambar
21
+ st.image('https://digitalhub.fifa.com/transform/34dd7fb5-4887-4015-b61d-bbbf6bdfa34a/Argentina-v-France-Final-FIFA-World-Cup-Qatar-2022?&io=transform:fill,aspectratio:16x9&quality=75',
22
+ caption= 'World Cup Champion')
23
+
24
+ # Menambah Deskripsi
25
+ st.write('Page ini dibuat oleh gigis')
26
+ st.write('#Head')
27
+ st.write('##SubHeader')
28
+ st.write('###SubSubHeader')
29
+
30
+ # membuat garis lurus
31
+ st.markdown('---')
32
+
33
+ # Magic syntax
34
+ '''
35
+ Pada page ini, penulis akan melakukan explorasi sederhana
36
+ dataset yang digunakan adalah dataset fifa
37
+ dataset ini diambil dari sofia.com
38
+ '''
39
+
40
+ # show dataframe
41
+ df = pd.read_csv('https://raw.githubusercontent.com/FTDS-learning-materials/phase-1/master/w1/P1W1D1PM%20-%20Machine%20Learning%20Problem%20Framing.csv')
42
+ st.dataframe(df)
43
+
44
+ # Membuat Barplot
45
+ st.write('### Plot AttackingWorkRate')
46
+ fig = plt.figure(figsize=[15,5])
47
+ sns.countplot(x='AttackingWorkRate', data=df)
48
+ st.pyplot(fig)
49
+
50
+ # membuat histogram berdasarkan input user
51
+ st.write('### Histogram berdasarkan pilihanmu')
52
+ pilihan= st.selectbox('pilih features:',('Age','Height','Weight'))
53
+ fig = plt.figure(figsize= (15,5))
54
+ sns.histplot(df[pilihan], bins=30, kde=True)
55
+ st.pyplot(fig)
56
+
57
+ # membuat plot
58
+ st.write('### Plot antara ValueEUR dengan Price')
59
+ fig= px.scatter(df,x='ValueEUR',y='Overall', hover_data=['Name','Age'])
60
+ st.plotly_chart(fig)
61
+
62
+ if __name__ == '__main__':
63
+ run()
model_svr.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6c9b58639df04b184e8d9acc8a1dcd31d6f6e307e6358589293cc38facaf2dc7
3
+ size 1579208
predict.py ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import numpy as np
3
+ import pickle
4
+ import json
5
+ import streamlit as st
6
+ with open('model_svr.pkl', 'rb') as file_6:
7
+ model = pickle.load(file_6)
8
+
9
+ with st.form("my_form"):
10
+ st.write("Inside the form")
11
+ nama = st.text_input('masukan nama player',value='nama', help= 'disini masukan nama player')
12
+ age = st.number_input('masukan usia player', min_value=15, max_value=100)
13
+ height = st.slider('Height', 50,250,170)
14
+ weight = st.slider('Weight', 50,100,170)
15
+ price = st.number_input('Price', 0,1000000,10000)
16
+ st.write('-'*50)
17
+ attack = st.selectbox('Attacking Work Rate', ['Low', 'Medium', 'High'], index=1)
18
+ defense = st.radio('Defensive Work Rate', ['Low', 'Medium', 'High'], index=1)
19
+ st.markdown('---')
20
+ pace = st.number_input('PaceTotal', 0,100,100)
21
+ shooting = st.number_input('ShootingTotal', 0,100,100)
22
+ passing = st.number_input('PassingTotal', 0,100,100)
23
+ dribbling = st.number_input('DribblingTotal', 0,100,100)
24
+ defending = st.number_input('DefendingTotal', 0,100,100)
25
+ physicality = st.number_input('PhysicalityTotal', 0,100,100)
26
+
27
+ # Every form must have a submit button.
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': shooting,
42
+ 'PassingTotal': passing,
43
+ 'DribblingTotal': dribbling,
44
+ 'DefendingTotal': defending,
45
+ 'PhysicalityTotal': physicality
46
+ }
47
+
48
+ data_inf = pd.DataFrame([data_inf])
49
+ data_inf
50
+
51
+ if submitted:
52
+ result= model.predict(data_inf)
53
+ st.write(f'## Player Rating: {round(result[0])}')
54
+ st.balloons()
55
+ st.snow()
56
+
57
+ if __name__ =='__main__':
58
+ data_inf()
requirements.txt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ streamlit
2
+ pandas
3
+ seaborn
4
+ matplotlib
5
+ numpy
6
+ scikit-learn==1.3.0
7
+ plotly