frex.pipeline_stages.candidate_generators package

Submodules

frex.pipeline_stages.candidate_generators.candidate_generator module

class frex.pipeline_stages.candidate_generators.candidate_generator.CandidateGenerator(*, generator_explanation: frex.models.explanation.Explanation, **kwargs)[source]

Bases: frex.pipeline_stages.pipeline_stage.PipelineStage

CandidateGenerator is a PipelineStage that is intended to generate new candidates to pass through a FREx Pipeline. This might take the form of applying some recommendation algorithm to choose new candidates (e.g., generate the top 100 items the user is most likely to purchase) or it may generate new candidates by modifying candidates that have been generated by an earlier stage.

A new CandidateGenerator can be minimally defined by creating a new subclass of the CandidateGenerator class and defining the generate() function. However, it is likely that custom CandidateGenerator classes will need to also perform some access to data sources to produce the actual objects.

Parameters

generator_explanation – The explanation to add to the Candidate when being yielded.

__call__(*, candidates: Optional[Generator[frex.models.candidate.Candidate, None, None]] = None, context: Any) Generator[frex.models.candidate.Candidate, None, None][source]

Execute some function to apply and yield new or updated candidates.

Parameters
  • candidates – A Generator yielding candidates. In the setup of a FREx Pipeline, this is typically another PipelineStage that is yielding candidates into the next stage.

  • context – The current context being used to execute the Pipeline.

Returns

A Generator, yielding new Candidate objects.

abstract generate(*, candidates: Optional[Generator[frex.models.candidate.Candidate, None, None]] = None, context: Any) Generator[frex.models.candidate.Candidate, None, None][source]

Apply a custom function to generate and yield new candidates to pass through a FREx Pipeline.

Parameters
  • candidates – A Generator yielding candidates. In the setup of a FREx Pipeline, this is typically another PipelineStage that is yielding candidates into the next stage.

  • context – The current context being used to execute the Pipeline.

Returns

A Generator, yielding newly generated Candidate objects.

Module contents