This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import cfbd | |
| import matplotlib.pyplot as plt | |
| from matplotlib.offsetbox import OffsetImage, AnnotationBbox | |
| import matplotlib.cbook as cbook | |
| import matplotlib.image as image | |
| import pandas as pd | |
| from PIL import Image |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import cfbd | |
| import numpy as np | |
| import pandas as pd | |
| configuration = cfbd.Configuration() | |
| configuration.api_key['Authorization'] = 'YOUR_API_KEY' | |
| configuration.api_key_prefix['Authorization'] = 'Bearer' | |
| api_config = cfbd.ApiClient(configuration) | |
| games_api = cfbd.GamesApi(api_config) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class PermutationImportance(): | |
| def __init__(self, learn:Learner, df=None, bs=None): | |
| "Initialize with a test dataframe, a learner, and a metric" | |
| self.learn = learn | |
| self.df = df | |
| bs = bs if bs is not None else learn.dls.bs | |
| if self.df is not None: | |
| self.dl = learn.dls.test_dl(self.df, bs=bs) | |
| else: | |
| self.dl = learn.dls[1] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import cfbd | |
| import matplotlib.pyplot as plt | |
| from matplotlib.offsetbox import OffsetImage, AnnotationBbox | |
| import pandas as pd | |
| # Grab some stats from the CFBD API | |
| stats = cfbd.StatsApi().get_advanced_team_season_stats(year=2020) | |
| df = pd.DataFrame.from_records([dict(team=s.team, o_line_yards=s.offense.line_yards, d_line_yards=s.defense.line_yards) for s in stats]) | |
| # Need to grab team ids |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import cfbd | |
| import pandas as pd | |
| games = cfbd.GamesApi().get_team_game_stats(year=2020, week=1) | |
| stats = [] | |
| for g in games: | |
| for t in g.teams: | |
| for s in t.stats: | |
| stats.append(dict(game_id=g.id, team=t.school, conference=t.conference, category=s.category, stat=s.stat)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import numpy as np | |
| import pandas as pd | |
| import requests | |
| pd.set_option('display.float_format', lambda x: '%.8f' % x) | |
| season = 2 | |
| day = 3 | |
| response = requests.get('https://collegefootballrisk.com/api/territories', params={'season': season, 'day': day}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pandas as pd | |
| import requests | |
| response = requests.get( | |
| "https://api.collegefootballdata.com/games/players", | |
| params={"year": 2019, "week": "1"} | |
| ) | |
| records = pd.io.json.json_normalize( | |
| response.json(), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [{ | |
| typeId: 3, | |
| regex: /(?:Fumble by [^,]+, )?(?:([A-Z][^,\s]+(?: [A-Z][^,\s]+)+)|(?:N\/A))(?:(?: pass incomplete(?: to )*)([A-Z][^,\s]+(?: [A-Z'][^,\s]*)+)*)*(?:(?:, broken up by )([A-Z][^,\s]+(?: [A-Z][^,\s]+)+))*/g, | |
| types: [{ | |
| id: 1, | |
| isOffense: true, | |
| yardageStat: false | |
| }, { | |
| id: 2, | |
| isOffense: true, |