Pythonで学ぶMachine Learning面接対策
Lisa Stuart
Data Scientist






| 正則化 | L1(Lasso) | L2(Ridge) |
|---|---|---|
| 罰則 | 係数の絶対値の和 | 係数の二乗和 |
| 解 | スパース | 非スパース |
| 解の数 | 複数 | 一意 |
| 特徴選択 | あり | なし |
| 外れ値に頑健? | はい | いいえ |
| 複雑なパターン? | いいえ | はい |

| 特徴量 | CHAS | NOX | RM |
|---|---|---|---|
| 係数推定値 | 2.7 | -17.8 | 3.8 |
| 正則化後の係数推定値 | 0 | 0 | 0.95 |
# Lasso estimator
sklearn.linear_model.Lasso
# Lasso estimator with cross-validation
sklearn.linear_model.LassoCV
# Ridge estimator
sklearn.linear_model.Ridge
# Ridge estimator with cross-validation
sklearn.linear_model.RidgeCV
# ElasticNet estimator
sklearn.linear_model.ElasticNet
# ElasticNet estimator with cross-validation
sklearn.linear_model.ElasticNetCV
# Train/test split
sklearn.model_selection.train_test_split
# Mean squared error
sklearn.metrics.mean_squared_error(y_test,
predict(X_test))
# Best regularization parameter
mod_cv.alpha_
# Array of log values
alphas=np.logspace(-6, 6, 13)
Pythonで学ぶMachine Learning面接対策