Exemplo n.º 1
0
    def fit(self, data, args):
        self.model = NuSVC(probability=True)

        with Timer() as t:
            self.model.fit(data.X_train, data.y_train)

        return t.interval
Exemplo n.º 2
0
 def fit(self, X, y=None):
     self._sklearn_model = SKLModel(**self._hyperparams)
     if (y is not None):
         self._sklearn_model.fit(X, y)
     else:
         self._sklearn_model.fit(X)
     return self
Exemplo n.º 3
0
 def __init__(self,
              nu=0.5,
              kernel='rbf',
              degree=3,
              gamma='auto_deprecated',
              coef0=0.0,
              shrinking=True,
              probability=False,
              tol=0.001,
              cache_size=200,
              class_weight='balanced',
              verbose=False,
              max_iter=(-1),
              decision_function_shape='ovr',
              random_state=None):
     self._hyperparams = {
         'nu': nu,
         'kernel': kernel,
         'degree': degree,
         'gamma': gamma,
         'coef0': coef0,
         'shrinking': shrinking,
         'probability': probability,
         'tol': tol,
         'cache_size': cache_size,
         'class_weight': class_weight,
         'verbose': verbose,
         'max_iter': max_iter,
         'decision_function_shape': decision_function_shape,
         'random_state': random_state
     }
     self._wrapped_model = Op(**self._hyperparams)
Exemplo n.º 4
0
class NuSVCImpl():

    def __init__(self, nu=0.5, kernel='rbf', degree=3, gamma='auto_deprecated', coef0=0.0, shrinking=True, probability=False, tol=0.001, cache_size=200, class_weight='balanced', verbose=False, max_iter=(- 1), decision_function_shape='ovr', random_state=None):
        self._hyperparams = {
            'nu': nu,
            'kernel': kernel,
            'degree': degree,
            'gamma': gamma,
            'coef0': coef0,
            'shrinking': shrinking,
            'probability': probability,
            'tol': tol,
            'cache_size': cache_size,
            'class_weight': class_weight,
            'verbose': verbose,
            'max_iter': max_iter,
            'decision_function_shape': decision_function_shape,
            'random_state': random_state}

    def fit(self, X, y=None):
        self._sklearn_model = SKLModel(**self._hyperparams)
        if (y is not None):
            self._sklearn_model.fit(X, y)
        else:
            self._sklearn_model.fit(X)
        return self

    def predict(self, X):
        return self._sklearn_model.predict(X)

    def predict_proba(self, X):
        return self._sklearn_model.predict_proba(X)
Exemplo n.º 5
0
 def test_kernel_sigmoid(self):
     clf = NuSVC(kernel='sigmoid', gamma=0.001, random_state=0)
     self._port_model(clf)
     php_preds, py_preds = [], []
     min_vals = np.amin(self.X, axis=0)
     max_vals = np.amax(self.X, axis=0)
     for n in range(self.n_random_tests):
         x = [
             random.uniform(min_vals[f], max_vals[f])
             for f in range(self.n_features)
         ]
         php_preds.append(self.make_pred_in_php(x))
         py_preds.append(self.make_pred_in_py(x))
     self.assertListEqual(py_preds, php_preds)
Exemplo n.º 6
0
 def test_kernel_poly(self):
     clf = NuSVC(kernel='poly', gamma=0.001, random_state=0)
     self._port_model(clf)
     Y, Y_py = [], []
     min_vals = np.amin(self.X, axis=0)
     max_vals = np.amax(self.X, axis=0)
     for n in range(self.n_random_tests):
         x = [
             random.uniform(min_vals[f], max_vals[f])
             for f in range(self.n_features)
         ]
         Y.append(self.make_pred_in_custom(x))
         Y_py.append(self.make_pred_in_py(x))
     self.assertListEqual(Y, Y_py)
Exemplo n.º 7
0
 def setUp(self):
     super(NuSVCPHPTest, self).setUp()
     self.estimator = NuSVC(kernel='rbf', gamma=0.001, random_state=0)
Exemplo n.º 8
0
 def setUp(self):
     super(SVCTest, self).setUp()
     self.porter = Porter(language='php')
     clf = NuSVC(kernel='rbf', gamma=0.001, random_state=0)
     self._port_model(clf)
Exemplo n.º 9
0
 def setUp(self):
     super(NuSVCJavaTest, self).setUp()
     self.mdl = NuSVC(kernel='rbf', gamma=0.001, random_state=0)
Exemplo n.º 10
0
    BernoulliNB(),
    CalibratedClassifierCV(),
    DecisionTreeClassifier(),
    ExtraTreeClassifier(),
    ExtraTreesClassifier(),
    GaussianNB(),
    GaussianProcessClassifier(),
    GradientBoostingClassifier(),
    KNeighborsClassifier(),
    LabelPropagation(),
    LabelSpreading(),
    LinearDiscriminantAnalysis(),
    LogisticRegression(),
    LogisticRegressionCV(),
    MLPClassifier(),
    NuSVC(probability=True),
    QuadraticDiscriminantAnalysis(),
    RandomForestClassifier(),
    SGDClassifier(loss='log'),
    SVC(probability=True),
    XGBClassifier()
]

names = [
    'AdaBoostClassifier', 'BaggingClassifier', 'BernoulliNB',
    'CalibratedClassifierCV', 'DecisionTreeClassifier', 'ExtraTreeClassifier',
    'ExtraTreesClassifier', 'GaussianNB', 'GaussianProcessClassifier',
    'GradientBoostingClassifier', 'KNeighborsClassifier', 'LabelPropagation',
    'LabelSpreading', 'LinearDiscriminantAnalysis', 'LogisticRegression',
    'LogisticRegressionCV', 'MLPClassifier', 'NuSVC',
    'QuadraticDiscriminantAnalysis', 'RandomForestClassifier', 'SGDClassifier',
Exemplo n.º 11
0
			'MeanShift':MeanShift(),
			'MinCovDet':MinCovDet(),
			'MinMaxScaler':MinMaxScaler(),
			'MiniBatchDictionaryLearning':MiniBatchDictionaryLearning(),
			'MiniBatchKMeans':MiniBatchKMeans(),
			'MiniBatchSparsePCA':MiniBatchSparsePCA(),
			'MultiTaskElasticNet':MultiTaskElasticNet(),
			'MultiTaskElasticNetCV':MultiTaskElasticNetCV(),
			'MultiTaskLasso':MultiTaskLasso(),
			'MultiTaskLassoCV':MultiTaskLassoCV(),
			'MultinomialNB':MultinomialNB(),
			'NMF':NMF(),
			'NearestCentroid':NearestCentroid(),
			'NearestNeighbors':NearestNeighbors(),
			'Normalizer':Normalizer(),
			'NuSVC':NuSVC(),
			'NuSVR':NuSVR(),
			'Nystroem':Nystroem(),
			'OAS':OAS(),
			'OneClassSVM':OneClassSVM(),
			'OrthogonalMatchingPursuit':OrthogonalMatchingPursuit(),
			'OrthogonalMatchingPursuitCV':OrthogonalMatchingPursuitCV(),
			'PCA':PCA(),
			'PLSCanonical':PLSCanonical(),
			'PLSRegression':PLSRegression(),
			'PLSSVD':PLSSVD(),
			'PassiveAggressiveClassifier':PassiveAggressiveClassifier(),
			'PassiveAggressiveRegressor':PassiveAggressiveRegressor(),
			'Perceptron':Perceptron(),
			'ProjectedGradientNMF':ProjectedGradientNMF(),
			'QuadraticDiscriminantAnalysis':QuadraticDiscriminantAnalysis(),
Exemplo n.º 12
0
 def setUp(self):
     super(SVCTest, self).setUp()
     mdl = NuSVC(kernel='rbf', gamma=0.001, random_state=0)
     self._port_model(mdl)