Machine Learning/Models (with codes)

(L2 Regularization) → Ridge Regression (w/scikit-learn)

metamong 2022. 4. 20.

๐Ÿ˜ผ ์ €๋ฒˆ ํฌ์ŠคํŒ…์—์„œ Ridge ํšŒ๊ท€๊ฐ€ ๋ฌด์—‡์ธ์ง€ ๊ฐœ๋…์— ๋Œ€ํ•ด ์ •ํ™•ํžˆ ์•Œ์•„๋ณด์•˜๋‹ค ๐Ÿ˜ผ

 

 

(L2 Regularization) → Ridge Regression (concepts)

** ์šฐ๋ฆฌ๋Š” ์ €๋ฒˆ ํฌ์ŠคํŒ…์—์„œ Supervised Learning ์ค‘ Regression์˜ ์ผ์ข…์ธ 'linear regression'์— ๋Œ€ํ•ด ํ•™์Šตํ–ˆ๋‹ค. โ˜๏ธ ์œ„ ๊ทธ๋ฆผ์—์„œ ๋ณด๋‹ค์‹œํ”ผ linear ์„ ํ˜• regression์œผ๋กœ๋Š” ๋งŽ์€ ์ข…๋ฅ˜์˜ model์ด ์žˆ์Œ์„ ํ™•์ธํ• ..

sh-avid-learner.tistory.com

 

→ ์ด์   Ridge ํšŒ๊ท€๋ฅผ ์‹ค์ œ python code๋กœ ๊ตฌํ˜„ํ•ด์„œ ์–ผ๋งˆ๋‚˜ model์ด ์ž˜ ์˜ˆ์ธก์„ ํ•˜๋Š”์ง€, ๊ณผ์—ฐ ๊ณผ์ ํ•ฉ์—์„œ ๋ฒ—์–ด๋‚˜ ๋” ๋‚˜์€ model์„ ๋งŒ๋“ค ์ˆ˜ ์žˆ๋Š” ๊ฑด์ง€ ์ด๋ฒˆ ํฌ์ŠคํŒ…์„ ํ†ตํ•ด ์•Œ์•„๋ณด๋ ค ํ•œ๋‹ค

 

 Ridge ๋ชจ๋ธ์„ ๋งŒ๋“œ๋Š” ํ•จ์ˆ˜๋Š” ํฌ๊ฒŒ Ridge์™€ RidgeCV๋กœ ๋‚˜๋‰œ๋‹ค. ๊ฐ๊ฐ์— ๋Œ€ํ•ด์„œ ์•Œ์•„๋ณด์ž

1. Ridge

โ–ค Ridge docu โ–ค

https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.Ridge.html

 

class sklearn.linear_model.Ridge(alpha=1.0, *, fit_intercept=True, normalize='deprecated', copy_X=True, max_iter=None, tol=0.001, solver='auto', positive=False, random_state=None)

 

๐Ÿ‘‰ 'Linear least squares with l2 regularization. Minimizes the objective function(cost function์ด๋ผ๊ณ ๋„ ํ•˜๋ฉฐ ์•„๋ž˜ bold์ฒด) This model solves a regression model where the loss function is the linear least squares function and regularization is given by the l2-norm. Also known as Ridge Regression or Tikhonov regularization. This estimator has built-in support for multi-variate regression(๋‹ค์ค‘ ํšŒ๊ท€์—๋„ ์ ์šฉ ๊ฐ€๋Šฅ์–˜๊ธฐ) (i.e., when y is a 2d-array of shape (n_samples, n_targets)'

 

" ||y - Xw||^2_2(SSR) + alpha * ||w||^2_2(L2-norm) "

 

- ์ผ๋ถ€ ์ค‘์š” parameter๋ฅผ ๋ณด๋ฉด .. -

 

 alpha) (default = 1.0) 'Regularization strength; must be a positive float. Regularization improves the conditioning of the problem and reduces the variance of the estimates. Larger values specify stronger regularization.'

= concept ํฌ์ŠคํŒ…์—์„œ ๋‹ค๋ฃฌ penalty ๋ถ€๊ณผ ์ •๋„ lambda ๊ฐ’์„ ๋งํ•œ๋‹ค

 

 max_iter & solver - ๋‚ด๋ถ€ data type์— ๋”ฐ๋ผ ridge ๊ตฌํ•˜๋Š” ์ตœ์ ์˜ ์—ฐ์‚ฐ๋ฒ•์„ auto ์ž๋™์œผ๋กœ ์ฐพ์•„์ฃผ๋Š”๋ฐ, ์ด ๋•Œ์˜ ์—ฐ์‚ฐ๋ฒ•์„ ์ž„์˜๋กœ ์ง€์ •ํ•ด์„œ ํ•ด๋‹น ์—ฐ์‚ฐ๋ฒ•์œผ๋กœ ridge๋ฅผ ๊ตฌํ•˜๊ฒŒ ์„ค์ •ํ•  ์ˆ˜ ์žˆ๋‹ค. (max_iter๋Š” ์ด ๋•Œ ์—ฐ์‚ฐ๋ฒ• ๋ฐ˜๋ณต ํšŸ์ˆ˜)

(- ๋‹ค์–‘ํ•œ ์ข…๋ฅ˜์˜ solver๊ฐ€ ์žˆ์œผ๋‚˜ ๋„ˆ๋ฌด ์‹ฌํ™” ๋‚ด์šฉ์ด๋ผ pass - ๐Ÿ˜…)


ใ€Œalpha ์ฆ๊ฐ€์— ๋”ฐ๋ฅธ Ridge ์„ ํ˜•๋ชจ๋ธ ๋ณ€ํ™” ์‹œ๊ฐํ™” ๐Ÿ‘€ ใ€

 

→ ์šฐ๋ฆฌ๋Š” alpha(์ฆ‰ lambda)๊ฐ’์— ๋”ฐ๋ผ penalty์˜ ํฌ๊ณ  ์ž‘์Œ์— ์˜ํ–ฅ์„ ์ค˜์„œ Ridge ๋ชจ๋ธ์ด ๊ธฐ์กด SLR(Simple Linear Regression) ๋ชจ๋ธ์˜ ๊ณผ์ ํ•ฉ์„ฑ์„ ํ•ด๊ฒฐํ•˜๊ณ ์ž, ์ฆ‰ ๋” generalized๋œ model์„ ๋งŒ๋“ค ์ˆ˜ ์žˆ๋‹ค๊ณ  ์–ธ๊ธ‰ํ–ˆ๋‹ค.

→ ์šฐ๋ฆฌ๋Š” Ridge()๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์—ฌ๋Ÿฌ alpha๊ฐ’์„ ์ง‘์–ด๋„ฃ๊ณ  ๊ฐ alpha๊ฐ’์„ ๋„ฃ์€ Ridge ๋ชจ๋ธ์„ ๋ชจ๋‘ ์‹œ๊ฐํ™”ํ•˜์—ฌ ๊ฐ๊ฐ์˜ ์ฐจ์ด์ ์„ ๋น„๊ตํ•ด๋ณผ ์ˆ˜ ์žˆ๋‹ค!

 

1> iris dataset ์ค€๋น„

2> SLR๋ชจ๋ธ๊ณผ์˜ ๋น„๊ต๋ฅผ ์œ„ํ•ด y์ข…์†๋ณ€์ˆ˜๋Š” 'petal length' & x๋…๋ฆฝ๋ณ€์ˆ˜๋Š” 'sepal length' 1๊ฐœ ํ•œ์ •

3> alpha๊ฐ’์€ 0๋ถ€ํ„ฐ 20, 40, 60, 80 ๊นŒ์ง€ ์ด 5๊ฐ€์ง€์˜ Ridge model ์ค€๋น„

(์—ฌ๊ธฐ์„œ alpha๊ฐ€ 0์ผ๋•Œ๋Š” penalty๋ฅผ ์•„์˜ˆ ๋ถ€๊ณผํ•˜์ง€ ์•Š๊ฒ ๋‹ค๋Š” ๋œป์œผ๋กœ SLR model์ด ๊ณง Ridge model)

4> ์ด 5๊ฐœ์˜ Ridge model์„ ์‹œ๊ฐํ™”ํ•˜์—ฌ ์œก์•ˆ์ƒ ์ฐจ์ด์ ์„ ํ™•์ธํ•ด๋ณด์ž

 

import matplotlib.pyplot as plt
import matplotlib
from sklearn.linear_model import Ridge
import seaborn as sns
import numpy as np
import pandas as pd

#preprocessing
df = sns.load_dataset('iris')
df.drop(columns=['sepal_width','species','petal_width'],inplace=True)

plt.figure(figsize=(6,7))

title_font = {
    'fontsize': 16,
    'fontweight': 'light'
}

plt.title('Sepal Length vs. Petal Length - SLR vs Ridge', pad=15, fontdict=title_font)
plt.xlabel('Sepal Length', labelpad=10, size=13)
plt.ylabel('Petal Length', labelpad=10, size=13)
plt.scatter(df['sepal_length'], df['petal_length'],color = '#C6492B')

x_lim = plt.xlim()

alphas = np.arange(0,100,20)

for alpha in alphas:
    #get a Ridge model
    ridge = Ridge(alpha=alpha)
    
    #fitting
    ridge.fit(df[['sepal_length']], df['petal_length'])

    slope = ridge.coef_
    intercept = ridge.intercept_
    
    x = x_lim
    
    #visualization
    plt.plot(x, slope*x + intercept, linewidth = 3, label = f'alpha {alpha}')
    plt.grid(True, linestyle='--')
    plt.legend()
    plt.style.use('default')
    
plt.axhline(df['petal_length'].mean(), 0, 1, color = 'red', linewidth=3)

 

 

→ ํ•ด์„ 1> alpha๊ฐ€ ์ฆ๊ฐ€ํ• ์ˆ˜๋ก ๊ธฐ์šธ๊ธฐ๊ฐ€ ๊ฐ์†Œํ•˜๋Š” ๊ฒƒ์„ ๋ณผ ์ˆ˜ ์žˆ๋‹ค. ์ด๋Š” lambda๊ฐ’์„ ์ฆ๊ฐ€์‹œํ‚จ๋‹ค๋ฉด cost function์„ ์ตœ์†Œํ™”ํ•˜๊ธฐ ์œ„ํ•œ ๋ชฉ์ ์œผ๋กœ ํšŒ๊ท€๊ณ„์ˆ˜์ œ๊ณฑํ•ฉ์„ ๊ฐ์†Œ์‹œ์ผœ์•ผ ํ•˜๋ฏ€๋กœ - ํ•ด๋‹น ๊ธฐ์กด SLR ๋ชจ๋ธ์—์„œ์˜ ํšŒ๊ท€๊ณ„์ˆ˜์ธ ๊ธฐ์šธ๊ธฐ๊ฐ’์„ ๊ฒฐ๊ณผ์ ์œผ๋กœ ๊ฐ์†Œ์‹œํ‚จ ํšจ๊ณผ

→ ํ•ด์„ 2> ๊ทธ๋Ÿฌ๋‚˜ alpha๋ฅผ ์ ์  ์ฆ๊ฐ€์‹œํ‚ฌ์ˆ˜๋ก SLR model์˜ basline model์— ์ ์  ๊ฐ€๊นŒ์›Œ์ง€๋Š” ๊ฒƒ์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ๋‹ค. ๋”ฐ๋ผ์„œ ์–ด๋Š ์ •๋„์˜ ์‹œ์ ์—์„œ ๋ฉˆ์ถฐ์•ผ ํ•œ๋‹ค!

 

๐Ÿ™ ์ฆ‰, ์šฐ๋ฆฌ๋Š” ์ตœ์ ์˜ alpha๋ฅผ ๊ตฌํ•  ์ˆ˜ ์žˆ์–ด์•ผ ํ•œ๋‹ค ๐Ÿ™

 

→ alpha ํ›„๋ณด๊ฐ’๋“ค์„ ๋ชจ๋‘ ridge์— ๋Œ€์ž…ํ•ด ๊ฐ€๋ฉด์„œ cross-validation ๊ธฐ๋ฒ•์œผ๋กœ ์ตœ์ ์˜ alpha๋ฅผ ์ฐพ์•„์•ผ ํ•œ๋‹ค!
(์ตœ์ ์˜ alpha ์ฐพ๋Š” ๊ธฐ์ค€์€ evaluation metrics (scoring system)์— ์˜๊ฑฐํ•˜์—ฌ ์ฐพ์Œ)

 

(*CV ๊ธฐ๋ฒ• ๊ด€๋ จ ํฌ์ŠคํŒ…์€ ํ•˜๋‹จ ์ฐธ์กฐ ↓↓↓↓)

 

Cross-Validation (concepts)

* ๋จธ์‹ ๋Ÿฌ๋‹์„ ์œ„ํ•ด์„œ ๋ฌด.์กฐ.๊ฑด. ์•Œ์•„์•ผ ํ•˜๋Š” CROSS-VALIDATION! ๊ฐ„๋‹จํžˆ ๊ฐœ๋…๋งŒ ์•Œ์•„๋ณดZA * - 2๋ฒˆ ๊ณผ์ • - model selection์—์„œ ์ฃผ๋กœ ๋งŽ์ด ์“ฐ์ด๋Š” cross-validation ๊ธฐ๋ฒ• - ๐Ÿง PURPOSE? 'The purpose of cross..

sh-avid-learner.tistory.com

 

 ์—ฌ๋Ÿฌ alpha ํ›„๋ณด๊ตฐ๋“ค์„ ๋„ฃ์–ด์„œ ์•Œ์•„์„œ ์ตœ์ ์˜ alpha๋ฅผ ์ฐพ์•„ Ridge model์„ ๋งŒ๋“ค์–ด์ฃผ๋Š” ํ•จ์ˆ˜๊ฐ€ ๋”ฐ๋กœ ์กด์žฌํ•œ๋‹ค! - RidgeCV

2. RidgeCV

โ–ค RidgeCV docu โ–ค

https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.RidgeCV.html#sklearn.linear_model.RidgeCV

 

class sklearn.linear_model.RidgeCV(alphas=(0.1, 1.0, 10.0), *, fit_intercept=True, normalize='deprecated', scoring=None, cv=None, gcv_mode=None, store_cv_values=False, alpha_per_target=False)

 

๐Ÿ‘‰ 'Ridge regression with built-in cross-validation' - ์—ฌ๋Ÿฌ alpha๊ฐ’๋“ค์„ list ํ˜•ํƒœ๋กœ alphas์— ์ง‘์–ด๋„ฃ์œผ๋ฉด ํ•ด๋‹น alpha ์ค‘ ์ตœ์ ์˜ alpha๋ฅผ built-in cv๊ธฐ๋ฒ•(Leave-One-Out CV)์„ ์‚ฌ์šฉํ•˜์—ฌ ์ฐพ๋Š”๋‹ค. ์—ฌ๊ธฐ์„œ scoring ์ธ์ž์— ์›ํ•˜๋Š” metrics ์ข…๋ฅ˜๋ฅผ ์ง‘์–ด๋„ฃ์–ด ์ตœ์ ์˜ alpha๋ฅผ ์–ด๋–ค ์ง€ํ‘œ๋กœ ์ฐพ๋Š” ์ง€ ์ˆ˜๋™์œผ๋กœ ๋„ฃ์„ ์ˆ˜ ์žˆ๋‹ค.

 

→ cv์ธ์ž) ๋ช‡ fold์˜ cross-validation ์‚ฌ์šฉํ•  ์ง€ ๊ฒฐ์ • (10์„ ๊ถŒ์žฅ)

 

→ alphas์ธ์ž) ๊ฒ€์ฆํ•˜๊ณ  ์‹ถ์€ alpha๋“ค list ํ˜•ํƒœ๋กœ ์ง‘์–ด๋„ฃ๊ธฐ

 

→ scoring ์ธ์ž) ์ตœ์ ์˜ alpha๋ฅผ ๊ตฌํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉํ•˜๋Š” scroing evaluation metrics

- default๋Š” None) 'If None, the negative mean squared error if cv is ‘auto’ or None (i.e. when using leave-one-out cross-validation), and r2 score otherwise.' = '์ฆ‰ cv๊ฐ’์ด ์—†์œผ๋ฉด NMSE๋ฅผ ์‚ฌ์šฉํ•˜๋‚˜ cv๊ฐ’์ด ๋ช…์‹œ๋˜์–ด ์žˆ์œผ๋ฉด r2๊ฐ’ ์‚ฌ์šฉ'

> ์—ฌ๊ธฐ์„œ NMSE๋Š” MSE๊ฐ’์— ์Œ์ˆ˜(-)๋ฅผ ๊ณฑํ•œ ๊ฒƒ์ผ ๋ฟ - ์ฆ‰ MSE์™€ ๋ฐ˜๋Œ€๋กœ NMSE๊ฐ€ ์ปค์ง€๋Š” ๋ฐฉํ–ฅ ์ชฝ์ด ๋ฐ”๋žŒ์งํ•จ!

 

(evaluation metrics ๊ด€๋ จ ํฌ์ŠคํŒ…์€ ์•„๋ž˜ ์ฐธ์กฐ ↓↓)

 

All About Evaluation Metrics(1/2) → MSE, MAE, RMSE, R^2

** ML ๋ชจ๋ธ์˜ ์„ฑ๋Šฅ์„ ์ตœ์ข…์ ์œผ๋กœ ํ‰๊ฐ€ํ•  ๋•Œ ๋‹ค์–‘ํ•œ evaluation metrics๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค๊ณ  ํ–ˆ์Œ! ** (supervised learning - regression problem์—์„œ ๋งŽ์ด ์“ฐ์ด๋Š” ํ‰๊ฐ€์ง€ํ‘œ๋“ค) - ๊ณผ์ • (5) - ๐Ÿ˜™ ๊ทธ๋Ÿฌ๋ฉด ์ฐจ๊ทผ์ฐจ..

sh-avid-learner.tistory.com

 

+) ์ถ”๊ฐ€๋กœ model attributes๋กœ best_score_์ด ์žˆ๋Š”๋ฐ ํ•ด๋‹น attribute๋ฅผ ํ†ตํ•ด ์ตœ์ ์˜ alpha๋ฅผ ๊ตฌํ•  ๋•Œ ์‚ฌ์šฉํ•œ ์ตœ์ ์˜ score๊ฐ’์„ ๋”ฐ๋กœ ์ถœ๋ ฅํ•  ์ˆ˜ ์žˆ๋‹ค 

 

> ์œ„ iris dataset ์˜ˆ๋ฅผ ๊ทธ๋Œ€๋กœ ๊ฐ€์ ธ์™€์„œ ์ด 7๊ฐœ์˜ alpha ์ค‘ ์ตœ์ ์˜ alpha๋ฅผ 5-folds CV๋ฅผ ์ด์šฉํ•ด ์ฐพ์•„๋ณด๋ฉด.. (NMSE scoring system)

(df๋ฅผ train๊ณผ test๋กœ ๋‚˜๋ˆ„๊ณ  ridge model์— train data๋ฅผ fittingํ–ˆ๋‹ค)

 

train = df.sample(frac=0.75,random_state=1)
test = df.drop(train.index)

target = 'petal_length'

## X_train, y_train, X_test, y_test ๋ฐ์ดํ„ฐ๋กœ ๋ถ„๋ฆฌ
X_train = train.drop(columns=target)
y_train = train[target]
X_test = test.drop(columns=target)
y_test = test[target]

from sklearn.metrics import mean_squared_error, r2_score
from sklearn.linear_model import RidgeCV 
alphas = [0.01, 0.05, 0.1, 0.2, 1.0, 10.0, 100.0] 
ridge = RidgeCV(alphas=alphas, cv=5) 

#fitting 
ridge.fit(X_train, y_train) 

print(ridge.coef_, ridge.intercept_, ridge.alpha_)
print(ridge.best_score_)

#[1.85727652] -7.153726228538956 1.0
#0.7520930909807484

 

> alpha๊ฐ€ 1์ผ ๋•Œ์ด๋ฉฐ, y =1.85727652x -7.153726228538956์— ํ•ด๋‹นํ•˜๋Š” ์ง์„ ์ด๋‹ค.

→ ํ•ด๋‹น alpha๋“ค ์ค‘ ํ•œ์ •ํ•ด์„œ ์ตœ์ ์˜ Ridge๋ฅผ ๊ตฌํ•œ ๊ฒƒ์ด๊ธฐ ๋•Œ๋ฌธ์— ๋งŒ์•ฝ SLR & MLR ๋ชจ๋ธ์—์„œ ๊ณผ์ ํ•ฉ์ด ๋ฐœ์ƒํ–ˆ๋‹ค๋ฉด ๋‹ค์–‘ํ•œ alpha๋ฅผ ์ง‘์–ด๋„ฃ์–ด ์ •๋ฐ€์„ฑ์„ ๋†’์ผ ํ•„์š”๊ฐ€ ์žˆ๋‹ค๐Ÿ‘

- ์ด ๋•Œ ์ตœ์ ์˜ alpha๋ฅผ ์ฐพ๊ธฐ ์œ„ํ•ด ์ˆ˜๋™์œผ๋กœ ์—ฌ๋Ÿฌ alpha์—์„œ ๊ตฌํ•˜๋Š” ๋Œ€์‹  GridSearchCV๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ๋„ ํ•œ๋‹ค (์ถ”ํ›„ ํฌ์ŠคํŒ… ์˜ˆ์ •)

 

> Q.) ๊ทธ๋Ÿฌ๋ฉด ๊ณผ์—ฐ ๊ธฐ์กด SLR ๋ชจ๋ธ๋ณด๋‹ค Ridge ์ ์šฉํ•œ ํ›„์˜ ๋ชจ๋ธ ์„ฑ๋Šฅ์ด ๋” ์ข‹์•„์กŒ์„๊นŒ?

→ test set์„ ์ ์šฉํ•ด๋ณด์ž

 

1) ridge์ผ ๋•Œ์˜ r2_score & MSE

 

#predicting 
y_test_pred = ridge.predict(X_test)

print(r2_score(y_test, y_test_pred), mean_squared_error(y_test, y_test_pred))
#0.7288552126544037 0.7451543211624959

 

2) SLR ๋ชจ๋ธ์ผ ๋•Œ์˜ r2_score & MSE

 

from sklearn.linear_model import LinearRegression

model = LinearRegression()

model.fit(X_train, y_train)

#predicting 
y_test_pred_SLR = model.predict(X_test)

print(r2_score(y_test, y_test_pred_SLR), mean_squared_error(y_test, y_test_pred_SLR))
#0.727547500747554 0.7487481471318764

 

๐Ÿ’๐Ÿป‍โ™‚๏ธ ํ™•์‹คํžˆ alpha=0 ์ฆ‰, ๊ธฐ์กด ๋‹จ์ˆœ์„ ํ˜•ํšŒ๊ท€(SLR) ๋ชจ๋ธ์ผ ๋•Œ๋ณด๋‹ค r2_score๊ฐ’์€ 0.727์—์„œ 0.729๋กœ ์†Œํญ ์ƒ์Šนํ–ˆ๊ณ , MSE๊ฐ’์€ 0.748์—์„œ 0.745๋กœ ์•ฝ๊ฐ„ ๊ฐ์†Œํ•˜์—ฌ ์กฐ๊ธˆ์ด๋ผ๋„ ๋” ์„ฑ๋Šฅ์ด ์ข‹์€ ๋ชจ๋ธ์„ ๋งŒ๋“ค์—ˆ๋‹ค๊ณ  ๊ฒฐ๋ก ์„ ๋‚ด๋ฆด ์ˆ˜ ์žˆ์Œ.

 

์ฆ‰ L2 ๊ทœ์ œ๊ฐ€ ๋ณธ๋ž˜์˜ ๋ชฉ์ ์„ ๋‹ฌ์„ฑํ•œ ๊ฒƒ์ด๋‹ค!

 

(๋ณธ๋ž˜ ridge ๊ทœ์ œ๋Š” ๊ธฐ์กด ๋ชจ๋ธ์ด ๊ณผ์ ํ•ฉ์„ ์ผ์œผ์ผœ ๋„ˆ๋ฌด train data์— ๋งž์ถฐ์ ธ ์žˆ์„ ๋•Œ ์ด๋ฅผ ์–ด๋Š ์ •๋„ ๊ทœ์ œ๋ฅผ ํ”ผํ•˜๊ณ ์ž ํ•˜๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉํ•œ๋‹ค. ๋”ฐ๋ผ์„œ ๋‹คํ•ญํšŒ๊ท€๋ชจ๋ธ(์„ ํ˜•๋ง๊ณ ๋„ ๋‹คํ•ญ๋ชจ๋ธ)๋กœ ๊ณผ์ ํ•ฉ์„ ์ผ์œผํ‚ฌ ๊ฒฝ์šฐ ridge ๊ทœ์ œ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” case๊ฐ€ ๋งŽ์€ ๋ฐ ๊ณผ์—ฐ PR ๋ชจ๋ธ์— ๊ทœ์ œ๋ฅผ ๊ฐ€ํ•œ ๊ฒฐ๊ณผ ์„ฑ๋Šฅ์ด ์ข‹์•„์ง€๋Š” ์ง€๋Š” ๋‹ค์Œ ํฌ์ŠคํŒ…์—์„œ ์‹คํ—˜ํ•ด๋ณผ ์˜ˆ์ •!

 

- Ridge ๊ธฐ์ดˆ ๋! -

(์ด์   ๋‹ค๋ฅธ L1 Regularization์œผ๋กœ ๋งŒ๋“  LASSO์™€ ๋น„๊ตํ•ด๋ณด์ž)

 

* ์ถœ์ฒ˜) https://www.mygreatlearning.com/blog/what-is-ridge-regression/

'Machine Learning > Models (with codes)' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

Polynomial Regression Model  (0) 2022.04.24
Logistic Regression Model (concepts)  (0) 2022.04.24
(L2 Regularization) โ†’ Ridge Regression (concepts)  (0) 2022.04.19
Multiple Linear Regression Model (concepts+w/code)  (0) 2022.04.17
Simple Linear Regression Model (w/scikit-learn)  (0) 2022.04.16

๋Œ“๊ธ€