import gradio as gr import joblib import pandas as pd import numpy as np # Load the model and unique brand values model = joblib.load('model.joblib') # Define the prediction function def predict(p_yds, p_cmp,p_att,ints,cmp_pct,rate,p_adj_ypa,p_ypa,r_att,year_drafted) : y_pds = int(p_yds) p_cmp = int(p_cmp) p_att = int(p_att) ints = int(ints) cmp_pct = float(cmp_pct) rate = float(rate) p_adj_ypa = float(p_adj_ypa) p_ypa = float(p_ypa) r_att = int(r_att) year_drafted = int(year_drafted) input_data = pd.DataFrame({ 'p_yds': [p_yds], 'p_cmp': [p_cmp], 'p_att': [p_att], 'ints': [ints], 'cmp_pct': [cmp_pct], 'rate': [rate], 'p_adj_ypa': [p_adj_ypa], 'p_ypa': [p_ypa], 'r_att': [r_att], 'year_drafted': [year_drafted] }) # Perform the prediction prediction = model.predict(input_data) return str(prediction[0]) # Create the Gradio interface interface = gr.Interface( fn=predict, inputs=[ gr.Textbox(label="Pass Yards"), gr.Textbox(label="Pass Completions"), gr.Textbox(label="Pass Attempts"), gr.Textbox(label="Interceptions"), gr.Textbox(label="Completion Percentage"), gr.Textbox(label="Passer Rating"), gr.Textbox(label="Adjusted Yards per Attempt"), gr.Textbox(label="Pass Yards per Attempt"), gr.Textbox(label="Rush Attempts"), gr.Textbox(label="Year Drafted") ], outputs="textbox", title="passing to touchdown Predictor", description="Enter all informations." ) # Launch the app interface.launch()