회귀: 정규화

Python으로 연습하는 Machine Learning 면접 질문

Lisa Stuart

Data Scientist

정규화 알고리즘

  • 리지 회귀
  • 라쏘 회귀
  • 엘라스틱넷 회귀
Python으로 연습하는 Machine Learning 면접 질문

최소제곱법(OLS)

OLS 플롯

OLS 공식

1 https://en.wikipedia.org/wiki/Linear_regression#Simple_and_multiple_linear_regression
Python으로 연습하는 Machine Learning 면접 질문

리지 손실 함수

리지 회귀 플롯

리지 회귀 공식

1 https://gerardnico.com/data_mining/ridge_regression#tuning_parameter_math_lambdamath
Python으로 연습하는 Machine Learning 면접 질문

라쏘 손실 함수

라쏘 회귀 플롯

라쏘 회귀 공식

1 https://stats.stackexchange.com/questions/155192/why-discrepancy-between-lasso-and-randomforest
Python으로 연습하는 Machine Learning 면접 질문

리지 vs 라쏘

정규화 L1(라쏘) L2(리지)
패널티 계수 절댓값의 합 계수 제곱의 합
희소 비희소
해의 개수 다수 하나
특성 선택 아니오
이상치에 강함? 아니오
복잡한 패턴? 아니오
Python으로 연습하는 Machine Learning 면접 질문

엘라스틱넷

엘라스틱넷 공식

Python으로 연습하는 Machine Learning 면접 질문

보스턴 주택 데이터로 정규화

특성 CHAS NOX RM
계수 추정치 2.7 -17.8 3.8
정규화된 계수 추정치 0 0 0.95
Python으로 연습하는 Machine Learning 면접 질문

정규화 함수

# 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 면접 질문

Ayo berlatih!

Python으로 연습하는 Machine Learning 면접 질문

Preparing Video For Download...