O'Reilly logo

Baseball Hacks by Joseph Adler

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Look for Evidence of Platoon Effects

Do lefties hit better against righties (and vice versa)?

In the 1950s, Branch Rickey’s Dodgers pioneered a lot of baseball thinking, including "platoon effects.” Based on observations that lefthanded batters fared better (on average) when facing righties than lefties, the Dodgers began to change pitchers and batters to better fit their opponents.

This hack looks at this classic sabermetric effect, showing you how to measure the effect of handedness.

Average Platoon Effects

Let’s start by looking at how lefty and righty hitters fared, on average, against lefty and righty pitchers over the past year.

To run these queries, you’ll need a play-by-play database such as the one I created in “Make a Historical Play-by-Play Database” [Hack #22] . You’ll also find it helpful to index the play-by-play tables by hand so that the queries run quickly. You can do this by executing the following SQL commands through your SQL client:

	-- create an index to expedite processing
	create index pbp2k_hands_idx on pbp.pbp2k
	  (res_batter_hand, res_pitcher_hand, res_batter, res_pitcher);

Now, let’s look at how players do by hand. Here is a query that calculates league batting averages and league average on-base percentage for each combination of batter and pitcher hand. I used a subquery to make this easy to read. The subquery calculates H, AB, BB, HBP, SF, and SH for each play. The main query calculates the league averages of these amounts.

 select res_batter_hand, res_pitcher_hand, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required