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

Method feature_name

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

Get names of features. Returns ------- result : list List with names of features.

(self)

Source from the content-addressed store, hash-verified

2573 return out_num_feature.value
2574
2575 def feature_name(self):
2576 """Get names of features.
2577
2578 Returns
2579 -------
2580 result : list
2581 List with names of features.
2582 """
2583 num_feature = self.num_feature()
2584 # Get name of features
2585 tmp_out_len = ctypes.c_int(0)
2586 string_buffers = [ctypes.create_string_buffer(255) for i in range_(num_feature)]
2587 ptr_string_buffers = (ctypes.c_char_p * num_feature)(*map(ctypes.addressof, string_buffers))
2588 _safe_call(_LIB.LGBM_BoosterGetFeatureNames(
2589 self.handle,
2590 ctypes.byref(tmp_out_len),
2591 ptr_string_buffers))
2592 if num_feature != tmp_out_len.value:
2593 raise ValueError("Length of feature names doesn't equal with num_feature")
2594 return [string_buffers[i].value.decode() for i in range_(num_feature)]
2595
2596 def feature_importance(self, importance_type='split', iteration=None):
2597 """Get feature importances.

Callers 4

plot_importanceFunction · 0.80
test_feature_nameMethod · 0.80

Calls 2

num_featureMethod · 0.95
_safe_callFunction · 0.85

Tested by 3

test_feature_nameMethod · 0.64