mlm_insights.core.features package

Submodules

mlm_insights.core.features.feature module

class mlm_insights.core.features.feature.Feature(feature_metadata: FeatureMetadata)

Bases: object

add_metric(metric_metadata: MetricMetadata) Feature

Add a Insights Metric to a feature by providing the Metric Metadata. When added, Insights computes the metric for the feature and makes the metric result available via the Insights Profile

Parameters

metric_metadataMetricMetadata

Metric Metadata describing the metric to be added. At a minimum, klass must be provided

add_sfc(sfc_metadata: SFCMetaData) Feature

Add a Shareable Feature Component (SFC) to a Feature by providing the SFC Metadata. Insights computes the SFC once which can be shared with all the Feature-level metrics. Insights makes the SFC result available via the Insights Profile

Parameters

sfc_metadataSFCMetaData

SFC Metadata describing the metric to be added. At a minimum, klass must be provided

compute(column: Series) None

Compute the Feature metrics and Shareable Feature Component

Parameters

column: pd.Series

Pandas Series which contains the feature data.

classmethod deserialize(feature_message: FeatureMessage) Feature

Deserializes “Feature” from the protobuf FeatureMessage. Delegates constituent part deserialization to respective deserializers

equals(other_feature: Feature) bool
get_metric(metric_metadata: MetricMetadata) MetricBase

Get the Metric instance based on the Metric Metadata. Pass the same Metric Metadata as used in add_metric

Parameters

metric_metadataMetricMetadata

Metric Metadata describing the metric to be added. At a minimum, klass must be provided

Returns

MetricBase

Metric Instance

get_name() str
get_sfc(sfc_metadata: SFCMetaData) ShareableFeatureComponent

Get the ShareableFeatureComponent instance based on the SFC Metadata. Pass the same SFC Metadata as used in add_sfc

Parameters

sfc_metadataSFCMetaData

SFC Metadata describing the SFC to be added. At a minimum, klass must be provided

Returns

ShareableFeatureComponent

SFC Instance

merge(other_feature: Feature) Feature
Merges 2 features to return a new Feature. Merge of 2 features involves:
1. Merging metrics
2. Merging SFC

Merge follows Insights guideline of not mutating existing Features and new copies of existing state into the new Feature

serialize() FeatureMessage

Serializes a Feature into its ProtoBuf equivalent message. This method serializes all the constituent components i.e. metrics, SFCs

Returns

FeatureMessage

Protobuf equivalent message

class mlm_insights.core.features.feature.FeatureMetadata(feature_name: str, feature_type: FeatureType)

Bases: object

Class describes the properties for a Feature

feature_name: str

Feature Type describing the feature schema i.e data type, variable type, column type

feature_type: FeatureType
to_string() str