(task_type)
| 4728 | |
| 4729 | |
| 4730 | def test_shap_feature_rmse(task_type): |
| 4731 | def rmse(yt, yp): |
| 4732 | return np.absolute(yt - yp) |
| 4733 | |
| 4734 | train_pool = Pool(TRAIN_FILE, column_description=CD_FILE) |
| 4735 | test_pool = Pool(TEST_FILE, column_description=CD_FILE) |
| 4736 | reference_data = make_reference_data(train_pool, "IndependentTreeSHAP") |
| 4737 | model = CatBoostRegressor(iterations=10, loss_function='RMSE') |
| 4738 | model.fit(train_pool) |
| 4739 | label = test_pool.get_label() |
| 4740 | shap_values = model.get_feature_importance(type=EFstrType.ShapValues, data=test_pool, reference_data=reference_data, model_output="LossFunction") |
| 4741 | predictions = model.predict(test_pool) |
| 4742 | for doc_idx in range(len(shap_values)): |
| 4743 | assert abs(sum(shap_values[doc_idx]) - rmse(float(label[doc_idx]), float(predictions[doc_idx]))) < 1e-6 |
| 4744 | |
| 4745 | |
| 4746 | def test_feature_importance_sage_basic(): |
nothing calls this directly
no test coverage detected