mlm_insights.core.sfcs.interfaces package

Submodules

mlm_insights.core.sfcs.interfaces.shareable_feature_component module

class mlm_insights.core.sfcs.interfaces.shareable_feature_component.ShareableFeatureComponent

Bases: ABC

Abstract Base Class for Sharable Feature Component. These components will be shared across other feature component such as Metrics. The subclass must be annotated with @dataclass. All the state of SFC must be mergeable. Subclasses need to implement merge method to merge two SFC 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(column: Series, **kwargs: Any) None

Update the state of the SFC using input series.

Parameters

columnpd.Series

Input column.

abstract classmethod create(config: Dict[str, ConfigParameter] | None = None) ShareableFeatureComponent

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

Returns

ShareableFeatureComponent

An Instance of SFC.

classmethod do_deserialize(serialized_sfc: ShareableFeatureComponentMessage) ShareableFeatureComponent

Private method to deserialize the ShareableFeatureComponent from Protobuffer message.

Returns

ShareableFeatureComponent: Deserialized the protobuffer message to ShareableFeatureComponent.

do_serialize() ShareableFeatureComponentMessage

Private method to serialize the ShareableFeatureComponent

Returns

ShareableFeatureComponentMessage: Proto-Buffer Message for ShareableFeatureComponentMessage

classmethod get_name() str

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

Returns

str: Name of SharableFeatureComponent

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

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

Parameters

otherShareableFeatureComponent

Other SFC that need be merged.

Returns

ShareableFeatureComponent

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