(loss_function)
| 7285 | |
| 7286 | @pytest.mark.parametrize('loss_function', ['MultiClass', 'MultiClassOneVsAll', 'Logloss', 'RMSE']) |
| 7287 | def test_save_class_labels_from_data(loss_function): |
| 7288 | labels = [10000000, 7, 0, 9999] |
| 7289 | |
| 7290 | model_path = yatest.common.test_output_path('model.bin') |
| 7291 | |
| 7292 | cd_path = yatest.common.test_output_path('cd.txt') |
| 7293 | np.savetxt(cd_path, [[0, 'Target']], fmt='%s', delimiter='\t') |
| 7294 | |
| 7295 | prng = np.random.RandomState(seed=0) |
| 7296 | |
| 7297 | train_path = yatest.common.test_output_path('train.txt') |
| 7298 | np.savetxt(train_path, generate_concatenated_random_labeled_dataset(100, 10, labels, prng=prng), fmt='%s', delimiter='\t') |
| 7299 | |
| 7300 | cmd = ( |
| 7301 | '--loss-function', loss_function, |
| 7302 | '-f', train_path, |
| 7303 | '--column-description', cd_path, |
| 7304 | '-i', '10', |
| 7305 | '-T', '4', |
| 7306 | '-m', model_path, |
| 7307 | '--use-best-model', 'false', |
| 7308 | ) |
| 7309 | |
| 7310 | if loss_function == 'Logloss': |
| 7311 | cmd += ('--target-border', '0.5') |
| 7312 | |
| 7313 | execute_catboost_fit('CPU', cmd) |
| 7314 | |
| 7315 | py_catboost = catboost.CatBoost() |
| 7316 | py_catboost.load_model(model_path) |
| 7317 | |
| 7318 | if loss_function in MULTICLASS_LOSSES: |
| 7319 | assert json.loads(py_catboost.get_metadata()['class_params'])['class_label_type'] == 'String' |
| 7320 | assert json.loads(py_catboost.get_metadata()['class_params'])['class_to_label'] == [0, 1, 2, 3] |
| 7321 | assert json.loads(py_catboost.get_metadata()['class_params'])['class_names'] == ['0.0', '7.0', '9999.0', '10000000.0'] |
| 7322 | assert json.loads(py_catboost.get_metadata()['class_params'])['classes_count'] == 0 |
| 7323 | elif loss_function == 'Logloss': |
| 7324 | assert json.loads(py_catboost.get_metadata()['class_params'])['class_label_type'] == 'Integer' |
| 7325 | assert json.loads(py_catboost.get_metadata()['class_params'])['class_to_label'] == [0, 1] |
| 7326 | assert json.loads(py_catboost.get_metadata()['class_params'])['class_names'] == [] |
| 7327 | assert json.loads(py_catboost.get_metadata()['class_params'])['classes_count'] == 0 |
| 7328 | else: |
| 7329 | assert 'class_params' not in py_catboost.get_metadata() |
| 7330 | |
| 7331 | |
| 7332 | @pytest.mark.parametrize('prediction_type', ['Probability', 'RawFormulaVal', 'Class']) |
nothing calls this directly
no test coverage detected