File size: 1,887 Bytes
58f46f5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import streamlit as st
import pandas as pd
import numpy as np
import pickle
with open('model_svr.pkl', 'rb') as file_6:
  model = pickle.load(file_6)

def run():
    with st.form("my_form"):
        
        nama = st.text_input('masukan nama player', value='nama')
        age = st.number_input('masukan usia player', min_value=15, max_value= 40, value=20)
        height = st.slider('Height',50, 250, 170)
        weight = st.number_input('Weight',50,100,70)
        price = st.number_input('Price',0,1000000,10000, help="Harga Pemain dalam euro " )
        # Every form must have a submit button.
        st.write('-'*50)
        attack = st.selectbox('Attacking Work Rate', {'Low','Medium','High'},index=1)
        defense = st.radio('Defensive Work Rate', {'Low','Medium','High'},index=1)
        st.markdown('---')

        pace  = st.number_input('Pace',0,100,50)
        shoot  = st.number_input('Shoot',0,100,50)
        passing = st.number_input('Passing',0,100,50)
        dribble = st.number_input('Dribble',0,100,50)
        defend = st.number_input('Defend',0,100,50)
        physicality = st.number_input('Physicality',0,100,50)
        submitted = st.form_submit_button("Submit")

    st.write("Outside the form")

    data_inf = {
        'Name': nama,
        'Age' : age,
        'Height' : height,
        'Weight' : weight,
        'Price' : price,
        'AttackingWorkRate': attack,
        'DefensiveWorkRate': defense,
        'PaceTotal': pace,
        'ShootingTotal': shoot,
        'PassingTotal': passing,
        'DribblingTotal': dribble,
        'DefendingTotal': defend,
        'PhysicalityTotal': physicality
    }

    data_inf = pd.DataFrame([data_inf])

    if submitted:
        result= model.predict(data_inf)
        st.write(f'## Player Rating: {round(result[0])}')
        st.balloons()
        st.snow()

if __name__ == '__main__':
    run()