Linear Regression with PHP
Lasso Regression with Rubix
In Lasso (Least Absolute Shrinkage and Selection Operator) regression, the penalty added is proportional to the absolute value of each
coefficient. The cost function to minimize is:
$J(\beta) = \sum_{i=1}^{n} (y_i - \hat{y_i})^2 + \lambda \sum_{j=1}^{p} |\beta_j|$
The L1 -norm penalty $\sum_{j=1}^{p} |\beta_j|$ often results in some coefficients being reduced to zero, effectively performing feature selection.
Chart:
Regression:
Result:
Memory: 0.312 Mb
Time running: 0.181 sec.
Custom Lasso Implementation:
----------------
Lasso Regression (alpha=0.0001):
Bedrooms: 2,205
Bathrooms: -5,205
Sqft: 203
Lot Size: 5
Year Built: -22
Days On Market: 356
Proximity To Transit: 2,883
Crime Rate: 134
School Rating: 5,518
Neighborhood Rating: 6,651
Predictions for example homes:
----------------
Small home (2 bed, 1 bath, 1000 sqft, built 1965): $308,227.96
Medium home (3 bed, 2 bath, 2000 sqft, built 2010): $522,394.16
Luxury home (5 bed, 3.5 bath, 3500 sqft, built 2018): $858,565.22