Commit e439c83b authored by Robert R. Walker's avatar Robert R. Walker
Browse files

Actually added it

parent 15855e31
Showing with 928 additions and 0 deletions
+928 -0
File added
File added
File added
File added
File added
File added
File added
File added
File added
Gm#,Date,,Tm,,Opp,W/L,R,RA,Inn,W-L,Rank,GB,Win,Loss,Save,Time,D/N,Attendance,cLI,Streak,Orig. Scheduled
1,Thursday Apr 7,boxscore,LAA,,HOU,L,1,3,,0-1,5,1.0,Valdez,Ohtani,Pressly,3:15,N,44723,.98,-,
2,Friday Apr 8,boxscore,LAA,,HOU,L,6,13,,0-2,5,2.0,Montero,Ortega,,3:44,N,42719,.93,--,
3,Saturday Apr 9,boxscore,LAA,,HOU,W,2,0,,1-2,3,1.5,Syndergaard,Verlander,Iglesias,3:02,N,36139,.93,+,
4,Sunday Apr 10,boxscore,LAA,,HOU,L,1,4,,1-3,5,2.0,Urquidy,Suarez,Pressly,3:15,D,41253,.96,-,
5,Monday Apr 11,boxscore,LAA,,MIA,W,6,2,,2-3,4,1.5,Lorenzen,Hernandez,,2:42,N,20480,.83,+,
6,Tuesday Apr 12,boxscore,LAA,,MIA,W-wo,4,3,,3-3,2,1.5,Iglesias,Bender,,2:59,D,16132,.84,++,
7,Thursday Apr 14,boxscore,LAA,@,TEX,L,5,10,,3-4,3,1.5,King,Ohtani,,3:30,N,21440,.97,-,
8,Friday Apr 15,boxscore,LAA,@,TEX,W,9,6,,4-4,2,0.5,Warren,Allard,Iglesias,3:32,N,28723,.95,+,
9,Saturday Apr 16,boxscore,LAA,@,TEX,W,7,2,,5-4,2,0.5,Syndergaard,Hearn,,3:10,N,34493,1.00,++,
10,Sunday Apr 17,boxscore,LAA,@,TEX,W,8,3,,6-4,1,up 0.5,Mayers,Perez,,3:25,D,22650,1.07,+++,
11,Monday Apr 18,boxscore,LAA,@,HOU,L,3,8,,6-5,2,0.5,Garcia,Lorenzen,,3:22,N,42646,1.12,-,
12,Tuesday Apr 19,boxscore,LAA,@,HOU,W,7,2,,7-5,1,Tied,Ortega,Valdez,,3:36,N,30212,1.11,+,
13,Wednesday Apr 20,boxscore,LAA,@,HOU,W,6,0,,8-5,1,up 0.5,Ohtani,Odorizzi,,3:08,N,29049,1.14,++,
14,Friday Apr 22,boxscore,LAA,,BAL,L,3,5,,8-6,1,Tied,Zimmermann,Detmers,Lopez,2:55,N,31679,1.11,-,
15,Saturday Apr 23,boxscore,LAA,,BAL,L,4,5,,8-7,2,1.0,Baker,Loup,Lopez,3:11,N,43883,1.04,--,
16,Sunday Apr 24,boxscore,LAA,,BAL,W,7,6,,9-7,2,1.0,Herget,Baumann,Bradley,3:42,D,41984,1.09,+,
17,Monday Apr 25,boxscore,LAA,,CLE,W,3,0,,10-7,2,0.5,Lorenzen,Bieber,Iglesias,2:22,N,23099,1.10,++,
18,Tuesday Apr 26,boxscore,LAA,,CLE,W,4,1,,11-7,2,0.5,Sandoval,McKenzie,Iglesias,2:34,N,22551,1.12,+++,
19,Wednesday Apr 27,boxscore,LAA,,CLE,W,9,5,,12-7,1,up 0.5,Ohtani,Plesac,,3:12,N,28557,1.14,++++,
20,Thursday Apr 28,boxscore,LAA,,CLE,W,4,1,,13-7,1,up 1.5,Detmers,Quantrill,Iglesias,2:35,D,18826,1.18,+++++,
21,Friday Apr 29,boxscore,LAA,@,CHW,W,5,1,,14-7,1,up 2.5,Warren,Giolito,Iglesias,3:19,N,23709,1.15,++++++,
22,Saturday Apr 30,boxscore,LAA,@,CHW,L,0,4,,14-8,1,up 2.5,Velasquez,Suarez,,2:55,D,33762,1.22,-,
23,Sunday May 1,boxscore,LAA,@,CHW,W,6,5,,15-8,1,up 2.5,Lorenzen,Keuchel,Tepera,3:15,D,27664,1.19,+,
24,Monday May 2,boxscore,LAA,@,CHW,L,0,3,,15-9,1,up 2.5,Cease,Sandoval,Hendriks,2:39,D,13112,1.25,-,
25,Tuesday May 3,boxscore,LAA,@,BOS,L,0,4,,15-10,1,up 1.5,Wacha,Syndergaard,,2:23,N,29793,1.21,--,
26,Wednesday May 4,boxscore,LAA,@,BOS,W,10,5,10,16-10,1,up 1.5,Tepera,Barnes,,3:42,N,27679,1.20,+,
27,Thursday May 5,boxscore,LAA,@,BOS,W,8,0,,17-10,1,up 1.5,Ohtani,Houck,,2:55,D,29476,1.25,++,
28,Friday May 6,boxscore,LAA,,WSN,W,3,0,,18-10,1,up 1.5,Diaz,Adon,Iglesias,2:28,N,41923,1.19,+++,
29,Saturday May 7,boxscore,LAA,,WSN,L,3,7,,18-11,1,up 0.5,Gray,Lorenzen,,3:02,N,30666,1.22,-,
30,Sunday May 8,boxscore,LAA,,WSN,W-wo,5,4,,19-11,1,up 0.5,Barria,Rainey,,3:26,D,32337,1.17,+,
31,Monday May 9,boxscore,LAA,,TBR,W,11,3,,20-11,1,up 1.0,Syndergaard,Springs,,3:02,N,19537,1.28,++,
32,Tuesday May 10,boxscore,LAA,,TBR,W,12,0,,21-11,1,up 1.0,Detmers,Kluber,,2:19,N,39313,1.29,+++,
33,Wednesday May 11,boxscore,LAA,,TBR,L,2,4,10,21-12,1,Tied,Feyereisen,Loup,Raley,3:17,D,21045,1.28,-,
34,Friday May 13,boxscore,LAA,@,OAK,W,2,0,,22-12,2,0.5,Silseth,Jefferies,Iglesias,2:30,N,13992,1.24,+,
35,Saturday May 14 (1),boxscore,LAA,@,OAK,L-wo,3,4,,22-13,1,Tied,Trivino,Iglesias,,3:18,D,12719,1.26,-,
36,Saturday May 14 (2),boxscore,LAA,@,OAK,W,9,1,,23-13,1,Tied,Lorenzen,Oller,,2:47,N,7737,1.28,+,
37,Sunday May 15,boxscore,LAA,@,OAK,W,4,1,,24-13,1,Tied,Sandoval,Montas,Herget,3:29,D,14668,1.25,++,
38,Monday May 16,boxscore,LAA,@,TEX,L,4,7,,24-14,1,Tied,Gray,Syndergaard,Barlow,2:51,N,15110,1.26,-,
39,Tuesday May 17,boxscore,LAA,@,TEX,L,5,10,,24-15,2,1.0,Santana,Tepera,,3:58,N,17727,1.24,--,
40,Wednesday May 18,boxscore,LAA,@,TEX,L-wo,5,6,10,24-16,2,1.0,Santana,Iglesias,,3:23,N,20366,1.28,---,
41,Friday May 20,boxscore,LAA,,OAK,L,2,4,,24-17,2,1.5,Moll,Silseth,Jimenez,3:24,N,32422,1.29,----,
42,Saturday May 21,boxscore,LAA,,OAK,W,5,3,,25-17,2,1.5,Lorenzen,Kolarek,Iglesias,3:12,N,39045,1.27,+,
43,Sunday May 22,boxscore,LAA,,OAK,W,4,1,,26-17,2,1.5,Sandoval,Irvin,Iglesias,2:49,D,40042,1.26,++,
44,Tuesday May 24,boxscore,LAA,,TEX,W,5,3,,27-17,2,1.0,Syndergaard,Dunning,Iglesias,2:30,N,23791,1.28,+++,
45,Wednesday May 25,boxscore,LAA,,TEX,L,2,7,,27-18,2,2.0,Otto,Detmers,,2:49,N,22950,1.27,-,
46,Thursday May 26,boxscore,LAA,,TOR,L,3,6,,27-19,2,2.5,Ryu,Ohtani,,2:56,N,28228,1.28,--,
47,Friday May 27,boxscore,LAA,,TOR,L,3,4,,27-20,2,2.5,Richards,Iglesias,Romano,3:05,N,44641,1.24,---,
48,Saturday May 28,boxscore,LAA,,TOR,L,5,6,,27-21,2,2.5,Cimber,Barraclough,Stripling,3:45,N,34005,1.29,----,
49,Sunday May 29,boxscore,LAA,,TOR,L,10,11,,27-22,2,3.5,Cimber,Quijada,Phelps,4:13,D,36568,1.24,-----,
50,Tuesday May 31,boxscore,LAA,@,NYY,L,1,9,,27-23,2,5.0,Montgomery,Syndergaard,,2:54,N,31242,1.16,------,
51,Thursday Jun 2 (1),boxscore,LAA,@,NYY,L,1,6,,27-24,2,6.5,Cortes,Ohtani,Peralta,3:07,D,30518,1.11,-------,
52,Thursday Jun 2 (2),boxscore,LAA,@,NYY,L,1,2,,27-25,2,6.5,Taillon,Ortega,Holmes,3:08,N,33476,1.08,--------,
53,Friday Jun 3,boxscore,LAA,@,PHI,L,0,10,,27-26,2,7.5,Eflin,Silseth,,2:41,N,28721,.98,---------,
54,Saturday Jun 4,boxscore,LAA,@,PHI,L,2,7,,27-27,2,7.5,Wheeler,Lorenzen,,3:05,N,36313,.89,----------,
55,Sunday Jun 5,boxscore,LAA,@,PHI,L-wo,7,9,,27-28,2,8.5,Knebel,Iglesias,,3:57,D,34801,.87,-----------,
56,Monday Jun 6,boxscore,LAA,,BOS,L,0,1,,27-29,2,8.5,Wacha,Syndergaard,,2:32,N,29395,.87,------------,
57,Tuesday Jun 7,boxscore,LAA,,BOS,L,5,6,10,27-30,2,9.5,Houck,Barria,Strahm,3:56,N,27627,.81,-------------,
58,Wednesday Jun 8,boxscore,LAA,,BOS,L,0,1,,27-31,2,9.5,Eovaldi,Herget,Strahm,3:09,N,26587,.78,--------------,
59,Thursday Jun 9,boxscore,LAA,,BOS,W,5,2,,28-31,2,9.0,Ohtani,Pivetta,Iglesias,3:09,N,28595,.69,+,
60,Friday Jun 10,boxscore,LAA,,NYM,L,3,7,,28-32,2,9.0,Peterson,Diaz,,3:21,N,31499,.68,-,
61,Saturday Jun 11,boxscore,LAA,,NYM,W,11,6,,29-32,2,8.0,Lorenzen,Carrasco,,3:21,N,36408,.61,+,
62,Sunday Jun 12,boxscore,LAA,,NYM,L,1,4,,29-33,3,9.0,Walker,Sandoval,Díaz,3:11,D,36598,.71,-,
63,Tuesday Jun 14,boxscore,LAA,@,LAD,L,0,2,,29-34,3,9.5,Gonsolin,Syndergaard,Kimbrel,2:58,N,51013,.61,--,
64,Wednesday Jun 15,boxscore,LAA,@,LAD,L,1,4,,29-35,3,10.5,Anderson,Detmers,,2:50,N,50812,.53,---,
65,Thursday Jun 16,boxscore,LAA,@,SEA,W,4,1,,30-35,3,10.0,Ohtani,Kirby,Iglesias,2:53,N,21485,.52,+,
66,Friday Jun 17,boxscore,LAA,@,SEA,L,1,8,,30-36,3,11.0,Ray,Lorenzen,,2:37,N,37500,.57,-,
67,Saturday Jun 18 (1),boxscore,LAA,@,SEA,W,4,2,10,31-36,3,9.5,Iglesias,Castillo,Quijada,3:24,D,24071,.49,+,
68,Saturday Jun 18 (2),boxscore,LAA,@,SEA,W,3,0,,32-36,3,9.5,Herget,Milone,Bradley,2:57,N,20804,.50,++,
69,Sunday Jun 19,boxscore,LAA,@,SEA,W,4,0,,33-36,2,9.5,Wantz,Gilbert,,2:44,D,39052,.66,+++,
70,Monday Jun 20,boxscore,LAA,,KCR,L,2,6,,33-37,2,10.0,Bubic,Syndergaard,,2:58,N,22234,.69,-,
71,Tuesday Jun 21,boxscore,LAA,,KCR,L,11,12,11,33-38,3,11.0,Coleman,Quijada,Mengden,4:14,N,20189,.59,--,
72,Wednesday Jun 22,boxscore,LAA,,KCR,W,5,0,,34-38,3,11.0,Ohtani,Lynch,,3:04,N,34792,.52,+,
73,Friday Jun 24,boxscore,LAA,,SEA,L,3,4,,34-39,3,11.5,Flexen,Lorenzen,Sewald,3:41,N,35704,.60,-,
74,Saturday Jun 25,boxscore,LAA,,SEA,L,3,5,,34-40,4,12.5,Gilbert,Bradley,Swanson,3:22,N,35466,.53,--,
75,Sunday Jun 26,boxscore,LAA,,SEA,W,2,1,,35-40,3,11.5,Suarez,Gonzales,Ortega,3:04,D,26489,.44,+,
76,Monday Jun 27,boxscore,LAA,,CHW,W,4,3,,36-40,3,11.0,Syndergaard,Lopez,Iglesias,2:42,N,21973,.48,++,
77,Tuesday Jun 28,boxscore,LAA,,CHW,L,4,11,,36-41,3,12.0,Cueto,Ortega,,3:16,N,23979,.53,-,
78,Wednesday Jun 29,boxscore,LAA,,CHW,W,4,1,,37-41,3,12.0,Ohtani,Kopech,Iglesias,3:21,N,27612,.49,+,
79,Friday Jul 1,boxscore,LAA,@,HOU,L,1,8,,37-42,3,13.5,Javier,Lorenzen,,2:45,N,36420,.54,-,
80,Saturday Jul 2,boxscore,LAA,@,HOU,L,1,9,,37-43,4,14.5,Urquidy,Sandoval,,2:51,D,35332,.47,--,
81,Sunday Jul 3,boxscore,LAA,@,HOU,L-wo,2,4,,37-44,4,15.5,Pressly,Tepera,,3:23,D,36048,.42,---,
82,Tuesday Jul 5,boxscore,LAA,@,MIA,L,1,2,,37-45,4,17.0,Alcantara,Syndergaard,Scott,2:47,N,13338,.34,----,
83,Wednesday Jul 6,boxscore,LAA,@,MIA,W,5,2,,38-45,4,16.0,Ohtani,Rogers,,3:07,N,18741,.27,+,
84,Thursday Jul 7,boxscore,LAA,@,BAL,L,1,4,,38-46,4,17.0,Lyles,Silseth,Lopez,3:00,N,13088,.36,-,
85,Friday Jul 8,boxscore,LAA,@,BAL,L-wo,4,5,,38-47,4,18.0,Tate,Iglesias,,3:30,N,27814,.33,--,
86,Saturday Jul 9,boxscore,LAA,@,BAL,L,0,1,,38-48,4,18.0,Kremer,Sandoval,Lopez,2:59,D,32286,.27,---,
87,Sunday Jul 10,boxscore,LAA,@,BAL,L,5,9,,38-49,4,19.0,Voth,Suarez,,2:48,D,19521,.24,----,
88,Tuesday Jul 12,boxscore,LAA,,HOU,L,5,6,,38-50,4,20.0,Neris,Iglesias,Pressly,3:37,N,27180,.18,-----,
89,Wednesday Jul 13,boxscore,LAA,,HOU,W,7,1,,39-50,4,19.0,Ohtani,Javier,,3:45,N,27803,.15,+,
90,Thursday Jul 14,boxscore,LAA,,HOU,L,2,3,10,39-51,4,20.0,Pressly,Loup,,3:28,N,34496,.15,-,
91,Friday Jul 15,boxscore,LAA,,LAD,L,1,9,,39-52,4,20.0,Kershaw,Sandoval,,3:01,N,44648,.12,--,
92,Saturday Jul 16,boxscore,LAA,,LAD,L,1,7,,39-53,4,21.0,Urias,Suarez,,3:07,N,44728,.07,---,
93,Friday Jul 22,boxscore,LAA,@,ATL,L,1,8,,39-54,4,22.5,Lee,Ohtani,,2:59,N,42867,.06,----,
94,Saturday Jul 23,boxscore,LAA,@,ATL,L,2,7,,39-55,4,23.5,Wright,Sandoval,,3:01,N,42827,.04,-----,
95,Sunday Jul 24,boxscore,LAA,@,ATL,W,9,1,,40-55,4,23.5,Detmers,Anderson,,3:17,D,42663,.04,+,
96,Monday Jul 25,boxscore,LAA,@,KCR,L,0,7,,40-56,4,23.5,Garrett,Syndergaard,,3:03,N,16616,.05,-,
97,Tuesday Jul 26,boxscore,LAA,@,KCR,W,6,0,,41-56,4,22.5,Suarez,Zerpa,,3:24,N,20834,.04,+,
98,Wednesday Jul 27,boxscore,LAA,@,KCR,W,4,0,,42-56,4,21.5,Junk,Keller,,2:48,D,12596,.05,++,
99,Thursday Jul 28,boxscore,LAA,,TEX,L,0,2,,42-57,4,22.5,Howard,Ohtani,Moore,2:47,N,29718,.06,-,
100,Friday Jul 29,boxscore,LAA,,TEX,L,2,7,,42-58,4,23.5,Perez,Sandoval,,3:13,N,29906,.05,--,
101,Saturday Jul 30,boxscore,LAA,,TEX,W,9,7,,43-58,4,22.5,Toussaint,Martin,Iglesias,3:04,N,32968,.04,+,
\ No newline at end of file
This diff is collapsed.
import numpy as np
import matplotlib.pyplot as plt
# RUN 1: Bitcoin is great!
def plot_cherry_picked_bitcoin_data(date, price):
"""
Plots bitcoin data from 2021-2022.
Arguments:
- date, price (both lists)
Returns:
- None (plot pops up)
"""
(fig, ax) = plt.subplots()
# Plot the data
ax.plot(..., ..., color=...)
# Title and labels
ax.set_title('Daily Bitcoin Price (2021-2022)', fontsize=22)
# 10 x ticks
x_ticks = []
for i in range(0, len(date), 100):
x_ticks.append(...)
# 10 y ticks
y_ticks = []
for j in range(10000, 100000, 10000):
...
ax.set_xticks(...)
ax.set_yticks(...)
# Restrict the x-axis (look it up!)
...
# Show the figure
plt.show()
# RUN 2: Caltech v Stanford
def plot_trimmed_y_axis_bar_graph(schools, laureates):
"""
Plots the number of Nobel laureates per school.
Arguments:
- schools, laureates (both lists)
Returns:
- None (plot pops up)
"""
# Create single Axes to manage the plotting
(fig, ax) = plt.subplots()
# Plot the data (bar chart - look it up!!!)
...
# Title and labels
ax.set_title(...)
# Restrict the y-axis
...
# Show the figure
...
# RUN 3: Spurious correlations
def plot_spurious_correlation(years, arcade_revenue, cs_doctorates):
"""
Plots two statistics which are spuriously correlated.
Arguments:
- years, arcade_revenue, cs_doctorates (all lists)
Returns:
- None (plot pops up)
"""
# Start the figure
fig, ax1 = plt.subplots()
# Allow for two functions on one plot
ax2 = ax1.twinx()
# Plot one in red and the other in black
ax1.plot(years, ..., 'r-')
ax2.plot(..., ..., 'k-')
# Restrict the y-axes
ax1.set_ylim([1, 2])
ax2.set_ylim([500, 2000])
# Title and labels
plt.title('Total revenue generated by arcades correlates (98.51%) with ' +
'computer science doctorates awarded in the US', wrap=True)
ax1.set_xlabel('Years')
ax1.set_ylabel('Arcade revenue (billions of USD)', color='red')
ax2.set_ylabel('Computer science doctorates', color='black')
# Show the figure
...
# RUN 4: Misleading trends
def plot_angels_projections(games, wins):
"""
Plots two statistics which are spuriously correlated.
Arguments:
- games, wins (both lists)
Returns:
- None (plot pops up)
"""
# Restrict the games and wins to the first 37 games
early_games = ...
early_wins = ...
# Find the line of best fit (ax + b)
a, b = np.polyfit(early_games, early_wins, 1)
extrapolation = []
for x in range(101):
extrapolation.append(a*x + b)
# Create single Axes to manage the plotting
(fig, ax) = plt.subplots()
# Plot the data and the line of best fit
...
...
# Title and labels
ax.set_title('LA Angel\'s Wins vs. Games played in the 2022 season')
ax.set_xlabel('Games played')
# Set the y axis label
...
# Legend
legend_1 = 'Games they would have won'
legend_2 = 'Games they won'
# Set the legend
...
# Show the figure
...
"""
CS 1 23fa
Lab 05 Provided Backend Code
Original Author: Leo Jenkins
"""
import csv
def get_angels_data():
"""
Returns a (list, list) tuple of game numbers and wins,
respectively, for the Angels in 2022. Data comes from
angels_wins_2022.csv. Both lists contain int values only.
Returns:
- (list, list) tuple representing number of games and wins
"""
ANGELS_DATASET = 'angels_wins_2022.csv'
with open(ANGELS_DATASET, 'r') as csv_file:
csv_reader = csv.DictReader(csv_file)
xs = []
ys = []
wins = 0
for row in csv_reader:
# Convert string values to ints for plotting
xs.append(int(row['Gm#']))
if row['W/L'] == 'W':
wins += 1
ys.append(wins)
return (xs, ys)
def get_bitcoin_data():
"""
Returns a (list, list) tuple of dates and prices for
Bitcoins collected from bitcoin_historical_data.csv.
Dates are represented as strings, and prices are represented as floats.
Returns:
- (list, list) tuple representing dates and prices for Bitcoin data
"""
BITCOIN_DATASET = 'bitcoin_historical_data.csv'
with open(BITCOIN_DATASET, 'r') as csv_file:
csv_reader = csv.DictReader(csv_file)
xs = []
ys = []
for row in csv_reader:
xs.append(row['Date'])
# Standardize price value (which may have ,) to float
# (it's good to break apart these steps for debugging!)
price = row['Price'] # e.g. '20,000.99'
price = price.replace(',', '') # e.g. '20000.99'
price = float(price) # e.g. 20000.99
ys.append(price)
# We're done processing the file, so we end the with block
# Reverse the lists (from list reading!) since dates (xs) are in descending
# order in our dataset, and we need to make sure the prices (ys) stay
# corresponding to the correct dates (remember that xs[i] and ys[i] must
# match as a single (xi, yi) data point)
xs = xs[::-1]
ys = ys[::-1]
return (xs, ys)
from lab05_backend import get_bitcoin_data
from lab05 import plot_cherry_picked_bitcoin_data
if __name__ == '__main__':
dates, prices = get_bitcoin_data()
plot_cherry_picked_bitcoin_data(dates, prices)
from lab05 import plot_trimmed_y_axis_bar_graph
if __name__ == '__main__':
schools = ['Caltech', 'Stanford']
lab05 = [46, 35]
plot_trimmed_y_axis_bar_graph(schools, lab05)
\ No newline at end of file
from lab05 import plot_spurious_correlation
if __name__ == '__main__':
# Generate 10 years between [2000-2010)
years = [i for i in range(2000, 2010)]
# Sample revenues and doctorates for each revenue per year
# (Remember that each index corresponds to the same (x, y) point; order
# matters!)
revenue = [1.196, 1.176, 1.269, 1.24, 1.307, 1.435, 1.601, 1.654, 1.803, 1.734]
doctorates = [861, 830, 809, 867, 848, 1129, 1453, 1656, 1787, 1611]
plot_spurious_correlation(years, revenue, doctorates)
\ No newline at end of file
from lab05_backend import get_angels_data
from lab05 import plot_angels_projections
if __name__ == "__main__":
games_played, games_won = get_angels_data()
plot_angels_projections(games_played, games_won)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment