예제 #1
0
파일: test_svm.py 프로젝트: ptartan21/cuml
def test_svm_predict_convert_dtype(train_dtype, test_dtype, classifier):
    X, y = make_classification(n_samples=50, random_state=0)

    X = X.astype(train_dtype)
    y = y.astype(train_dtype)
    X_train, X_test, y_train, y_test = train_test_split(X, y, train_size=0.8,
                                                        random_state=0)

    if classifier:
        clf = cu_svm.SVC()
    else:
        clf = cu_svm.SVR()
    clf.fit(X_train, y_train)
    clf.predict(X_test.astype(test_dtype))
예제 #2
0
파일: test_svm.py 프로젝트: ptartan21/cuml
def test_svr_skl_cmp(params, dataset, n_rows, n_cols):
    """ Compare to Sklearn SVR """
    if (dataset == 'Friedman' and n_cols < 5):
        # We need at least 5 feature columns for the Friedman dataset
        return
    X_train, X_test, y_train, y_test = make_regression_dataset(dataset, n_rows,
                                                               n_cols)
    cuSVR = cu_svm.SVR(**params)
    cuSVR.fit(X_train, y_train)

    sklSVR = svm.SVR(**params)
    sklSVR.fit(X_train, y_train)

    compare_svr(cuSVR, sklSVR, X_test, y_test)
예제 #3
0
파일: test_svm.py 프로젝트: ptartan21/cuml
def test_svr_skl_cmp_weighted():
    """ Compare to Sklearn SVR, use sample weights"""
    X, y = make_regression(
        n_samples=100, n_features=5, n_informative=2, n_targets=1,
        random_state=137, noise=10)
    sample_weights = 10*np.sin(np.linspace(0, 2*np.pi, len(y))) + 10.1

    params = {'kernel': 'linear', 'C': 10, 'gamma': 1}
    cuSVR = cu_svm.SVR(**params)
    cuSVR.fit(X, y, sample_weights)

    sklSVR = svm.SVR(**params)
    sklSVR.fit(X, y, sample_weights)

    compare_svr(cuSVR, sklSVR, X, y)