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

Method get_field

python-package/lightgbmmt/basic.py:1238–1275  ·  view source on GitHub ↗

Get property from the Dataset. Parameters ---------- field_name : string The field name of the information. Returns ------- info : numpy array A numpy array with information from the Dataset.

(self, field_name)

Source from the content-addressed store, hash-verified

1236 return self
1237
1238 def get_field(self, field_name):
1239 """Get property from the Dataset.
1240
1241 Parameters
1242 ----------
1243 field_name : string
1244 The field name of the information.
1245
1246 Returns
1247 -------
1248 info : numpy array
1249 A numpy array with information from the Dataset.
1250 """
1251 if self.handle is None:
1252 raise Exception("Cannot get %s before construct Dataset" % field_name)
1253 tmp_out_len = ctypes.c_int()
1254 out_type = ctypes.c_int()
1255 ret = ctypes.POINTER(ctypes.c_void_p)()
1256 _safe_call(_LIB.LGBM_DatasetGetField(
1257 self.handle,
1258 c_str(field_name),
1259 ctypes.byref(tmp_out_len),
1260 ctypes.byref(ret),
1261 ctypes.byref(out_type)))
1262 if out_type.value != FIELD_TYPE_MAPPER[field_name]:
1263 raise TypeError("Return type error for get_field")
1264 if tmp_out_len.value == 0:
1265 return None
1266 if out_type.value == C_API_DTYPE_INT32:
1267 return cint32_array_to_numpy(ctypes.cast(ret, ctypes.POINTER(ctypes.c_int32)), tmp_out_len.value)
1268 elif out_type.value == C_API_DTYPE_FLOAT32:
1269 return cfloat32_array_to_numpy(ctypes.cast(ret, ctypes.POINTER(ctypes.c_float)), tmp_out_len.value)
1270 elif out_type.value == C_API_DTYPE_FLOAT64:
1271 return cfloat64_array_to_numpy(ctypes.cast(ret, ctypes.POINTER(ctypes.c_double)), tmp_out_len.value)
1272 elif out_type.value == C_API_DTYPE_INT8:
1273 return cint8_array_to_numpy(ctypes.cast(ret, ctypes.POINTER(ctypes.c_int8)), tmp_out_len.value)
1274 else:
1275 raise TypeError("Unknown type")
1276
1277 def set_categorical_feature(self, categorical_feature):
1278 """Set categorical features.

Callers 10

set_labelMethod · 0.95
set_weightMethod · 0.95
set_init_scoreMethod · 0.95
get_labelMethod · 0.95
get_weightMethod · 0.95
get_feature_penaltyMethod · 0.95
get_init_scoreMethod · 0.95
get_groupMethod · 0.95
check_assertsMethod · 0.80

Calls 7

_safe_callFunction · 0.85
cint32_array_to_numpyFunction · 0.85
cfloat32_array_to_numpyFunction · 0.85
cfloat64_array_to_numpyFunction · 0.85
cint8_array_to_numpyFunction · 0.85
castMethod · 0.80
c_strFunction · 0.70

Tested by 1

check_assertsMethod · 0.64