File size: 2,511 Bytes
cb96cf5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import os\n",
    "\n",
    "DATA_DIR = os.path.join(\"..\", \"data\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/var/folders/v8/0hd98b512cn3ms2rz146k7jw0000gn/T/ipykernel_46104/712369024.py:1: DtypeWarning: Columns (481,482,483) have mixed types. Specify dtype option on import or set low_memory=False.\n",
      "  games_df = pd.read_csv(os.path.join(DATA_DIR, \"AllSuperDetailedGames.csv\"))\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 377608 entries, 0 to 377607\n",
      "Columns: 487 entries, Unnamed: 0 to ChalkSeed\n",
      "dtypes: float64(347), int64(133), object(7)\n",
      "memory usage: 1.4+ GB\n"
     ]
    }
   ],
   "source": [
    "games_df = pd.read_csv(os.path.join(DATA_DIR, \"AllSuperDetailedGames.csv\"))\n",
    "games_df.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "# create baseline model that predicts the winner of the game only based on the team with the higher seed\n",
    "# and if the seed is the same, have it be the winning percentage that determines the winner. We will compare\n",
    "# our ML models to this one to decide if performance is actually good or not.\n",
    "\n",
    "def predict_baseline(row: pd.Series) -> int:\n",
    "    if row[\"ChalkSeed Team\"] > row[\"OppChalkSeed Opp\"]:\n",
    "        return 1\n",
    "    if row[\"Win mean reg\"] > row[\"OppWin mean reg\"]:\n",
    "        return 1\n",
    "    return 0\n",
    "\n",
    "games_df[\"BaselinePrediction\"] = games_df.apply(\n",
    "    lambda row: predict_baseline(row),\n",
    "    axis=1,\n",
    ")\n",
    "\n",
    "games_df[\"BaselinePrediction\"]"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}