Applying a regression model
Remember how we called Clone on our DataFrame at the beginning of the chapter to store a copy of our original DataFrame before we dropped the Name column?
In this section, we’ll take that variable, dfWithName, and we’ll use our trained model to add new columns to the DataFrame. This will let us store the predicted market value and the percentage of that value they’re currently being paid. We can then order the DataFrame and look at the highest and lowest rows to identify players to potentially acquire and players to avoid or trade away.
We’ll start by defining a method to help us get a value out of a row or default to 0 if the value for that row is null:
float GetValueOrDefault(DataFrameRow row, string columnName) {
object value = row[columnName];
return value == null ? 0 : (float)value;
} This method will be helpful when looking at players in their first season who have...