def apply(self): kernel = ["linear", "poly", "rbf", "sigmoid"][self.kernel_type] common_args = dict(kernel=kernel, degree=self.degree, gamma=self.gamma, coef0=self.coef0, tol=self.tol, preprocessors=self.preprocessors) if self.svrtype == OWSVMRegression.Epsilon_SVR: learner = SVRLearner(C=self.epsilon_C, epsilon=self.epsilon, **common_args) else: learner = NuSVRLearner(C=self.nu_C, nu=self.nu, **common_args) learner.name = self.learner_name predictor = None sv = None if self.data is not None: self.error(0) if not learner.check_learner_adequacy(self.data.domain): self.error(0, learner.learner_adequacy_err_msg) else: predictor = learner(self.data) predictor.name = self.learner_name sv = self.data[predictor.skl_model.support_] self.send("Learner", learner) self.send("Predictor", predictor) self.send("Support vectors", sv)
def apply(self): kernel = ["linear", "poly", "rbf", "sigmoid"][self.kernel_type] common_args = dict( kernel=kernel, degree=self.degree, gamma=self.gamma, coef0=self.coef0, tol=self.tol, preprocessors=self.preprocessors ) if self.svrtype == OWSVMRegression.Epsilon_SVR: learner = SVRLearner( C=self.epsilon_C, epsilon=self.epsilon, **common_args ) else: learner = NuSVRLearner(C=self.nu_C, nu=self.nu, **common_args) learner.name = self.learner_name predictor = None sv = None if self.data is not None: self.error(0) if not learner.check_learner_adequacy(self.data.domain): self.error(0, learner.learner_adequacy_err_msg) else: predictor = learner(self.data) predictor.name = self.learner_name sv = self.data[predictor.skl_model.support_] self.send("Learner", learner) self.send("Predictor", predictor) self.send("Support vectors", sv)
def test_SVR(self): nrows, ncols = 200, 5 X = np.random.rand(nrows, ncols) y = X.dot(np.random.rand(ncols)) data = Table(X, y) learn = SVRLearner(kernel='rbf', gamma=0.1) res = CrossValidation(data, [learn], k=2) self.assertLess(RMSE(res)[0], 0.15)
def test_LinearSVR(self): nrows, ncols = 200, 5 X = np.random.rand(nrows, ncols) y = X.dot(np.random.rand(ncols)) data = Table(X, y) learn = SVRLearner() cv = CrossValidation(k=2) res = cv(data, [learn]) self.assertLess(RMSE(res)[0], 0.15)
def test_SVR(self): nrows, ncols = 200, 5 X = np.random.rand(nrows, ncols) y = X.dot(np.random.rand(ncols)) data = Table.from_numpy(None, X, y) learn = SVRLearner(kernel='rbf', gamma=0.1) cv = CrossValidation(k=2) res = cv(data, [learn]) self.assertLess(RMSE(res)[0], 0.15)
def create_learner(self): kernel = ["linear", "poly", "rbf", "sigmoid"][self.kernel_type] common_args = dict(kernel=kernel, degree=self.degree, gamma=self.gamma, coef0=self.coef0, tol=self.tol, preprocessors=self.preprocessors) if self.svrtype == OWSVMRegression.Epsilon_SVR: return SVRLearner(C=self.epsilon_C, epsilon=self.epsilon, **common_args) else: return NuSVRLearner(C=self.nu_C, nu=self.nu, **common_args)