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

Method get_ref_chain

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

Get a chain of Dataset objects. Starts with r, then goes to r.reference (if exists), then to r.reference.reference, etc. until we hit ``ref_limit`` or a reference loop. Parameters ---------- ref_limit : int, optional (default=100) The lim

(self, ref_limit=100)

Source from the content-addressed store, hash-verified

1591 raise LightGBMError("Cannot get num_feature before construct dataset")
1592
1593 def get_ref_chain(self, ref_limit=100):
1594 """Get a chain of Dataset objects.
1595
1596 Starts with r, then goes to r.reference (if exists),
1597 then to r.reference.reference, etc.
1598 until we hit ``ref_limit`` or a reference loop.
1599
1600 Parameters
1601 ----------
1602 ref_limit : int, optional (default=100)
1603 The limit number of references.
1604
1605 Returns
1606 -------
1607 ref_chain : set of Dataset
1608 Chain of references of the Datasets.
1609 """
1610 head = self
1611 ref_chain = set()
1612 while len(ref_chain) < ref_limit:
1613 if isinstance(head, Dataset):
1614 ref_chain.add(head)
1615 if (head.reference is not None) and (head.reference not in ref_chain):
1616 head = head.reference
1617 else:
1618 break
1619 else:
1620 break
1621 return ref_chain
1622
1623 def add_features_from(self, other):
1624 """Add features from other Dataset to the current Dataset.

Callers 1

set_referenceMethod · 0.95

Calls 1

addMethod · 0.80

Tested by

no test coverage detected