File size: 1,695 Bytes
01e9ada
 
53c399e
01e9ada
 
 
 
a173bbd
01e9ada
 
afa3b6f
 
 
 
 
 
 
 
 
 
 
01e9ada
2d6c894
 
 
 
 
 
 
 
 
 
 
 
01e9ada
 
afa3b6f
01e9ada
2d6c894
01e9ada
 
 
 
5ad27ee
afa3b6f
df20c8a
 
 
afa3b6f
df20c8a
afa3b6f
 
df20c8a
afa3b6f
01e9ada
264ef3d
df20c8a
afa3b6f
01e9ada
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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()