Alphas selection--> getting best alpha

10 views
Skip to first unread message

dani.l...@gmail.com

unread,
Oct 2, 2019, 11:03:03 AM10/2/19
to Yellowbrick
Hi everybody.
Can anyone tellme how to get the alpha that minimize my error? It is printed in the plot but I wish to automatize some features

Here is my code

n_alphas =200
alphas = np.logspace(-4,3,n_alphas)

#Y and X
n=1
Y=array[:,0]
X=array[:,1:8*n+1]
numpy.set_printoptions(threshold=sys.maxsize)

#validation VS train

validation_size = 0.20
seed = 7
X_train, X_validation, Y_train, Y_validation = model_selection.train_test_split(X, Y, test_size=validation_size, random_state=seed)

 #data balancing
scaler = StandardScaler()
scaler.fit(X_train)
X_train = scaler.transform(X_train)
X_validation = scaler.transform(X_validation)
 #end balancing

model = RidgeCV(alphas=alphas)
visualizer = AlphaSelection(model)
visualizer.fit(X_train, Y_train)
plt.grid(True)


visualizer.poof(outpath="RidgeCV n={}.png".format(n))   
visualizer.finalize()


Thanks!

Benjamin Bengfort

unread,
Oct 2, 2019, 3:44:54 PM10/2/19
to Yellowbrick
Hello, 

You can access the selected alpha for RidgeCV via the visualizer.alpha_ property, generally speaking, you can access any of the learned properties from the underlying estimator directly through the model visualizer, or if you're having problems you can go directly to visualizer.estimator if needed. Thanks for using Yellowbrick and let us know if we can be of any further assistance!

Best Regards,
Benjamin Bengfort
Reply all
Reply to author
Forward
0 new messages