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

Method set_weight

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

Set weight of each instance. Parameters ---------- weight : list, numpy 1-D array, pandas Series or None Weight to be set for each data point. Returns ------- self : Dataset Dataset with set weight.

(self, weight)

Source from the content-addressed store, hash-verified

1395 return self
1396
1397 def set_weight(self, weight):
1398 """Set weight of each instance.
1399
1400 Parameters
1401 ----------
1402 weight : list, numpy 1-D array, pandas Series or None
1403 Weight to be set for each data point.
1404
1405 Returns
1406 -------
1407 self : Dataset
1408 Dataset with set weight.
1409 """
1410 if weight is not None and np.all(weight == 1):
1411 weight = None
1412 self.weight = weight
1413 if self.handle is not None and weight is not None:
1414 weight = list_to_1d_numpy(weight, name='weight')
1415 self.set_field('weight', weight)
1416 self.weight = self.get_field('weight') # original values can be modified at cpp side
1417 return self
1418
1419 def set_init_score(self, init_score):
1420 """Set init score of Booster to start from.

Callers 2

_lazy_initMethod · 0.95

Calls 3

set_fieldMethod · 0.95
get_fieldMethod · 0.95
list_to_1d_numpyFunction · 0.85