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

Function test_cv_with_text

catboost/python-package/ut/medium/test.py:3713–3737  ·  view source on GitHub ↗
(problem_type)

Source from the content-addressed store, hash-verified

3711
3712@pytest.mark.parametrize('problem_type', ['binclass', 'multiclass', 'regression'])
3713def test_cv_with_text(problem_type):
3714 cats_words = ['Meow', 'Kitten', 'Paw', 'Tail', 'Purring', 'Crouch', 'Whisker']
3715 dogs_words = ['Puppy', 'Whelp', 'Woof', 'Tail', 'Paw', 'Snarl', 'Barking']
3716 words = [cats_words, dogs_words]
3717 np.random.seed(1)
3718 labels = np.random.choice(2, 1000)
3719 texts = [[' '.join(np.random.choice(words[label], 3, replace=False))] for label in labels]
3720 data_pool = Pool(data=texts, label=labels, text_features=[0])
3721 train_dir_prefix = test_output_path('')
3722 params = {
3723 'loss_function': {
3724 'binclass': 'Logloss',
3725 'multiclass': 'MultiClass',
3726 'regression': 'RMSE'
3727 }[problem_type],
3728 'iterations': 10,
3729 'random_seed': 42,
3730 'learning_rate': 0.5,
3731 'train_dir': os.path.join(train_dir_prefix, 'catboost_info')
3732 }
3733 result = cv(iterations=10, pool=data_pool, params=params, fold_count=3).round(decimals=3)
3734
3735 preds_path = test_output_path(CV_CSV_PATH)
3736 result.to_csv(preds_path)
3737 return local_canonical_file(preds_path)
3738
3739
3740def test_cv_with_save_snapshot(task_type):

Callers

nothing calls this directly

Calls 6

PoolClass · 0.90
cvFunction · 0.90
test_output_pathFunction · 0.85
local_canonical_fileFunction · 0.50
seedMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected