Azrieldr
commited on
Commit
•
742e1ed
1
Parent(s):
be7a7ed
mt
Browse files- eda.py +21 -0
- import.py +20 -0
- list_cat_cols.txt +1 -0
- list_num_cols.txt +1 -0
- main.py +15 -0
- model_encoder.pkl +3 -0
- model_lin_reg.pkl +3 -0
- model_scaler.pkl +3 -0
- prediciton.py +75 -0
- requirement.txt +9 -0
- soccer.jpg +0 -0
eda.py
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
from PIL import Image
|
7 |
+
|
8 |
+
st.set_page_config(
|
9 |
+
page_title='FIFA 2022',
|
10 |
+
layout='wide',
|
11 |
+
initial_sidebar_state='expanded'
|
12 |
+
)
|
13 |
+
def run():
|
14 |
+
st.title('fifa 2022 player rating data analysis')
|
15 |
+
st.subheader('eda untuk analisa dataset')
|
16 |
+
|
17 |
+
image= Image.open('soccer.jpg')
|
18 |
+
st.image(image, caption='fifa 2022')
|
19 |
+
|
20 |
+
if __name__== '__main__':
|
21 |
+
run()
|
import.py
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import subprocess
|
3 |
+
|
4 |
+
def run_prediction():
|
5 |
+
result = subprocess.run(['python', 'prediction.py'], stdout=subprocess.PIPE)
|
6 |
+
return result.stdout.decode('utf-8')
|
7 |
+
|
8 |
+
def run_eda():
|
9 |
+
result = subprocess.run(['python', 'eda.py'], stdout=subprocess.PIPE)
|
10 |
+
return result.stdout.decode('utf-8')
|
11 |
+
|
12 |
+
pages = {
|
13 |
+
'Prediction': run_prediction,
|
14 |
+
'EDA': run_eda,
|
15 |
+
}
|
16 |
+
|
17 |
+
selected_page = st.sidebar.selectbox('Select a page', list(pages.keys()))
|
18 |
+
|
19 |
+
page_content = pages[selected_page]()
|
20 |
+
st.write(page_content)
|
list_cat_cols.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
["AttackingWorkRate", "DefensiveWorkRate"]
|
list_num_cols.txt
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
["Age", "Height", "Weight", "Price", "PaceTotal", "ShootingTotal", "PassingTotal", "DribblingTotal", "DefendingTotal", "PhysicalityTotal"]
|
main.py
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
from PIL import Image
|
7 |
+
import eda
|
8 |
+
import prediciton
|
9 |
+
|
10 |
+
navigation=st.sidebar.selectbox('Pilih Halaman:', ('EDA','Predict A player'))
|
11 |
+
|
12 |
+
if navigation== 'EDA':
|
13 |
+
eda.run()
|
14 |
+
else:
|
15 |
+
prediciton.run()
|
model_encoder.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:2240ea3c82dad58d6247c4654a4c46ab2c0f0ca495f01515a364924fbe2c9c3e
|
3 |
+
size 539
|
model_lin_reg.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:70087a6eef90d9e5071121722f1e174ce2138cd18db8ba5330a757e5150844e5
|
3 |
+
size 651
|
model_scaler.pkl
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:38558e0c33e6ab5e79b980f8c436f2bf761625562a30f7635281ee4aaa15fd11
|
3 |
+
size 1096
|
prediciton.py
ADDED
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import pickle
|
2 |
+
import streamlit as st
|
3 |
+
import json
|
4 |
+
import pandas as pd
|
5 |
+
import numpy as np
|
6 |
+
import sklearn
|
7 |
+
# Load All Files
|
8 |
+
def run():
|
9 |
+
with st.form(key='formfifa2022'):
|
10 |
+
name =st.text_input('Name', value='')
|
11 |
+
age =st.number_input('Age', min_value=16, max_value=60,help='usia pemain')
|
12 |
+
weight=st.number_input('Weight', min_value=50, max_value=150, value=70)
|
13 |
+
height=st.slider('Height', 50, 250, 170)
|
14 |
+
price=st.number_input('Price', min_value=0, max_value=1000000000, value=0)
|
15 |
+
st.markdown('---')
|
16 |
+
attacking_work_rate = st.selectbox('AttackingWorkRate',('Low','Medium','High'), index=1)
|
17 |
+
defensive_work_rate = st.selectbox('DefensiveWorkRate',('Low','Medium','High'), index=1)
|
18 |
+
st.markdown('---')
|
19 |
+
pace =st.number_input('Pace', min_value=0, max_value=100, value=50)
|
20 |
+
defending =st.number_input('Defending', min_value=0, max_value=100, value=50)
|
21 |
+
physicality=st.number_input('Physicality', min_value=0, max_value=100, value=50)
|
22 |
+
Passing =st.number_input('Passing', min_value=0, max_value=100, value=50)
|
23 |
+
Shooting =st.number_input(' Shooting ', min_value=0, max_value=100, value=50)
|
24 |
+
Dribbling =st.number_input('Dribbling', min_value=0, max_value=100, value=50)
|
25 |
+
submitted =st.form_submit_button('Predict')
|
26 |
+
|
27 |
+
with open('model_lin_reg.pkl', 'rb') as file_1:
|
28 |
+
model_lin_reg = pickle.load(file_1)
|
29 |
+
|
30 |
+
with open('model_scaler.pkl', 'rb') as file_2:
|
31 |
+
model_scaler = pickle.load(file_2)
|
32 |
+
|
33 |
+
with open('model_encoder.pkl','rb') as file_3:
|
34 |
+
model_encoder = pickle.load(file_3)
|
35 |
+
|
36 |
+
with open('list_num_cols.txt', 'r') as file_4:
|
37 |
+
list_num_cols = json.load(file_4)
|
38 |
+
|
39 |
+
with open('list_cat_cols.txt', 'r') as file_5:
|
40 |
+
list_cat_cols = json.load(file_5)
|
41 |
+
|
42 |
+
data_inf = {
|
43 |
+
'Name': name,
|
44 |
+
'Age':age,
|
45 |
+
'Height': height,
|
46 |
+
'Weight': weight,
|
47 |
+
'Price':price,
|
48 |
+
'AttackingWorkRate': attacking_work_rate,
|
49 |
+
'DefensiveWorkRate': defensive_work_rate,
|
50 |
+
'PaceTotal': pace,
|
51 |
+
'ShootingTotal': Shooting,
|
52 |
+
'PassingTotal': Passing,
|
53 |
+
'DribblingTotal': Dribbling,
|
54 |
+
'DefendingTotal': defending,
|
55 |
+
'PhysicalityTotal': physicality
|
56 |
+
}
|
57 |
+
|
58 |
+
data_inf = pd.DataFrame([data_inf])
|
59 |
+
data_inf
|
60 |
+
|
61 |
+
data_inf_num = data_inf[list_num_cols]
|
62 |
+
data_inf_cat = data_inf[list_cat_cols]
|
63 |
+
data_inf_num
|
64 |
+
|
65 |
+
# Feature Scaling and Feature Encoding
|
66 |
+
|
67 |
+
data_inf_num_scaled = model_scaler.transform(data_inf_num)
|
68 |
+
data_inf_cat_encoded = model_encoder.transform(data_inf_cat)
|
69 |
+
data_inf_final = np.concatenate([data_inf_num_scaled, data_inf_cat_encoded], axis=1)
|
70 |
+
|
71 |
+
y_pred_inf = model_lin_reg.predict(data_inf_final)
|
72 |
+
print('y_pred_inf')
|
73 |
+
|
74 |
+
if __name__== '__main__':
|
75 |
+
run()
|
requirement.txt
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
matplotlib
|
2 |
+
json
|
3 |
+
pickle
|
4 |
+
pandas
|
5 |
+
numpy
|
6 |
+
plotly
|
7 |
+
seaborn
|
8 |
+
scikit-learn==1.2.1
|
9 |
+
PIL
|
soccer.jpg
ADDED
![]() |