MCPcopy Create free account
hub / github.com/catboost/catboost / test_pool_from_slices

Function test_pool_from_slices

catboost/python-package/ut/medium/test.py:773–791  ·  view source on GitHub ↗
(features_type)

Source from the content-addressed store, hash-verified

771 ids=['features_type=numpy.ndarray', 'features_type=pandas.DataFrame']
772)
773def test_pool_from_slices(features_type):
774 full_size = (100, 30)
775 subset_size = (20, 17)
776
777 prng = np.random.RandomState(seed=20191120)
778
779 for start_offsets in ((0, 0), (5, 3)):
780 full_features_data = np.round(prng.normal(size=full_size), decimals=3)
781 full_label = _generate_nontrivial_binary_target(full_size[0], prng=prng)
782
783 subset_features_data = full_features_data[start_offsets[0]:subset_size[0], start_offsets[1]:subset_size[1]]
784 subset_label = full_label[start_offsets[0]:subset_size[0]]
785
786 if features_type == 'numpy.ndarray':
787 pool = Pool(subset_features_data, subset_label)
788 else:
789 pool = Pool(pd.DataFrame(subset_features_data), subset_label)
790 assert _check_data(pool.get_features(), subset_features_data)
791 assert _check_data([float(value) for value in pool.get_label()], subset_label)
792
793
794@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 5

PoolClass · 0.90
get_labelMethod · 0.80
_check_dataFunction · 0.70
floatFunction · 0.50

Tested by

no test coverage detected