MCPcopy Create free account
hub / github.com/antmachineintelligence/mtgbmcode / LGBM_BoosterPredictForCSC

Function LGBM_BoosterPredictForCSC

src/c_api.cpp:1419–1469  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1417
1418
1419int LGBM_BoosterPredictForCSC(BoosterHandle handle,
1420 const void* col_ptr,
1421 int col_ptr_type,
1422 const int32_t* indices,
1423 const void* data,
1424 int data_type,
1425 int64_t ncol_ptr,
1426 int64_t nelem,
1427 int64_t num_row,
1428 int predict_type,
1429 int num_iteration,
1430 const char* parameter,
1431 int64_t* out_len,
1432 double* out_result) {
1433 API_BEGIN();
1434 Booster* ref_booster = reinterpret_cast<Booster*>(handle);
1435 auto param = Config::Str2Map(parameter);
1436 Config config;
1437 config.Set(param);
1438 if (config.num_threads > 0) {
1439 omp_set_num_threads(config.num_threads);
1440 }
1441 int num_threads = 1;
1442 #pragma omp parallel
1443 #pragma omp master
1444 {
1445 num_threads = omp_get_num_threads();
1446 }
1447 int ncol = static_cast<int>(ncol_ptr - 1);
1448 std::vector<std::vector<CSC_RowIterator>> iterators(num_threads, std::vector<CSC_RowIterator>());
1449 for (int i = 0; i < num_threads; ++i) {
1450 for (int j = 0; j < ncol; ++j) {
1451 iterators[i].emplace_back(col_ptr, col_ptr_type, indices, data, data_type, ncol_ptr, nelem, j);
1452 }
1453 }
1454 std::function<std::vector<std::pair<int, double>>(int row_idx)> get_row_fun =
1455 [&iterators, ncol] (int i) {
1456 std::vector<std::pair<int, double>> one_row;
1457 const int tid = omp_get_thread_num();
1458 for (int j = 0; j < ncol; ++j) {
1459 auto val = iterators[tid][j].Get(i);
1460 if (std::fabs(val) > kZeroThreshold || std::isnan(val)) {
1461 one_row.emplace_back(j, val);
1462 }
1463 }
1464 return one_row;
1465 };
1466 ref_booster->Predict(num_iteration, predict_type, static_cast<int>(num_row), ncol, get_row_fun, config,
1467 out_result, out_len);
1468 API_END();
1469}
1470
1471int LGBM_BoosterPredictForMat(BoosterHandle handle,
1472 const void* data,

Callers 1

Calls 6

omp_set_num_threadsFunction · 0.50
omp_get_num_threadsFunction · 0.50
omp_get_thread_numFunction · 0.50
SetMethod · 0.45
GetMethod · 0.45
PredictMethod · 0.45

Tested by

no test coverage detected