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

Function LGBM_DatasetGetField_R

src/lightgbm_R.cpp:217–249  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

215}
216
217LGBM_SE LGBM_DatasetGetField_R(LGBM_SE handle,
218 LGBM_SE field_name,
219 LGBM_SE field_data,
220 LGBM_SE call_state) {
221 R_API_BEGIN();
222 const char* name = R_CHAR_PTR(field_name);
223 int out_len = 0;
224 int out_type = 0;
225 const void* res;
226 CHECK_CALL(LGBM_DatasetGetField(R_GET_PTR(handle), name, &out_len, &res, &out_type));
227
228 if (!strcmp("group", name) || !strcmp("query", name)) {
229 auto p_data = reinterpret_cast<const int32_t*>(res);
230 // convert from boundaries to size
231#pragma omp parallel for schedule(static)
232 for (int i = 0; i < out_len - 1; ++i) {
233 R_INT_PTR(field_data)[i] = p_data[i + 1] - p_data[i];
234 }
235 } else if (!strcmp("init_score", name)) {
236 auto p_data = reinterpret_cast<const double*>(res);
237#pragma omp parallel for schedule(static)
238 for (int i = 0; i < out_len; ++i) {
239 R_REAL_PTR(field_data)[i] = p_data[i];
240 }
241 } else {
242 auto p_data = reinterpret_cast<const float*>(res);
243#pragma omp parallel for schedule(static)
244 for (int i = 0; i < out_len; ++i) {
245 R_REAL_PTR(field_data)[i] = p_data[i];
246 }
247 }
248 R_API_END();
249}
250
251LGBM_SE LGBM_DatasetGetFieldSize_R(LGBM_SE handle,
252 LGBM_SE field_name,

Callers

nothing calls this directly

Calls 2

LGBM_DatasetGetFieldFunction · 0.70
R_GET_PTRFunction · 0.50

Tested by

no test coverage detected