(task_type)
| 4245 | |
| 4246 | |
| 4247 | def test_feature_importance(task_type): |
| 4248 | pool = Pool(TRAIN_FILE, column_description=CD_FILE) |
| 4249 | pool_querywise = Pool(QUERYWISE_TRAIN_FILE, column_description=QUERYWISE_CD_FILE) |
| 4250 | fimp_npy_path = test_output_path(FIMP_NPY_PATH) |
| 4251 | |
| 4252 | model = CatBoostRanker(iterations=5, learning_rate=0.03, task_type=task_type, gpu_ram_part=TEST_GPU_RAM_PART, devices="0", loss_function="QueryRMSE") |
| 4253 | model.fit(pool_querywise) |
| 4254 | |
| 4255 | assert len(model.feature_importances_.shape) == 0 |
| 4256 | model.get_feature_importance(type=EFstrType.LossFunctionChange, data=pool_querywise) |
| 4257 | |
| 4258 | model = CatBoostClassifier(iterations=5, learning_rate=0.03, task_type=task_type, gpu_ram_part=TEST_GPU_RAM_PART, devices='0') |
| 4259 | model.fit(pool) |
| 4260 | assert (model.get_feature_importance() == model.get_feature_importance(type=EFstrType.PredictionValuesChange)).all() |
| 4261 | failed = False |
| 4262 | try: |
| 4263 | model.get_feature_importance(type=EFstrType.LossFunctionChange) |
| 4264 | except CatBoostError: |
| 4265 | failed = True |
| 4266 | assert failed |
| 4267 | np.save(fimp_npy_path, np.array(model.feature_importances_)) |
| 4268 | assert len(model.feature_importances_.shape) |
| 4269 | return local_canonical_file(fimp_npy_path) |
| 4270 | |
| 4271 | |
| 4272 | def test_feature_importance_interaction_asymmetric_grow_policy(): |
nothing calls this directly
no test coverage detected