-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0eee6da
commit 6685954
Showing
4 changed files
with
46 additions
and
46 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,51 @@ | ||
import unittest | ||
import pytest | ||
import testing as tm | ||
import numpy as np | ||
import pandas as pd | ||
try: | ||
import cudf.dataframe as gdf | ||
except ImportError as e: | ||
print("Failed to import cuDF: " + str(e)) | ||
print("Skipping this test") | ||
return 0 | ||
from sklearn import datasets | ||
import sys | ||
import unittest | ||
import xgboost as xgb | ||
|
||
from regression_test_utilities import run_suite, parameter_combinations, \ | ||
assert_results_non_increasing, Dataset | ||
|
||
try: | ||
import cudf.dataframe as cudf | ||
except ImportError: | ||
pass | ||
|
||
pytestmark = pytest.mark.skipif( | ||
tm.no_cudf()['condition'], | ||
reason=tm.no_cudf()['reason']) | ||
|
||
def get_gdf(): | ||
|
||
def get_cudf(): | ||
rng = np.random.RandomState(199) | ||
n = 50000 | ||
m = 20 | ||
sparsity = 0.25 | ||
X, y = datasets.make_regression(n, m, random_state=rng) | ||
Xy = (np.ascontiguousarray | ||
(np.transpose(np.concatenate((X, np.expand_dims(y, axis=1)), axis=1)))) | ||
df = gdf.DataFrame(list(zip(['col%d' % i for i in range(m+1)], Xy))) | ||
(np.transpose(np.concatenate((X, np.expand_dims(y, axis=1)), axis=1)))) | ||
df = cudf.DataFrame(list(zip(['col%d' % i for i in range(m + 1)], Xy))) | ||
all_columns = list(df.columns) | ||
cols_X = all_columns[0:len(all_columns)-1] | ||
cols_y = [all_columns[len(all_columns)-1]] | ||
cols_X = all_columns[0:len(all_columns) - 1] | ||
cols_y = [all_columns[len(all_columns) - 1]] | ||
return df[cols_X], df[cols_y] | ||
|
||
|
||
class TestGPU(unittest.TestCase): | ||
class TestCudf(unittest.TestCase): | ||
cudf_datasets = [Dataset("GDF", get_cudf, "reg:linear", "rmse")] | ||
|
||
gdf_datasets = [Dataset("GDF", get_gdf, "reg:linear", "rmse")] | ||
|
||
def test_gdf(self): | ||
def test_cudf(self): | ||
variable_param = {'n_gpus': [1], 'max_depth': [10], 'max_leaves': [255], | ||
'max_bin': [255], | ||
'grow_policy': ['lossguide']} | ||
for param in parameter_combinations(variable_param): | ||
param['tree_method'] = 'gpu_hist' | ||
gpu_results = run_suite(param, num_rounds=20, | ||
select_datasets=self.gdf_datasets) | ||
select_datasets=self.cudf_datasets) | ||
assert_results_non_increasing(gpu_results, 1e-2) | ||
|
||
def test_set_info_single_column(self): | ||
X, y = get_cudf() | ||
y = y[:,0] | ||
dtrain = xgb.DMatrix(X, y) |
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