casheu commited on
Commit
bc9b26f
1 Parent(s): 54b29ac
Files changed (5) hide show
  1. eda.py +66 -0
  2. main.py +10 -0
  3. model_lin_reg.pkl +3 -0
  4. pipeline.pkl +3 -0
  5. prediction.py +65 -0
eda.py ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import seaborn as sns
4
+ import matplotlib.pyplot as plt
5
+ import numpy as np
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
+ # Title
15
+ st.title('House Price Prediction by Area Characteristics')
16
+
17
+ # Membuat Sub Header
18
+ st.subheader('EDA untuk Analisa Dataset FIFA 2022')
19
+
20
+ # Membuat Deskripsi
21
+ st.write('Page ini dibuat oleh *Danu Purnomo*')
22
+
23
+ # Menambahkan Gambar
24
+ #image = Image.open('soccer.jpg')
25
+ #st.image(image, caption='FIFA 2022')
26
+
27
+ # Membuat Garis Lurus
28
+ st.markdown('---')
29
+
30
+ # Magic Syntax
31
+ '''
32
+ Pada page kali ini, penulis akan melakukan eskplorasi sederhana.
33
+ Dataset yang digunakan adalah dataset FIFA 2022.
34
+ Dataset ini berasal dari web sofifa.com.
35
+ '''
36
+
37
+ # Show DataFrame
38
+ data = pd.read_csv('https://raw.githubusercontent.com/ardhiraka/FSDS_Guidelines/master/p1/v3/w1/P1W1D1PM%20-%20Machine%20Learning%20Problem%20Framing.csv')
39
+ st.dataframe(data)
40
+
41
+ # Membuat BarPlot
42
+ st.write('#### Plot AttackingWorkRate')
43
+ fig = plt.figure(figsize=(15, 5))
44
+ sns.countplot(x='AttackingWorkRate', data=data)
45
+ st.pyplot(fig)
46
+
47
+ # Membuat Histogram
48
+ st.write('#### Histogram of Rating')
49
+ fig = plt.figure(figsize=(15, 5))
50
+ sns.histplot(data['Overall'], bins=30, kde=True)
51
+ st.pyplot(fig)
52
+
53
+ # Membuat Histogram Berdasarkan Input User
54
+ st.write('#### Histogram berdasarkan Input User')
55
+ pilihan = st.selectbox('Pilih Column : ', ('Age', 'Weight', 'Height', 'ShootingTotal'))
56
+ fig = plt.figure(figsize=(15, 5))
57
+ sns.histplot(data[pilihan], bins=30, kde=True)
58
+ st.pyplot(fig)
59
+
60
+ # Membuat Plotly Plot
61
+ #st.write('#### Plotly Plot - ValueEUR dengan Overall')
62
+ #fig = px.scatter(data, x='ValueEUR', y='Overall', hover_data=['Name', 'Age'])
63
+ #st.plotly_chart(fig)
64
+
65
+ if __name__ == '__main__':
66
+ run()
main.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import eda
3
+ import prediction
4
+
5
+ navigation = st.sidebar.selectbox('Pages : ', ('Model EDA', 'Predict House Price'))
6
+
7
+ if navigation == 'Model 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:06f4c14e2ea824ccf574f7ee53e52f77dd218e83caa2b1d350f21d402526593f
3
+ size 632
pipeline.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:656494e15a705d39ee63dac0a8b2b97a4486efaa9b8d2359181297e4538b8a91
3
+ size 2101
prediction.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 numpy as np
8
+ import joblib
9
+ import json
10
+
11
+ # Load All Files
12
+ with open('model_lin_reg.pkl', 'rb') as file_1:
13
+ model_lin_reg = joblib.load(file_1)
14
+
15
+ with open('pipeline.pkl', 'rb') as file_2:
16
+ preprocessor = joblib.load(file_2)
17
+
18
+ def run():
19
+ # Membuat Form
20
+ with st.form(key='form_parameters'):
21
+ income = st.number_input('Average Income', min_value=0, max_value=60, value=25, step=1)
22
+ age = st.number_input('House Age', min_value=0, max_value=60, value=25, step=1)
23
+ rooms = st.number_input('Number of Rooms', min_value=50, max_value=150, value=70)
24
+ bedrooms = st.number_input('Number of Bedrooms', min_value=50, max_value=150, value=70)
25
+ population = st.number_input('Area Population', min_value=50, max_value=150, value=70)
26
+ # price = st.slider('Price', 0, 100000000, 0)
27
+ #price = st.number_input('Price', min_value=0, max_value=1000000000, value=0)
28
+ st.markdown('---')
29
+
30
+ #attacking_work_rate = st.selectbox('AttackingWorkrate', ('Low', 'Medium', 'High'), index=1)
31
+ #defensive_work_rate = st.selectbox('DefensiveWorkRate', ('Low', 'Medium', 'High'), index=1)
32
+ st.markdown('---')
33
+
34
+ #pace = st.number_input('Pace', min_value=0, max_value=100, value=50)
35
+ #shooting = st.number_input('Shooting', min_value=0, max_value=100, value=50)
36
+ #passing = st.number_input('Passing', min_value=0, max_value=100, value=50)
37
+ #dribbling = st.number_input('Dribbling', min_value=0, max_value=100, value=50)
38
+ #defending = st.number_input('Defending', min_value=0, max_value=100, value=50)
39
+ #physicality = st.number_input('Physicality', min_value=0, max_value=100, value=50)
40
+ st.markdown('---')
41
+
42
+ submitted = st.form_submit_button('Predict')
43
+
44
+ data_inf = {
45
+ 'Income': income,
46
+ 'Age': age,
47
+ 'Rooms': rooms,
48
+ 'Bedrooms': bedrooms,
49
+ 'Population': population
50
+ }
51
+
52
+ data_inf = pd.DataFrame([data_inf])
53
+ st.dataframe(data_inf)
54
+
55
+ if submitted:
56
+ # Feature Preprocessing
57
+ X_inf = preprocessor.transform(data_inf)
58
+
59
+ # Predict using Linear regression
60
+ y_pred_inf = model_lin_reg.predict(X_inf)
61
+
62
+ st.write('# House Price : ', str(int(y_pred_inf)))
63
+
64
+ if __name__ == '__main__':
65
+ run()