Skip to content

Commit 95d2f95

Browse files
committed
RFCT Merge cv10_lr.py & boston_cv_penalized.py
1 parent 2bf5384 commit 95d2f95

3 files changed

Lines changed: 6 additions & 48 deletions

File tree

‎ch07/README.rst‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ boston1.py
1616
boston1numpy.py
1717
Version of above script using numpy operations for linear regression
1818
boston_cv_penalized.py
19-
Test different penalized regression schemes on the Boston dataset
20-
cv10_lr.py
19+
Test different penalized (and OLS) regression schemes on the Boston dataset
2120
figure1_2.py
2221
Show the regression line for Boston data
2322
figure3.py

‎ch07/boston_cv_penalized.py‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,18 @@
1010
from __future__ import print_function
1111
import numpy as np
1212
from sklearn.cross_validation import KFold
13-
from sklearn.linear_model import ElasticNet, Lasso, Ridge
13+
from sklearn.linear_model import LinearRegression, ElasticNet, Lasso, Ridge
1414
from sklearn.metrics import r2_score
1515
from sklearn.datasets import load_boston
1616
boston = load_boston()
1717
x = boston.data
1818
y = boston.target
1919

2020
for name, met in [
21-
('elastic-net(.5)', ElasticNet(fit_intercept=True, alpha=0.5)),
22-
('lasso(.5)', Lasso(fit_intercept=True, alpha=0.5)),
23-
('ridge(.5)', Ridge(fit_intercept=True, alpha=0.5)),
21+
('linear regression', LinearRegression()),
22+
('elastic-net(.5)', ElasticNet(alpha=0.5)),
23+
('lasso(.5)', Lasso(alpha=0.5)),
24+
('ridge(.5)', Ridge(alpha=0.5)),
2425
]:
2526
# Fit on the whole data:
2627
met.fit(x, y)

‎ch07/cv10_lr.py‎

Lines changed: 0 additions & 42 deletions
This file was deleted.

0 commit comments

Comments
 (0)