{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "gbg_and_odds_this_year = pd.read_csv('Source/Data/gbg_and_odds_this_year.csv')\n", "results = pd.read_csv('Source/Data/results.csv')\n", "\n", "from Source.Predict.predict import predict" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "import pickle as pkl\n", "with open('Source/Pickles/team_abbreviation_to_name.pkl', 'rb') as f:\n", " team_abbreviation_to_name = pkl.load(f)" ] }, { "cell_type": "code", "execution_count": 4, "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "100%|██████████| 32/32 [00:04<00:00, 6.79it/s]\n" ] } ], "source": [ "from tqdm import tqdm\n", "predictions = {}\n", "for game_id,home,away,season,week,total in tqdm(gbg_and_odds_this_year[['game_id','home_team','away_team','Season','GP','Total Score Close']].values):\n", " if week!=1:\n", " predictions[game_id] = predict(home,away,season,week,total)" ] }, { "cell_type": "code", "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "{'winners_correct': '5', 'winners_incorrect': '11', 'over_unders_correct': '7', 'over_unders_incorrect': '9'}\n" ] } ], "source": [ "predictions_df = pd.DataFrame(predictions).T\n", "predictions_df['predicted_winner'] = [i['Winner'][0] if type(i['Winner'])==list else None for i in predictions_df[1]]\n", "predictions_df['predicted_winner'] = predictions_df['predicted_winner'].map(team_abbreviation_to_name)\n", "predictions_df['predicted_over_under'] = [i['Over/Under'][0] if type(i['Over/Under'])==list else None for i in predictions_df[2]]\n", "predictions_df = predictions_df.merge(results, left_index=True, right_on='game_id').merge(gbg_and_odds_this_year[['game_id','Total Score Close']]).dropna(subset=['predicted_winner'])\n", "predictions_df['over_under'] = ['Over' if t>tsc else 'Under' if t