mlm_insights.core.sdcs.interfaces package

Submodules

mlm_insights.core.sdcs.interfaces.shareable_dataset_component module

class mlm_insights.core.sdcs.interfaces.shareable_dataset_component.ShareableDatasetComponent

Bases: ABC

Abstract Base Class for Sharable dataset Component. These components will be shared across dataset metrics. The subclass must be annotated with @dataclass. All the state of SDC must be mergeable. Subclasses need to implement merge method to merge two SDC together.

By default, base class will use dataclass.asdict() to do serialization. In case base class has complex states that require custom serialization, They need to implement the Serializable interface.

Use create factory method and pass required config parameter instead of using constructor.

abstract compute(dataset: DataFrame, **kwargs: Any) None

Update the state of the SDC using input dataframe.

Parameters

datasetpd.DataFrame

Input dataframe.

abstract classmethod create(config: Dict[str, ConfigParameter] | None = None, **kwargs: Any) ShareableDatasetComponent

Factory Method to create an object. The configuration will be available in config.

Returns

ShareableDatasetComponent

An Instance of SDC.

classmethod do_deserialize(serialized_sdc: ShareableDatasetComponentMessage) ShareableDatasetComponent

Private method to deserialize the ShareableDatasetComponent from Protobuffer message.

Returns

ShareableDatasetComponent: Deserialized the protobuffer message to ShareableDatasetComponent.

do_serialize() ShareableDatasetComponentMessage

Private method to serialize the ShareableDatasetComponent

Returns

ShareableDatasetComponentMessage: Proto-Buffer Message for ShareableDatasetComponentMessage

classmethod get_name() str

Get the name of ShareableDatasetComponent, Optionally subclasses can override this method if custom name is required.

Returns

str: Name of ShareableDatasetComponent

abstract merge(other: ShareableDatasetComponent, **kwargs: Any) ShareableDatasetComponent

Merge the current SDC to other SDC of same type. The subclass must produce a new instance of SDC and not mutate the current one.

Parameters

otherShareableDatasetComponent

Other SDC that need be merged.

Returns

ShareableDatasetComponent

Must be a new instance of SDC, and should not mutate the current or other SDCs.

Module contents