{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "4826cf16", "metadata": {}, "outputs": [], "source": [ "import ipywidgets as widgets\n", "from IPython.display import display, HTML\n", "import pandas as pd\n", "from fastai.tabular.all import *\n", "import gradio as gr" ] }, { "cell_type": "code", "execution_count": 2, "id": "34fc127c", "metadata": {}, "outputs": [], "source": [ "path = Path()\n", "df = pd.read_csv(\"rookie_year.csv\")\n", "learn = load_learner(path/\"export.pkl\")\n", "columns = [\"Name\", \"G\", \"GS\", \"Cmp\", \"Att\", \"Yds\", \"Cmp%\", \"TD\", \"Int\", \"Y/G\", \"Sk\"]" ] }, { "cell_type": "code", "execution_count": 64, "id": "6e82eaae", "metadata": {}, "outputs": [], "source": [ "def predict(data):\n", " row = df[df[\"Name\"] == data]\n", " row = row.loc[:, ~df.columns.str.contains('^Unnamed')]\n", " if not len(row):\n", " print(\"ERROR: No QB in database with this name\")\n", " return \n", " pred_row, clas, probs = learn.predict(row.iloc[0])\n", " prediction = pred_row.decode()[\"Tier\"].item() \n", " return row[columns], prediction\n" ] }, { "cell_type": "code", "execution_count": 81, "id": "b9242a91", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Running on local URL: http://127.0.0.1:7866/\n", "\n", "To create a public link, set `share=True` in `launch()`.\n" ] }, { "data": { "text/html": [ "
" ], "text/plain": [ "