tft_regression / app.py
Hegyes's picture
Create app.py
64f2b6e
import gradio as gr
import pickle
import numpy as np
def make_prediction(placement, LargestTrait, MaxTraitCount, Itemcount, Fivecost, Fourcost, Threecost, Twocost, Onecost):
with open("modelforweb.pkl", "rb") as f:
clf = pickle.load(f)
preds = clf.predict([[placement, LargestTrait, MaxTraitCount, Itemcount, Fivecost, Fourcost, Threecost, Twocost, Onecost]])
pred = np.round(preds)
return pred
#Create the input component for Gradio since we are expecting 4 inputs
placement_input = gr.Number(label = "Enter your placement")
LargestTrait_input = gr.Number(label= "Enter your largest active trait number")
MaxTraitCount_input = gr.Number(label = "Enter your all active trait sum")
Itemcount_input = gr.Number(label = "Enter your items number")
Fivecost_input = gr.Number(label = "Enter your five cost champs number")
Fourcost_input = gr.Number(label= "Enter your four cost champs number")
Threecost_input = gr.Number(label = "Enter your three cost champs number")
Twocost_input = gr.Number(label = "Enter your two cost champs number")
Onecost_input = gr.Number(label = "Enter your one cost champs number")
# We create the output
output = gr.Number(label = "Predicted level")
app = gr.Interface(fn = make_prediction, inputs=[placement_input, LargestTrait_input, MaxTraitCount_input, Itemcount_input, Fivecost_input, Fourcost_input, Threecost_input, Twocost_input, Onecost_input], outputs=output)
app.launch()