darly9991 commited on
Commit
ccf3253
·
verified ·
1 Parent(s): ded8458

Upload 11 files

Browse files
.gitattributes CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ ball.jpg filter=lfs diff=lfs merge=lfs -text
Machine_Learning_Problem_Framing_HCK_015.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
ball.jpg ADDED

Git LFS Details

  • SHA256: bcd5a99f56a686dfabbd316d07c71f9c62b84cb1d2bce28450417ab539323f74
  • Pointer size: 132 Bytes
  • Size of remote file: 1.11 MB
eda.py ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ def run():
9
+ #membuat judul
10
+ st.title('FIFA 2022 Player Rating Prediction')
11
+
12
+ #membuat sub header
13
+ st.subheader('EDA untuk Analisa Dataset FIFA 2022')
14
+
15
+ #tambahkan gambar
16
+ image = Image.open('ball.jpg')
17
+ st.image(image, caption = 'FIFA 2022')
18
+
19
+ #menambahkan deskripsi
20
+ st.write('Page ini dibuat oleh Hana')
21
+
22
+ #font size
23
+ #font terbesar
24
+ st.write('# Halo')
25
+ st.write('## Halo')
26
+ #bold
27
+ st.write('**Tes**')
28
+ #italic
29
+ st.write('*Tes*')
30
+
31
+ #mmebuat batas dengan garis lurus
32
+ st.markdown('---')
33
+
34
+ #show dataframe
35
+ data = pd.read_csv('https://raw.githubusercontent.com/FTDS-learning-materials/phase-1/master/w1/P1W1D1PM%20-%20Machine%20Learning%20Problem%20Framing.csv')
36
+ st.dataframe(data)
37
+
38
+ #membuat bar plot
39
+ st.write('#### Plot AttackingWorkRate')
40
+ fig = plt.figure(figsize=(15,5))
41
+ sns.countplot(x='AttackingWorkRate', data = data)
42
+ st.pyplot(fig)
43
+
44
+ #membuat histogram
45
+ st.write('#### Histogram of Rating')
46
+ fig = plt.figure(figsize=(15,5))
47
+ sns.histplot(data['Overall'], bins = 30, kde = True)
48
+ st.pyplot(fig)
49
+
50
+ #membuat histogram berdasarkan input user
51
+ st.write('#### Histogram berdasarkan input user')
52
+ option = st.selectbox('Pilih column : ', ('Age', 'Weight', 'Height', 'ShootingTotal'))
53
+ fig = plt.figure(figsize=(15,5))
54
+ sns.histplot(data[option], bins = 30, kde = True)
55
+ st.pyplot(fig)
56
+
57
+ #membuat plotly plot
58
+ #membandingkan ratingpemain bola dengan proce nya
59
+ st.write('#### Plotly plot - ValueEUR vs Overall')
60
+ fig = px.scatter(data, x = 'ValueEUR', y = 'Overall', hover_data = ['Name', 'Age'])
61
+ st.plotly_chart(fig)
62
+
63
+ if __name__ == '__main__':
64
+ run()
encoder.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:9bf2d42bd9157cc7b8a167c08eee1ae3f0f5c3e7cf6e0eef2e81d3dc269ccd7a
3
+ size 642
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,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import eda
3
+ import prediction
4
+
5
+ page = st.sidebar.selectbox('Pilih halaman ', ('EDA', 'Prediction'))
6
+
7
+ if page == 'EDA':
8
+ eda.run()
9
+ else:
10
+ prediction.run()
model_lin_reg.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b4f561538a344846514523e24b29c98c7cfe21d6eecd673eaf90b18c2c34371a
3
+ size 601
prediction.py ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import numpy as np
4
+ import pickle
5
+ import json
6
+
7
+ #Load All files
8
+ #Load model
9
+
10
+ with open('list_cat_cols.txt', 'r') as file_1:
11
+ list_cat_col = json.load(file_1)
12
+
13
+ with open('list_num_cols.txt', 'r') as file_2:
14
+ list_num_col = json.load(file_2)
15
+
16
+ with open('encoder.pkl', 'rb') as file_3:
17
+ model_encoder = pickle.load(file_3)
18
+
19
+ with open('scaler.pkl', 'rb') as file_4:
20
+ model_scaler = pickle.load(file_4)
21
+
22
+ with open('model_lin_reg.pkl', 'rb') as file_5:
23
+ model_lin_reg = pickle.load(file_5)
24
+
25
+ def run():
26
+ with st.form('form_fifa_2022'):
27
+ #nama, value untuk default value
28
+ name = st.text_input('Name', value = ' ')
29
+
30
+ #age, min_value untuk minimum nilai yang bisa diisi, max_value maksimum nilai yang bisa diisi
31
+ age = st.number_input('Age', value = 25, min_value = 15, max_value = 60, help = 'isi dengan usia pemain')
32
+
33
+ #height
34
+ height = st.number_input('Height', value = 170, min_value = 100, help = 'in cm')
35
+
36
+ weight = st.slider('Weight', value = 70, min_value = 50, max_value = 150)
37
+
38
+ price = st.number_input('Price', value = 0)
39
+
40
+ st.markdown('---')
41
+ #index untuk default value di selctbox/radio button
42
+ attacking_work_rate = st.selectbox('Attacking Work Rate', ('Low', 'Medium', 'High'), index = 1)
43
+
44
+ defensive_work_rate = st.radio('Defensive Work Rate', ('Low', 'Medium', 'High'), index = 1)
45
+
46
+ pace = st.number_input('Pace', min_value = 0, max_value = 100, value = 50)
47
+ shooting = st.number_input('Shooting Score', min_value = 0, max_value = 100, value = 50)
48
+ passing = st.number_input('Passing Score', min_value = 0, max_value = 100, value = 50)
49
+ dribbling = st.number_input('Dribbling Score', min_value = 0, max_value = 100, value = 50)
50
+ defending = st.number_input('Defending Score', min_value = 0, max_value = 100, value = 50)
51
+ physicality = st.number_input('Pysicality Score', min_value = 0, max_value = 100, value = 50)
52
+
53
+ #bikin submit button form
54
+ submitted = st.form_submit_button('Predict')
55
+
56
+ data_inf = {
57
+ 'Name' : name,
58
+ 'Age' : age,
59
+ 'Height' : height,
60
+ 'Weight' : weight,
61
+ 'Price' : price,
62
+ 'AttackingWorkRate' : attacking_work_rate,
63
+ 'DefensiveWorkRate' : defensive_work_rate,
64
+ 'PaceTotal' : pace,
65
+ 'ShootingTotal' : shooting,
66
+ 'PassingTotal' : passing,
67
+ 'DribblingTotal' : dribbling,
68
+ 'DefendingTotal' : defending,
69
+ 'PhysicalityTotal' : physicality
70
+ }
71
+ data_inf = pd.DataFrame([data_inf])
72
+ st.dataframe(data_inf)
73
+
74
+ if submitted:
75
+ #split between numerical and categorical columns
76
+ data_inf_num = data_inf[list_num_col]
77
+ data_inf_cat = data_inf[list_cat_col]
78
+
79
+ #feature scaling and encoding
80
+
81
+ data_inf_num_scaled = model_scaler.transform(data_inf_num)
82
+ data_inf_cat_encoded = model_encoder.transform(data_inf_cat)
83
+ data_inf_final = np.concatenate([data_inf_num_scaled, data_inf_cat_encoded], axis = 1)
84
+
85
+ #predict using linear reg model
86
+
87
+ y_pred_inf = model_lin_reg.predict(data_inf_final)
88
+
89
+ st.write('## Rating : ', str(int(y_pred_inf)))
90
+
91
+
92
+ if __name__ == '__main__':
93
+ run()
94
+
95
+
requirements.txt ADDED
File without changes
scaler.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:db0a744773e3ee62d3825281ff187f3ad1bb7bb8cd96d8ae82bcbd90431dea7d
3
+ size 1102