Spaces:
Sleeping
Sleeping
import pandas as pd | |
import numpy as np | |
import pickle | |
import json | |
import streamlit as st | |
with open('model_svr.pkl', 'rb') as file_6: | |
model = pickle.load(file_6) | |
def run(): | |
with st.form("my_form"): | |
st.write("Inside the form") | |
nama = st.text_input('masukan nama player',value='nama', help= 'disini masukan nama player') | |
age = st.number_input('masukan usia player', min_value=15, max_value=100) | |
height = st.slider('Height', 50,250,170) | |
weight = st.slider('Weight', 50,100,170) | |
price = st.number_input('Price', 0,1000000,10000) | |
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('PaceTotal', 0,100,100) | |
shooting = st.number_input('ShootingTotal', 0,100,100) | |
passing = st.number_input('PassingTotal', 0,100,100) | |
dribbling = st.number_input('DribblingTotal', 0,100,100) | |
defending = st.number_input('DefendingTotal', 0,100,100) | |
physicality = st.number_input('PhysicalityTotal', 0,100,100) | |
# Every form must have a submit button. | |
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': shooting, | |
'PassingTotal': passing, | |
'DribblingTotal': dribbling, | |
'DefendingTotal': defending, | |
'PhysicalityTotal': physicality | |
} | |
data_inf = pd.DataFrame([data_inf]) | |
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() |