rail.projects.algorithm_factory module

class rail.projects.algorithm_factory.RailAlgorithmFactory[source]

Bases: RailFactoryMixin

Factory class to make holder for Algorithms

Expected usage is that user will define a yaml file with the various datasets that they wish to use with the following example syntax:

SpecSelections:
  - SpecSelection:
      name: zCOSMOS
      Select: SpecSelection_zCOSMOS
      Module: rail.creation.degraders.spectroscopic_selections

PZAlgorithms:
  - PZAlgorithm:
      name: trainz
      Estimate: TrainZEstimator
      Inform: TrainZInformer
      Module: rail.estimation.algos.train_z
  - PZAlgorithm:
      name: simplenn
      Estimate: SklNeurNetEstimator
      Inform: SklNeurNetInformer
      Module: rail.estimation.algos.sklearn_neurnet

and so on.

classmethod add_algorithm(algorithm)[source]

Add a particular aglorithm to the factory

Return type:

None

Parameters:

algorithm (RailAlgorithmHolder)

property algorithm_holder_dict: dict[str, dict[str, RailAlgorithmHolder]]

Return the dictionary of all the algorithms, keyed by type

client_classes: list[type[Configurable]] = [<class 'rail.projects.algorithm_holder.RailPZAlgorithmHolder'>, <class 'rail.projects.algorithm_holder.RailSpecSelectionAlgorithmHolder'>, <class 'rail.projects.algorithm_holder.RailClassificationAlgorithmHolder'>, <class 'rail.projects.algorithm_holder.RailSummarizerAlgorithmHolder'>, <class 'rail.projects.algorithm_holder.RailErrorModelAlgorithmHolder'>, <class 'rail.projects.algorithm_holder.RailSubsamplerAlgorithmHolder'>, <class 'rail.projects.algorithm_holder.RailReducerAlgorithmHolder'>]
classmethod get_algorithm(algorithm_type, algo_name)[source]

Return a particular algorithm of a particular type

Return type:

RailAlgorithmHolder

Parameters:
  • algorithm_type (str)

  • algo_name (str)

classmethod get_algorithm_class(algorithm_type, algo_name, key)[source]

Return the class of a particular algorithm of a particular type

Return type:

type

Parameters:
  • algorithm_type (str)

  • algo_name (str)

  • key (str)

classmethod get_algorithm_holder_dict()[source]

Return the dict of all the algorithms

Return type:

dict[str, dict[str, RailAlgorithmHolder]]

classmethod get_algorithm_names(algorithm_type)[source]

Return the names of all the algorithms of a particular type

Return type:

list[str]

Parameters:

algorithm_type (str)

classmethod get_algorithm_types()[source]

Return the names of the algorithms types

Return type:

list[str]

classmethod get_algorithms(algorithm_type)[source]

Return a dict of all the algorithms of a particular type

Return type:

dict[str, RailAlgorithmHolder]

Parameters:

algorithm_type (str)

load_instance_yaml(yaml_file)[source]

Read a yaml file and load the factory accordingly

Return type:

None

Parameters:

yaml_file (str) – File to read

Notes

See class description for yaml file syntax

print_instance_contents()[source]

Print the contents of the factory

Return type:

None

to_instance_yaml_dict()[source]

Write the content of the factory to a dict for export to a yaml file

Return type:

dict