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 requests | |
| import pandas as pd | |
| import 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
| {“api_key”: “paste_your_actual_api_key_here”} |
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
| keys = get_keys("/Users/{your_username}/.secret/api_football.json") | |
| api_key = keys['api_key'] |
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
| url = "https://api-football-v1.p.rapidapi.com/v2/leagues/seasonsAvailable/524" | |
| headers = { | |
| 'x-rapidapi-host': "api-football-v1.p.rapidapi.com", | |
| 'x-rapidapi-key': api_key | |
| } | |
| resp = requests.request("GET", url, headers=headers) |
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
| resp.status_code == requests.codes.ok |
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
| print(resp.text) |
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
| # Check keys of response | |
| resp.json().keys() |
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
| # Check keys at next level of response | |
| resp.json()['api'].keys() |
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
| # Create dictionary of results for 'leagues' key | |
| leagues_dict = resp.json()['api']['leagues'] | |
| # Visualize df for all English Premier league seasons available | |
| leagues_df = pd.DataFrame.from_dict(leagues_dict) | |
| display(leagues_df) |
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
| # Plot f1 scores and number of pseudo-labels added for all iterations | |
| fig, (ax1, ax2) = plt.subplots(nrows=2, ncols=1, figsize=(6,8)) | |
| ax1.plot(range(iterations), test_f1s) | |
| ax1.set_ylabel('f1 Score') | |
| ax2.bar(x=range(iterations), height=pseudo_labels) | |
| ax2.set_ylabel('Pseudo-Labels Created') | |
| ax2.set_xlabel('# Iterations'); | |
| # View confusion matrix after self-training |
NewerOlder