Évariste Galois
Évariste Galois

Reputation: 1033

training an alpha value for ridge regression

I have the following code which runs a simple Ridge regression:

for col in cols:                      #zscore normalization
    df[col] = (df[col] - df[col].mean())/df[col].std(ddof=0)
y = df['SPXR_{}D'.format(horizon)]    #my dependent variable (future market returns)
x = df[cols]                          #a bunch of variables that predict market returns
model = linear_model.Ridge(alpha=0.5) #ridge regression, guess & check based alpha
res = model.fit(x, y)

I have read that using the first half of my data to find an alpha is the easiest approach, however how is this possible?

Upvotes: 2

Views: 2964

Answers (1)

Jan K
Jan K

Reputation: 4150

Let me point you in 2 possible directions.

1) Cross validation:

  • RidgeCV - Just a convenient wrapper combining GridSearchCV and Ridge. Fit the model and check the attribute _alpha.

2) Bayesian approach:

Upvotes: 2

Related Questions