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

Function test_convert_model_to_json

catboost/python-package/ut/medium/test.py:1537–1559  ·  view source on GitHub ↗
(task_type, pool, parameters)

Source from the content-addressed store, hash-verified

1535
1536@pytest.mark.parametrize('pool,parameters', [('adult', {}), ('adult', {'one_hot_max_size': 100}), ('higgs', {})])
1537def test_convert_model_to_json(task_type, pool, parameters):
1538 train_pool = Pool(data_file(pool, 'train_small'), column_description=data_file(pool, 'train.cd'))
1539 test_pool = Pool(data_file(pool, 'test_small'), column_description=data_file(pool, 'train.cd'))
1540 converted_model_path = test_output_path("converted_model.bin")
1541 parameters.update({'iterations': 20, 'task_type': task_type, 'gpu_ram_part': TEST_GPU_RAM_PART, 'devices': '0'})
1542 model = CatBoost(parameters)
1543 model.fit(train_pool)
1544 output_model_path = test_output_path(OUTPUT_MODEL_PATH)
1545 output_json_model_path = test_output_path(OUTPUT_JSON_MODEL_PATH)
1546 model.save_model(output_model_path)
1547 model.save_model(output_json_model_path, format="json")
1548 model2 = CatBoost()
1549 model2.load_model(output_json_model_path, format="json")
1550 model2.save_model(converted_model_path)
1551 pred1 = model.predict(test_pool)
1552 pred2 = model2.predict(test_pool)
1553 assert _check_data(pred1, pred2)
1554 subprocess.check_call((
1555 model_diff_tool, output_model_path, converted_model_path,
1556 '--diff-limit', '0.000001',
1557 '--ignore-keys', '.*TargetBorderClassifierIdx',
1558 ))
1559 return compare_canonical_models(converted_model_path)
1560
1561
1562def test_coreml_cbm_import_export(task_type):

Callers

nothing calls this directly

Calls 11

fitMethod · 0.95
save_modelMethod · 0.95
load_modelMethod · 0.95
predictMethod · 0.95
PoolClass · 0.90
CatBoostClass · 0.90
test_output_pathFunction · 0.85
compare_canonical_modelsFunction · 0.85
_check_dataFunction · 0.70
data_fileFunction · 0.50
updateMethod · 0.45

Tested by

no test coverage detected