Spaces:
Runtime error
Runtime error
Matthew Rice
commited on
Commit
·
e71753a
1
Parent(s):
c6dd398
Remove more unecessary files. Restore Data Preprocess
Browse files- 01_Data_Preprocess.ipynb +0 -0
- 3_Demo.ipynb +9 -7
- app.py +31 -0
- predict.py +0 -0
- train.py +0 -0
01_Data_Preprocess.ipynb
ADDED
The diff for this file is too large to render.
See raw diff
|
|
3_Demo.ipynb
CHANGED
@@ -23,18 +23,18 @@
|
|
23 |
"source": [
|
24 |
"path = Path()\n",
|
25 |
"df = pd.read_csv(\"rookie_year.csv\")\n",
|
26 |
-
"learn = load_learner(path/\"export.pkl\")"
|
|
|
27 |
]
|
28 |
},
|
29 |
{
|
30 |
"cell_type": "code",
|
31 |
"execution_count": 64,
|
32 |
-
"id": "
|
33 |
"metadata": {},
|
34 |
"outputs": [],
|
35 |
"source": [
|
36 |
"def predict(data):\n",
|
37 |
-
" columns = [\"Name\", \"G\", \"GS\", \"Cmp\", \"Att\", \"Yds\", \"Cmp%\", \"TD\", \"Int\", \"Y/G\", \"Sk\"]\n",
|
38 |
" row = df[df[\"Name\"] == data]\n",
|
39 |
" row = row.loc[:, ~df.columns.str.contains('^Unnamed')]\n",
|
40 |
" if not len(row):\n",
|
@@ -48,7 +48,7 @@
|
|
48 |
{
|
49 |
"cell_type": "code",
|
50 |
"execution_count": 81,
|
51 |
-
"id": "
|
52 |
"metadata": {},
|
53 |
"outputs": [
|
54 |
{
|
@@ -92,6 +92,7 @@
|
|
92 |
" ],\n",
|
93 |
" title=\"Rookie QB Career Prediction (Name)\",\n",
|
94 |
" description=\"Given Name of QB who has played in the NFL, predict their career tier. Uses data from https:\\/\\/www.pro-football-reference.com. Tiers based on PFR Approximate Value.\",\n",
|
|
|
95 |
" examples=[\"Tom Brady\", \"Joe Burrow\", \"Trevor Lawrence\"]\n",
|
96 |
" )\n",
|
97 |
"\n",
|
@@ -101,7 +102,7 @@
|
|
101 |
{
|
102 |
"cell_type": "code",
|
103 |
"execution_count": 72,
|
104 |
-
"id": "
|
105 |
"metadata": {},
|
106 |
"outputs": [],
|
107 |
"source": [
|
@@ -116,7 +117,7 @@
|
|
116 |
{
|
117 |
"cell_type": "code",
|
118 |
"execution_count": 80,
|
119 |
-
"id": "
|
120 |
"metadata": {},
|
121 |
"outputs": [
|
122 |
{
|
@@ -157,6 +158,7 @@
|
|
157 |
" outputs=gr.Textbox(label=\"Prediction\"),\n",
|
158 |
" title=\"Rookie QB Career Prediction (Stats)\",\n",
|
159 |
" description=\"Given stats of a presumed rookie QB, predict their career tier. Uses data from https:\\/\\/www.pro-football-reference.com. Tiers based on PFR Approximate Value.\"\n",
|
|
|
160 |
" )\n",
|
161 |
"\n",
|
162 |
"demo2.launch()"
|
@@ -165,7 +167,7 @@
|
|
165 |
{
|
166 |
"cell_type": "code",
|
167 |
"execution_count": null,
|
168 |
-
"id": "
|
169 |
"metadata": {},
|
170 |
"outputs": [],
|
171 |
"source": []
|
|
|
23 |
"source": [
|
24 |
"path = Path()\n",
|
25 |
"df = pd.read_csv(\"rookie_year.csv\")\n",
|
26 |
+
"learn = load_learner(path/\"export.pkl\")\n",
|
27 |
+
"columns = [\"Name\", \"G\", \"GS\", \"Cmp\", \"Att\", \"Yds\", \"Cmp%\", \"TD\", \"Int\", \"Y/G\", \"Sk\"]"
|
28 |
]
|
29 |
},
|
30 |
{
|
31 |
"cell_type": "code",
|
32 |
"execution_count": 64,
|
33 |
+
"id": "6e82eaae",
|
34 |
"metadata": {},
|
35 |
"outputs": [],
|
36 |
"source": [
|
37 |
"def predict(data):\n",
|
|
|
38 |
" row = df[df[\"Name\"] == data]\n",
|
39 |
" row = row.loc[:, ~df.columns.str.contains('^Unnamed')]\n",
|
40 |
" if not len(row):\n",
|
|
|
48 |
{
|
49 |
"cell_type": "code",
|
50 |
"execution_count": 81,
|
51 |
+
"id": "b9242a91",
|
52 |
"metadata": {},
|
53 |
"outputs": [
|
54 |
{
|
|
|
92 |
" ],\n",
|
93 |
" title=\"Rookie QB Career Prediction (Name)\",\n",
|
94 |
" description=\"Given Name of QB who has played in the NFL, predict their career tier. Uses data from https:\\/\\/www.pro-football-reference.com. Tiers based on PFR Approximate Value.\",\n",
|
95 |
+
" article=\"See more details at https://github.com/mhrice/Rookie-QB-Predictions\"\n",
|
96 |
" examples=[\"Tom Brady\", \"Joe Burrow\", \"Trevor Lawrence\"]\n",
|
97 |
" )\n",
|
98 |
"\n",
|
|
|
102 |
{
|
103 |
"cell_type": "code",
|
104 |
"execution_count": 72,
|
105 |
+
"id": "46d819f7",
|
106 |
"metadata": {},
|
107 |
"outputs": [],
|
108 |
"source": [
|
|
|
117 |
{
|
118 |
"cell_type": "code",
|
119 |
"execution_count": 80,
|
120 |
+
"id": "dd0aae3a",
|
121 |
"metadata": {},
|
122 |
"outputs": [
|
123 |
{
|
|
|
158 |
" outputs=gr.Textbox(label=\"Prediction\"),\n",
|
159 |
" title=\"Rookie QB Career Prediction (Stats)\",\n",
|
160 |
" description=\"Given stats of a presumed rookie QB, predict their career tier. Uses data from https:\\/\\/www.pro-football-reference.com. Tiers based on PFR Approximate Value.\"\n",
|
161 |
+
" article=\"See more details at https://github.com/mhrice/Rookie-QB-Predictions\"\n",
|
162 |
" )\n",
|
163 |
"\n",
|
164 |
"demo2.launch()"
|
|
|
167 |
{
|
168 |
"cell_type": "code",
|
169 |
"execution_count": null,
|
170 |
+
"id": "5c7e8cbe",
|
171 |
"metadata": {},
|
172 |
"outputs": [],
|
173 |
"source": []
|
app.py
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from fastai.tabular.all import *
|
2 |
+
import gradio as gr
|
3 |
+
|
4 |
+
path = Path()
|
5 |
+
df = pd.read_csv("rookie_year.csv")
|
6 |
+
learn = load_learner(path/"export.pkl")
|
7 |
+
columns = ["Name", "G", "GS", "Cmp", "Att", "Yds", "Cmp%", "TD", "Int", "Y/G", "Sk"]
|
8 |
+
|
9 |
+
def predict(data):
|
10 |
+
row = df[df["Name"] == data]
|
11 |
+
row = row.loc[:, ~df.columns.str.contains('^Unnamed')]
|
12 |
+
if not len(row):
|
13 |
+
print("ERROR: No QB in database with this name")
|
14 |
+
return
|
15 |
+
pred_row, clas, probs = learn.predict(row.iloc[0])
|
16 |
+
prediction = pred_row.decode()["Tier"].item()
|
17 |
+
return row[columns], prediction
|
18 |
+
|
19 |
+
demo = gr.Interface(fn=predict,
|
20 |
+
inputs="text",
|
21 |
+
outputs=[
|
22 |
+
gr.Dataframe(row_count=1, col_count=11, headers=columns, label="Rookie Year Stats"),
|
23 |
+
gr.Textbox(label="Prediction")
|
24 |
+
],
|
25 |
+
title="Rookie QB Career Prediction (Name)",
|
26 |
+
description="Given Name of QB who has played in the NFL, predict their career tier. Uses data from https:\/\/www.pro-football-reference.com. Tiers based on PFR Approximate Value.",
|
27 |
+
article="See more details at https://github.com/mhrice/Rookie-QB-Predictions"
|
28 |
+
examples=["Tom Brady", "Joe Burrow", "Trevor Lawrence"]
|
29 |
+
)
|
30 |
+
|
31 |
+
demo.launch()
|
predict.py
DELETED
File without changes
|
train.py
DELETED
File without changes
|