(task_type, calc_shap_mode)
| 5106 | |
| 5107 | @pytest.mark.parametrize('calc_shap_mode', ['TreeSHAP', 'IndependentTreeSHAP']) |
| 5108 | def test_shap_complex_ctr(task_type, calc_shap_mode): |
| 5109 | pool = Pool([[0, 0, 0], [0, 1, 0], [1, 0, 1], [1, 1, 2]], [0, 0, 5, 8], cat_features=[0, 1, 2]) |
| 5110 | reference_data = make_reference_data(pool, calc_shap_mode) |
| 5111 | model = train(pool, {'random_seed': 12302113, 'iterations': 100, 'task_type': task_type, 'gpu_ram_part': TEST_GPU_RAM_PART, 'devices': '0'}) |
| 5112 | shap_values = model.get_feature_importance(type=EFstrType.ShapValues, data=pool, reference_data=reference_data) |
| 5113 | predictions = model.predict(pool) |
| 5114 | assert (len(predictions) == len(shap_values)) |
| 5115 | for pred_idx in range(len(predictions)): |
| 5116 | assert (abs(sum(shap_values[pred_idx]) - predictions[pred_idx]) < 1e-9) |
| 5117 | fimp_txt_path = test_output_path(FIMP_TXT_PATH) |
| 5118 | np.savetxt(fimp_txt_path, np.around(np.array(shap_values), 9)) |
| 5119 | return local_canonical_file(fimp_txt_path) |
| 5120 | |
| 5121 | |
| 5122 | def test_shap_interaction_feature_importance(task_type): |
nothing calls this directly
no test coverage detected