Category Archives: Uncategorized

Hands-On Machine Learning Using the R Language

Hello, folks. This post is for those who plan to attend my “Hands-On Machine Learning Using the R Language” session at the Better Software / Agile Dev / DevOps conference on Wednesday, November 8th, 2017.

You will want to install R and the R-Studio IDE in advance. The session will assume you already have these installed.

Below are the data files and code I will be using during the presentation.

house_prices_in_19083

home_price_preds_BAD.R

Raw SMS ham / spam data

spam_analysis_BAD.R

 

One-Time Raise or Multi-Year Bonus Increase?

Meet Victor – he currently makes $100k annually with a 10% annual bonus. He has learned that he is getting a promotion next year, and will be receiving additional compensation. He can choose between two options – a one-time 5% raise or having his annual bonus upped to 15% for next year and all subsequent years. Which should he choose?

At first glance, many would choose the bonus, based on the idea that the bonus is a recurring benefit. In the first year, some would say, the additional 5% bonus would be equivalent to the additional 5% salary, but in subsequent years, the recurring benefit from the increased bonus (15% versus 10%) would make the bonus the more attractive option.

Let’s do the math and examine this claim. Currently, his $100k salary and 10% bonus bring him $110k per year. If he takes the 5% salary increase for next year, he will make $105k, and his 10% bonus will tack on an additional $10,500, bringing his annual haul to $115,500. In contrast, if he takes the extra 5% on his bonus, he will continue to make $100k for his salary,  but his bonus will rise to $15,000, bringing his annual compensation to $115,000 – $500 less than what the salary increase will bring.

What about subsequent years? Will the recurring benefit of the increased bonus make it the more profitable option in year 2? For the sake of realism, we will assume a 3% annual merit increase on Victor’s salary, but we will assume this to hold true across both of the scenarios we are tracking. So, if his initial move was to go with the 5% salary increase, which brought him to $105k in salary, then a 3% merit increase in the next year will bring him to $108,150. Once his 10% bonus has been paid, he will have made $118,965 for the year.

What would have happened in year 2 if he had gone with the bonus? His 3% merit increase would have brought him to $103k in salary. Then, his big 15% bonus would kick in, giving him another $15,450. Yet, the two together come to only $118,450, or $515 less than he would have gotten in year 2 had he taken the initial salary bump instead of the bonus. The gap has now gotten wider, from $500 the first year to $515 in the second.

You can probably see how this will play out. The gap will just keep getting wider, because he is always 5% higher in salary than he otherwise would have been for a given year, and then his bonus is calculated on top of that. In year 3, assuming another 3% merit increase, the initial salary bump results in a salary of $111,395 and a bonus of $11,140, yielding $122, 535. In contrast, the initial bonus would bring a salary of $106,090, and a bonus of $15,914, yielding a total of $122,004. The gap is now about $530 in favor of the salary increase.

The math here is pretty simple, but maybe not terribly intuitive. Many folks seem to think that the recurring bonus is the thing to get excited about, but they don’t realize that when salary increases are calculated this way (and for many people, they are), that one-time salary bump has even greater recurring benefits. Food for thought the next time you have to negotiate compensation …

Anticipation vs Explication

Any smart person can come up with a plausible explanation of something after the fact – you’re adding real value when you can predict an outcome in advance.

Casey Anthony was just found innocent of the murder of her daughter. Almost everybody, professional and layperson alike, thought she would be convicted.

Almost immediately, the pundits weighed in with explanations – the prosecution went too far, they said, in pushing for first degree murder. The evidence wasn’t strong enough for a first degree conviction, the prosecutors had overreached, a lesser charge would have been more appropriate, etc.

However, the prosecution had wrapped up its case weeks before the acquittal. If the pundits saw a mismatch between the charges and the evidence, they could have piped up then. Yet, most said nary a word about this, because they did not see it as an issue at the time. They, like the rest of the world, foresaw a conviction.

When the stunning acquital came, they were quick to manufacture reasons. These reasons made sense, in a way, but once you know how a story ends, it’s relatively easy for an intelligent person to select a set of facts and inferences that leads toward the outcome, and weave these together into an explanation of what happened. It’s much harder (and more valuable) to weave together the facts and probabilities in advance, and correctly divine an outcome before the movie ends.

The world needs more psychics and prophets – we have enough Monday morning quarterbacks and plausible explanations that come when the punchline is already obvious.