Created
April 5, 2019 11:10
-
-
Save gf712/c6a98704bae6fa22026f1e03148173ab to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import shogun as sg | |
from sklearn import datasets | |
X, y = datasets.load_breast_cancer(True) | |
y[y==0] = -1 | |
feat = sg.features(X.T) | |
kernel1 = sg.kernel("GaussianKernel") | |
kernel2 = sg.kernel("PolyKernel") | |
svm = sg.machine("LibSVM", epsilon=1, kernel=kernel1, labels=sg.BinaryLabels(y)) | |
node = sg.GridSearch(svm) | |
node.attach("kernel::log_width", np.array([1., 2.])) | |
node.attach("C1", np.array([1., 2., 3.])) | |
node.attach("C2", np.array([1., 2., 3.])) | |
node2=sg.GridParameters(kernel2) | |
node2.attach("degree", np.array([1,2], np.int32)) | |
node.attach("kernel", node2) | |
node.train(feat) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment