Skip to main content

base

Base classes for all algorithms.

Each module in this package defines a single algorithm.

Attributes: registry: A read-only dictionary of algorithm factory names to their implementation classes.

Classes

AlgorithmDecoratorMetaClass

class AlgorithmDecoratorMetaClass(*args, **kwargs):

Decorates the __init__, initialise and run algorithm methods.

Ancestors

  • bitfount.hooks.BaseDecoratorMetaClass
  • builtins.type

Subclasses

  • types.AbstractAlgorithmDecoratorMetaClass

Static methods


decorator

def decorator(f: Callable)> Callable:

Hook and federated error decorators.

do_decorate

def do_decorate(attr: str, value: Any)> bool:

Checks if an object should be decorated.

Only the init, initialise and run methods should be decorated.

BaseAlgorithmFactory

class BaseAlgorithmFactory(**kwargs: Any):

Base algorithm factory from which all other algorithms must inherit.

Attributes

  • class_name: The name of the algorithm class.

Ancestors

  • abc.ABC
  • bitfount.federated.roles._RolesMixIn
  • bitfount.types._BaseSerializableObjectMixIn

Variables

  • static nested_fields : ClassVar[Dict[str, Mapping[str, Any]]]

BaseModellerAlgorithm

class BaseModellerAlgorithm(**kwargs: Any):

Modeller side of the algorithm.

Ancestors

  • bitfount.federated.algorithms.base._BaseAlgorithm
  • abc.ABC

Subclasses

  • bitfount.federated.algorithms.column_avg._ModellerSide
  • bitfount.federated.algorithms.compute_intersection_rsa._ModellerSide
  • bitfount.federated.algorithms.csv_report_algorithm._ModellerSide
  • bitfount.federated.algorithms.hugging_face_algorithms.hugging_face_image_classification._ModellerSide
  • bitfount.federated.algorithms.hugging_face_algorithms.hugging_face_image_segmentation._ModellerSide
  • bitfount.federated.algorithms.hugging_face_algorithms.hugging_face_perplexity._ModellerSide
  • bitfount.federated.algorithms.hugging_face_algorithms.hugging_face_text_classification._ModellerSide
  • bitfount.federated.algorithms.hugging_face_algorithms.hugging_face_text_generation._ModellerSide
  • bitfount.federated.algorithms.hugging_face_algorithms.hugging_face_zero_shot_image_classification._ModellerSide
  • bitfount.federated.algorithms.hugging_face_algorithms.timm_fine_tuning._ModellerSide
  • bitfount.federated.algorithms.hugging_face_algorithms.timm_inference._ModellerSide
  • bitfount.federated.algorithms.model_algorithms.base._BaseModellerModelAlgorithm
  • bitfount.federated.algorithms.private_sql_query._ModellerSide
  • bitfount.federated.algorithms.sql_query._ModellerSide

Methods


initialise

def initialise(self, task_id: Optional[str], **kwargs: Any)> None:

Initialise the algorithm.

BaseWorkerAlgorithm

class BaseWorkerAlgorithm(**kwargs: Any):

Worker side of the algorithm.

Ancestors

  • bitfount.federated.algorithms.base._BaseAlgorithm
  • abc.ABC

Subclasses

  • bitfount.federated.algorithms.column_avg._WorkerSide
  • bitfount.federated.algorithms.compute_intersection_rsa._WorkerSide
  • bitfount.federated.algorithms.csv_report_algorithm._WorkerSide
  • bitfount.federated.algorithms.hugging_face_algorithms.hugging_face_image_classification._WorkerSide
  • bitfount.federated.algorithms.hugging_face_algorithms.hugging_face_image_segmentation._WorkerSide
  • bitfount.federated.algorithms.hugging_face_algorithms.hugging_face_perplexity._WorkerSide
  • bitfount.federated.algorithms.hugging_face_algorithms.hugging_face_text_classification._WorkerSide
  • bitfount.federated.algorithms.hugging_face_algorithms.hugging_face_text_generation._WorkerSide
  • bitfount.federated.algorithms.hugging_face_algorithms.hugging_face_zero_shot_image_classification._WorkerSide
  • bitfount.federated.algorithms.hugging_face_algorithms.timm_fine_tuning._WorkerSide
  • bitfount.federated.algorithms.hugging_face_algorithms.timm_inference._WorkerSide
  • bitfount.federated.algorithms.model_algorithms.base._BaseWorkerModelAlgorithm
  • bitfount.federated.algorithms.private_sql_query._WorkerSide
  • bitfount.federated.algorithms.sql_query._WorkerSide

Methods


initialise

def initialise(    self,    datasource: BaseSource,    pod_dp: Optional[DPPodConfig] = None,    pod_identifier: Optional[str] = None,    **kwargs: Any,)> None:

Initialises the algorithm.

This method is only called once regardless of the number of batches in the task.

note

This method must call the initialise_data method.

initialise_data

def initialise_data(self, datasource: BaseSource)> None:

Initialises the algorithm with data.

This method will be called once per task batch. It is expected that algorithms will override this method to initialise their data in the required way.

note

This is called by the initialise method and should not be called directly by the algorithm or protocol.