Регуляризация хребта - Тестирование числа альф - PullRequest
0 голосов
/ 08 октября 2019

Надеюсь, вы можете помочь мне с этой проблемой.

Учитывая случайный набор данных ниже,

from sklearn.linear_model import RidgeCV, Ridge
import numpy as np
import pandas as pd
import random

#Define input Array
x = np.array([i*np.pi/180 for i in range(60,300,4)])
np.random.seed(1)  #Setting seed for reproducability
y = np.sin(x) + np.random.normal(0,0.15,len(x))
z =  np.random.normal(0,0.15,len(x))
data = pd.DataFrame(np.column_stack([x,y,z]),columns=['x','y','z'])

We set our independant variables

x=data.iloc[:,0:2].values
y=data.iloc[:,-1:].values

and if we run the following code to retrieve the best alpha and best score 
given np.logspace(-3,4,100)

import statistics
scores = []
alphas = np.logspace(-3,4,100)
regr_cv = RidgeCV(alphas, cv=None)
model_cv = regr_cv.fit(x, y)
best_alpha=model_cv.alpha_
print ("Best Alpha:",best_alpha )

We get
Best Alpha: 10000.0 

My question,what are appropriate values to get the best alpha and best score 

Notice, 

If you change the range values and the number of alphas that will test the parameters of regularization both scores will change, increase or decrease.

Итак, мой вопрос, как мы выбираем значения для n1, n2, n_alphas? когда: alphas = np.logspace (n1, n2, n_alphas) ​​

Любой совет?

Спасибо, если вы можете помочь.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...