Regression: regularization

Python में Machine Learning इंटरव्यू प्रश्नों का अभ्यास

Lisa Stuart

Data Scientist

Regularization एल्गोरिदम

  • Ridge regression
  • Lasso regression
  • ElasticNet regression
Python में Machine Learning इंटरव्यू प्रश्नों का अभ्यास

Ordinary least squares

OLS प्लॉट

OLS सूत्र

1 https://en.wikipedia.org/wiki/Linear_regression#Simple_and_multiple_linear_regression
Python में Machine Learning इंटरव्यू प्रश्नों का अभ्यास

Ridge लॉस फंक्शन

Ridge regression प्लॉट

Ridge regression सूत्र

1 https://gerardnico.com/data_mining/ridge_regression#tuning_parameter_math_lambdamath
Python में Machine Learning इंटरव्यू प्रश्नों का अभ्यास

Lasso लॉस फंक्शन

Lasso regression प्लॉट

Lasso regression सूत्र

1 https://stats.stackexchange.com/questions/155192/why-discrepancy-between-lasso-and-randomforest
Python में Machine Learning इंटरव्यू प्रश्नों का अभ्यास

Ridge बनाम Lasso

Regularization L1 (Lasso) L2 (Ridge)
दंडित करता है गुणांकों के परिमाणों का योग गुणांकों के वर्गों का योग
समाधान sparse non-sparse
समाधानों की संख्या कई एक
फीचर चयन हाँ नहीं
outliers के प्रति robust? हाँ नहीं
जटिल पैटर्न? नहीं हाँ
Python में Machine Learning इंटरव्यू प्रश्नों का अभ्यास

ElasticNet

ElasticNet सूत्र

Python में Machine Learning इंटरव्यू प्रश्नों का अभ्यास

Boston housing डेटा पर Regularization

Features CHAS NOX RM
Coefficient estimates 2.7 -17.8 3.8
Regularized coefficient estimates 0 0 0.95
Python में Machine Learning इंटरव्यू प्रश्नों का अभ्यास

Regularization फंक्शन

# 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 इंटरव्यू प्रश्नों का अभ्यास

Let's practice!

Python में Machine Learning इंटरव्यू प्रश्नों का अभ्यास

Preparing Video For Download...