Coefficient of Determination
-data = yi … yn
-predictions = fi..fn
-average of data = y
R^2 = 1 – Σn(yi-fi)/Σn(yi-y)^2
Calculating R^2
import numpy as np def compute_r_squared(data, predictions): SST = ((data-np.mean(data))**2).sum() SSReg = ((predictions-data)**2).sum() r_squared = 1 - SSReg / SST return r_squared
Additional Considerations
– other types of linear regression
– ordinary least squares regression
– parameter estimation
– under / overfitting
– multiple local minima