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

Function test_group_weight

catboost/python-package/ut/medium/test.py:2258–2278  ·  view source on GitHub ↗
(task_type)

Source from the content-addressed store, hash-verified

2256
2257
2258def test_group_weight(task_type):
2259 train_pool = Pool(QUERYWISE_TRAIN_FILE, column_description=QUERYWISE_CD_FILE_WITH_GROUP_WEIGHT)
2260 test_pool = Pool(QUERYWISE_TEST_FILE, column_description=QUERYWISE_CD_FILE_WITH_GROUP_WEIGHT)
2261 model = CatBoostRanker(loss_function='YetiRank', iterations=10, thread_count=8, task_type=task_type, gpu_ram_part=TEST_GPU_RAM_PART, devices='0')
2262 model.fit(train_pool)
2263 pred1 = model.predict(test_pool)
2264
2265 df = pd.read_csv(QUERYWISE_TRAIN_FILE, delimiter='\t', header=None)
2266 train_query_weight = df.loc[:, 0]
2267 train_query_id = df.loc[:, 1]
2268 train_target = df.loc[:, 2]
2269 train_data = df.drop([0, 1, 2, 3, 4], axis=1).astype(str)
2270
2271 df = pd.read_csv(QUERYWISE_TEST_FILE, delimiter='\t', header=None)
2272 test_query_weight = df.loc[:, 0]
2273 test_query_id = df.loc[:, 1]
2274 test_data = Pool(df.drop([0, 1, 2, 3, 4], axis=1).astype(np.float32), group_id=test_query_id, group_weight=test_query_weight)
2275
2276 model.fit(train_data, train_target, group_id=train_query_id, group_weight=train_query_weight)
2277 pred2 = model.predict(test_data)
2278 assert _check_data(pred1, pred2)
2279
2280
2281def test_zero_baseline(task_type):

Callers

nothing calls this directly

Calls 6

fitMethod · 0.95
predictMethod · 0.95
PoolClass · 0.90
CatBoostRankerClass · 0.90
dropMethod · 0.80
_check_dataFunction · 0.70

Tested by

no test coverage detected