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

Function _test_generated_losses

catboost/python-package/ut/medium/test.py:2876–2892  ·  view source on GitHub ↗
(train_pool, test_pool, losses, result_dtype=float)

Source from the content-addressed store, hash-verified

2874
2875
2876def _test_generated_losses(train_pool, test_pool, losses, result_dtype=float):
2877 catboost_params = {'iterations': 50}
2878 for loss_text, loss_instance in losses.items():
2879 # text-description metric/loss
2880 td_params = catboost_params.copy()
2881 td_params['loss_function'] = loss_text
2882 td_model = CatBoost(td_params)
2883 td_model.fit(train_pool, eval_set=test_pool)
2884 td_pred = td_model.predict(test_pool)
2885 # instances of autogenerated metric/loss classes
2886 ag_params = catboost_params.copy()
2887 ag_params['loss_function'] = loss_instance
2888 ag_model = CatBoost(ag_params)
2889 ag_model.fit(train_pool, eval_set=test_pool)
2890 ag_pred = ag_model.predict(test_pool)
2891 np.allclose(td_pred.astype(result_dtype), ag_pred.astype(result_dtype)), \
2892 "Different results for {}".format(loss_text)
2893
2894
2895def test_generated_classification_losses():

Calls 5

fitMethod · 0.95
predictMethod · 0.95
CatBoostClass · 0.90
copyMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected