Tuesday, November 3, 2015

Baby Analytics

For those that have been missing my posts, you probably don't know that my wife and I welcomed a son into our family earlier this year. Unfortunately, sleep deprivation kept me from being able to code (and think) effectively. I did end up with some new data though. For those without newborns, you might not be aware that parents are recommended to keep track of their baby in a notebook (or phone app) for the first few months of their life. This data comprises how much our son eats, when he has a diaper change, what his temperature is, etc.

Using this data, I thought it might be interesting to see if we could perform some analytics. Here's a list of problems I'm looking to tackle:
  • Can you predict growth spurts with this data?
  • Can you detect abnormal or just a change in behavior from this data?
It's going to take me a month or so to enter the data into a spreadsheet, but once it's up I'll put together another post with some visualization of that data.

Tuesday, October 20, 2015

DFS and Optimization: Simple Optimization

Now that we have data, let's actually get into the point of having this data: choosing what players to play each day. For our first go, we're going to take a simple approach. We'll start out with just pitchers and maximizing over just one metric, game score. This will allow us to get a refresher in how to run an optimization problem in R and create a set of code that we will be able build out in the future.

First step is merging the datasets that have the two data points we need. Using this dataset, we'll create an empty Integer Program. Our decision variables will be binary variables representing if we will choose that player or not. The IP will have two constraints:

  1. We must select 2 pitchers
  2. The total salary used must be below a threshold
Using lpSolve, we can construct the problem and solve it. The results are interesting as it's easy to see what players were optimal selection. That being said, this is just a start.