standard_lasso
Jonathan corrected a spurious use of standard_lasso
This commit is contained in:
@@ -1,15 +1,3 @@
|
|||||||
---
|
|
||||||
jupyter:
|
|
||||||
jupytext:
|
|
||||||
cell_metadata_filter: -all
|
|
||||||
formats: Rmd,ipynb
|
|
||||||
main_language: python
|
|
||||||
text_representation:
|
|
||||||
extension: .Rmd
|
|
||||||
format_name: rmarkdown
|
|
||||||
format_version: '1.2'
|
|
||||||
jupytext_version: 1.14.7
|
|
||||||
---
|
|
||||||
|
|
||||||
# Chapter 10
|
# Chapter 10
|
||||||
|
|
||||||
@@ -236,7 +224,7 @@ $\lambda$ with an all-zero solution. This value equals the largest absolute inn
|
|||||||
X_s = scaler.fit_transform(X_train)
|
X_s = scaler.fit_transform(X_train)
|
||||||
n = X_s.shape[0]
|
n = X_s.shape[0]
|
||||||
lam_max = np.fabs(X_s.T.dot(Y_train - Y_train.mean())).max() / n
|
lam_max = np.fabs(X_s.T.dot(Y_train - Y_train.mean())).max() / n
|
||||||
param_grid = {'alpha': np.exp(np.linspace(0, np.log(0.01), 100))
|
param_grid = {'lasso__alpha': np.exp(np.linspace(0, np.log(0.01), 100))
|
||||||
* lam_max}
|
* lam_max}
|
||||||
```
|
```
|
||||||
Note that we had to transform the data first, since the scale of the variables impacts the choice of $\lambda$.
|
Note that we had to transform the data first, since the scale of the variables impacts the choice of $\lambda$.
|
||||||
@@ -246,7 +234,7 @@ We now perform cross-validation using this sequence of $\lambda$ values.
|
|||||||
cv = KFold(10,
|
cv = KFold(10,
|
||||||
shuffle=True,
|
shuffle=True,
|
||||||
random_state=1)
|
random_state=1)
|
||||||
grid = GridSearchCV(lasso,
|
grid = GridSearchCV(standard_lasso,
|
||||||
param_grid,
|
param_grid,
|
||||||
cv=cv,
|
cv=cv,
|
||||||
scoring='neg_mean_absolute_error')
|
scoring='neg_mean_absolute_error')
|
||||||
@@ -868,7 +856,7 @@ for idx, (X_ ,Y_) in enumerate(cifar_dm.train_dataloader()):
|
|||||||
|
|
||||||
|
|
||||||
Before we start, we look at some of the training images; similar code produced
|
Before we start, we look at some of the training images; similar code produced
|
||||||
Figure 10.5 on page 447. The example below also illustrates
|
Figure 10.5 on page 406. The example below also illustrates
|
||||||
that `TensorDataset` objects can be indexed with integers --- we are choosing
|
that `TensorDataset` objects can be indexed with integers --- we are choosing
|
||||||
random images from the training data by indexing `cifar_train`. In order to display correctly,
|
random images from the training data by indexing `cifar_train`. In order to display correctly,
|
||||||
we must reorder the dimensions by a call to `np.transpose()`.
|
we must reorder the dimensions by a call to `np.transpose()`.
|
||||||
@@ -1388,7 +1376,7 @@ We’ll now make a plot to compare our neural network results with the
|
|||||||
lasso.
|
lasso.
|
||||||
|
|
||||||
```{python}
|
```{python}
|
||||||
# %%capture
|
%%capture
|
||||||
fig, axes = subplots(1, 2, figsize=(16, 8), sharey=True)
|
fig, axes = subplots(1, 2, figsize=(16, 8), sharey=True)
|
||||||
for ((X_, Y_),
|
for ((X_, Y_),
|
||||||
data_,
|
data_,
|
||||||
|
|||||||
177109
Ch10-deeplearning-lab.ipynb
177109
Ch10-deeplearning-lab.ipynb
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user