milestone2daffa / prediksi.py
shirokuniku's picture
Upload 6 files
a0ae618 verified
# Import libraries
import pickle
import json
import pandas as pd
import numpy as np
import streamlit as st
with open('best_estimator.pkl', 'rb') as file_1:
best_estimator = pickle.load(file_1)
def run():
with st.form(key = 'NBA Player Return Form'):
Teamid = st.number_input('TEAM_ID', min_value=0, max_value=9999999999, value = 0, placeholder="Type a number...", help='Nomor Team')
Seasonid = st.number_input('SEASON_ID', min_value=0, max_value=99999,value=0, placeholder="Type a number", help='Nomor Season')
Conference = st.text_input('Name of Conference', value= 'West')
Team = st.text_input('Name of Team', value= 'Phoenix')
Game = st.number_input('Number of Games', min_value=0, value = None, placeholder="Type a number...", help='Berapa Game Dalam Season')
Win = st.number_input('Number of Win', min_value=0, value = None, placeholder="Type a number...", help='Berapa Win Dalam Season')
Loss = st.number_input('Number of Loss', min_value=0, value = None, placeholder="Type a number...", help='Berapa Loss Dalam Season')
WinPercentage = st.number_input('Win %', min_value=0.01, value = None, placeholder="Type a number...", help='Berapa Win %')
submitted = st.form_submit_button('Predict')
df_inf = {
'TEAM_ID': Teamid,
'SEASON_ID': Seasonid,
'CONFERENCE': Conference,
'TEAM': Team,
'G': Game,
'W': Win,
'L': Loss,
'W_PCT': WinPercentage,
}
df_inf = pd.DataFrame([df_inf])
if submitted:
pred = best_estimator.predict(df_inf)
if pred == 1:
st.write('Will Return')
else:
st.write('Will not Return')
if __name__ == '__main__':
run()