(loss_function, train_pool, test_pool, metrics, task)
| 2670 | |
| 2671 | |
| 2672 | def _test_generated_metrics(loss_function, train_pool, test_pool, metrics, task): |
| 2673 | model = CatBoost({'loss_function': loss_function, 'iterations': 50}) |
| 2674 | model.fit(train_pool, eval_set=test_pool) |
| 2675 | |
| 2676 | # text description metrics |
| 2677 | td_results = model.eval_metrics(test_pool, list(metrics.keys())) |
| 2678 | # instances of autogenerated metric classes |
| 2679 | ag_results = model.eval_metrics(test_pool, list(metrics.values())) |
| 2680 | |
| 2681 | for metric in metrics: |
| 2682 | assert np.allclose(td_results[metric], ag_results[metric]), "Different results for {}".format(metric) |
| 2683 | |
| 2684 | if task not in ("ranking", "multiclassification", "multiregression", "survival_regression"): |
| 2685 | preds = model.predict(test_pool, prediction_type='RawFormulaVal') |
| 2686 | for metric, metric_obj in metrics.items(): |
| 2687 | score = metric_obj.eval(test_pool.get_label(), preds)[0] |
| 2688 | assert np.abs(td_results[metric][-1] - score) < 1e-6, "Eval metric results differ for {}".format(metric) |
| 2689 | |
| 2690 | |
| 2691 | def test_f1_vs_fbeta(): |
no test coverage detected