"python-package/vscode:/vscode.git/clone" did not exist on "ebb07f019a611ec9d3712aadbc9e725faaa9c78c"
Commit e7c53270 authored by j-mark-hou's avatar j-mark-hou Committed by Guolin Ke
Browse files

added test for training when both train and valid are subsets of a si… (#759)

* added test for training when both train and valid are subsets of a single lgb.Dataset object

* pep8 changes

* more pep8

* added test involving subsets of subsets of lgb.Dataset objects

* minor fix to contruction of X matrix

* even more pep8

* simplified test further
parent 64e52093
......@@ -453,3 +453,18 @@ class TestEngine(unittest.TestCase):
np.testing.assert_almost_equal(pred0, pred2)
np.testing.assert_almost_equal(pred0, pred3)
np.testing.assert_almost_equal(pred0, pred4)
def test_subset_train_val(self):
'''
Tests that it's fine to construct a single lgb.Dataframe object,
takes subsets of it, and uses the subsets for training and validation
'''
n = 1000
X = np.random.normal(size=(n, 2))
y = np.random.normal(size=n)
tmp_dat = lgb.Dataset(X, y)
# take subsets and train
tmp_dat_train = tmp_dat.subset(np.arange(int(n * .8)))
tmp_dat_val = tmp_dat.subset(np.arange(int(n * .8), n)).subset(np.arange(n * .2 * .9))
params = {'objective': 'regression_l2', 'metric': 'rmse'}
gbm = lgb.train(params, tmp_dat_train, num_boost_round=20, valid_sets=[tmp_dat_train, tmp_dat_val])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment