Agent_Analysis / app.py
OatNapat's picture
Update app.py
5959ae3
import joblib
import pandas as pd
import streamlit as st
model = joblib.load('model (1).joblib')
unique_values = joblib.load('unique_values (1).joblib')
unique_map = unique_values["map"]
unique_player= unique_values["player"]
def main():
st.title("agent Analysis")
with st.form("questionaire"):
rating= st.slider("Rating in game", min_value=0.01, max_value=2.5)
acs= st.slider("Average Combat Score", min_value=35, max_value=450)
kill = st.slider("Number of Kill Accumulated", min_value=0, max_value=50)
death = st.slider("Number of Death Accumulated", min_value=0, max_value=40)
assist = st.slider("Number of Assist Accumulated", min_value=0, max_value=40)
kast = st.slider("Percentage of Kill, Assist, Survive, Trade", min_value=10, max_value=100)
adr = st.slider("Average damage dealt during a game", min_value=20, max_value=300)
hs = st.slider("Headshot percentage", min_value=0, max_value=75)
fk = st.slider("First kill count", min_value=0, max_value=15)
fd = st.slider("First death count", min_value=0, max_value=15)
map = st.selectbox("Name of map played", unique_map)
player = st.selectbox("player", unique_player)
clicked = st.form_submit_button("Predict agent")
if clicked:
result=model.predict(pd.DataFrame({"map": [map],
"player": [player],
"rating": [rating],
"acs": [acs],
"kill": [kill],
"death": [death],
"assist": [assist],
"kast%": [kast],
"adr": [adr],
"hs%": [hs],
"fk": [fk],
"fd": [fd]}))
if result[0] == 18:
result = 'sova'
elif result[0] == 10:
result = 'killjoy'
elif result[0] == 8:
result = 'jett'
elif result[0] == 9:
result = 'kayo'
elif result[0] == 12:
result = 'omen'
elif result[0] == 19:
result = 'viper'
elif result[0] == 17:
result = 'skye'
elif result[0] == 7:
result = 'harbor'
elif result[0] == 5:
result = 'fade'
elif result[0] == 0:
result = 'astra'
elif result[0] == 1:
result = 'breach'
elif result[0] == 14:
result = 'raze'
elif result[0] == 13:
result = 'phoenix'
elif result[0] == 20:
result = 'yoru'
elif result[0] == 4:
result = 'cypher'
elif result[0] == 16:
result = 'sage'
elif result[0] == 2:
result = 'brimstone'
elif result[0] == 11:
result = 'neon'
elif result[0] == 6:
result = 'gekko'
elif result[0] == 15:
result = 'reyna'
elif result[0] == 3:
result = 'chamber'
st.success('The predicted agent is {}'.format(result))
if __name__=='__main__':
main()