Exemplo n.º 1
0
 def decision_function(self, X) -> CumlArray:
     """
     Calculate the decision function.
     """
     X, _, _, _, _ = input_to_host_array(X)
     with cuml.internals.exit_internal_api():
         return self.multiclass_estimator.decision_function(X)
Exemplo n.º 2
0
 def predict(self, X) -> CumlArray:
     """
     Predict using multi class classifier.
     """
     X, _, _, _, _ = input_to_host_array(X)
     with cuml.internals.exit_internal_api():
         return self.multiclass_estimator.predict(X)
Exemplo n.º 3
0
 def fit(self, X, y) -> 'MulticlassClassifier':
     """
     Fit a multiclass classifier.
     """
     if self.strategy == 'ovr':
         self.multiclass_estimator = sklearn.multiclass.\
             OneVsRestClassifier(self.estimator, n_jobs=None)
     elif self.strategy == 'ovo':
         self.multiclass_estimator = \
             sklearn.multiclass.OneVsOneClassifier(
                 self.estimator, n_jobs=None)
     else:
         raise ValueError('Invalid multiclass strategy ' +
                          str(self.strategy) + ', must be one of '
                          '{"ovr", "ovo"}')
     X, _, _, _, _ = input_to_host_array(X)
     y, _, _, _, _ = input_to_host_array(y)
     with cuml.internals.exit_internal_api():
         self.multiclass_estimator.fit(X, y)
         return self
Exemplo n.º 4
0
def test_input_to_host_array(dtype, input_type, num_rows, num_cols, order):
    input_data, real_data = get_input(input_type, num_rows, num_cols, dtype,
                                      order=order)

    if input_type == 'cupy' and input_data is None:
        pytest.skip('cupy not installed')

    X, X_ptr, n_rows, n_cols, dtype = input_to_host_array(input_data,
                                                          order=order)

    np.testing.assert_equal(X, real_data)

    assert n_rows == num_rows
    assert n_cols == num_cols
    assert dtype == dtype

    del input_data
    del real_data