Sabermetrics

SabermetricsIn this article I introduce you to the world of Sabermetrics. Sabermetrics is the analysis of baseball statistics to measure player performance, in game probabilities and much more.

With Sabermetrics you’ll be able to do most anything from decide who was the greatest hitter of all time to analyze the probability that your team will win.

But, to get started with Sabermetrics, you need to first get your tools being MySQL and a Baseball Stat Database. Both are free! More info follows the video below.

If you like videos like this tell google , or share it

More on Sabermetrics

I plan on covering many more Sabermetric formulas, but you can find mostly everyone of them in The Bill James Historical Baseball Abstract. He is credited with first publishing many of the formulas we will explore.

Code from the Video

LOAD SQL DUMP FILE
(Shawn Lahman's Free BaseBall Database)

mysql5 -u mysqladm -p < /Users/derekbanas/Downloads/lahman591.sql;

SHOW DATABASES

show databases;

USE DATABASE

use lahman591;

HOW TO KILL A QUERY

1. Open a new Terminal
2. SHOW PROCESSLIST;
3. KILL QUERY id;

SHOW TABLES AND DESCRIBE THEM

SHOW TABLES;
DESCRIBE Batting; # Using Table Named Batting

TEAM NAME AND SALARY

describe salaries; # Show salaries Table

PROOF SABERMETRICS WORKED 2002 ATHLETICS 103 WINS

SELECT s.yearID, s.teamID, 
SUM(s.salary) AS SALARY, 
t.W AS WINS, 
SALARY/t.W AS CPW 
FROM salaries s, teams t 
WHERE s.yearID = 2002 AND s.teamID = t.teamID 
AND s.yearID = t.yearID 
GROUP BY s.teamID 
ORDER BY SALARY DESC;

13 Responses to “Sabermetrics”

  1. mr.roshik says:

    Thanks for new lesson.

  2. Nathan Martinez says:

    I need help I can’t seem to get it to run right it always sends the following error message:

    -bash: mysql: command not found
    HELP PLEASE

  3. Nathan Martinez says:

    Where do i change this

  4. sham says:

    hello derek,
    if i do not give ‘group by s.teamID’ clause for query, i get single record for teamID ANA why?
    i want to understand this.

    Select s.yearID, s.teamID, sum(s.salary) as salary, t.w as wins, salary/t.w as cpw from salaries s ,teams t where s.yearID = 2002 and s.teamID = t.teamID and s.yearID = t.yearID;

  5. sham says:

    hello derek,
    If i remove
    Group by clause
    In any of your sql query,
    I get only one entry instead of multiple entries.
    Why?

Leave a Reply

Your email address will not be published.

Google+