π By AnswerΒΆ
Note
ID: operators.balancers.qa.by_answer | Type: DeterministicBalancer
{
"__type__": "deterministic_balancer",
"fields": [
"reference_fields/answer"
]
}
Explanation about DeterministicBalancerΒΆ
A class used to balance streams deterministically.
For each instance, a signature is constructed from the values of the instance in specified input βfieldsβ. By discarding instances from the input stream, DeterministicBalancer maintains equal number of instances for all signatures. When also input βmax_instancesβ is specified, DeterministicBalancer maintains a total instance count not exceeding βmax_instancesβ. The total number of discarded instances is as few as possible.
- Attributes:
fields (List[str]): A list of field names to be used in producing the instanceβs signature. max_instances (Optional, int)
- Usage:
balancer = DeterministicBalancer(fields=[βfield1β, βfield2β], max_instances=200) balanced_stream = balancer.process(stream)
- Example:
When input [{βaβ: 1, βbβ: 1},{βaβ: 1, βbβ: 2},{βaβ: 2},{βaβ: 3},{βaβ: 4}] is fed into DeterministicBalancer(fields=[βaβ]) the resulting stream will be: [{βaβ: 1, βbβ: 1},{βaβ: 2},{βaβ: 3},{βaβ: 4}]
Read more about catalog usage here.