Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Evidentlyai Evidently Legacy Custom Descriptor

From Leeroopedia
Revision as of 12:28, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Evidentlyai_Evidently_Legacy_Custom_Descriptor.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains ML Monitoring, Feature Engineering
Last Updated 2026-02-14 12:00 GMT

Overview

Provides descriptor classes that wrap user-defined callable functions into generated features for single-column and pair-column evaluation in the Evidently legacy pipeline.

Description

This module defines two descriptor classes, CustomColumnEval and CustomPairColumnEval, which serve as high-level wrappers that let users supply arbitrary Python functions to compute custom features on DataFrame columns.

CustomColumnEval extends FeatureDescriptor and accepts a function operating on a single pd.Series. When its feature() method is called with a column name, it instantiates a CustomSingleColumnFeature with the provided function, display name, feature type, and an auto-generated name (falling back to the function's __name__ attribute or a new UUID if unavailable).

CustomPairColumnEval extends GeneralDescriptor and accepts a function operating on two pd.Series objects. It requires explicit specification of first_column and second_column names. Its feature() method instantiates a CustomPairColumnFeature with those columns and the provided callable.

Both classes use the ColumnType enum to specify the resulting feature type (e.g., Numerical, Categorical) and delegate actual feature generation to the corresponding classes in evidently.legacy.features.custom_feature.

Usage

Use CustomColumnEval when you need to compute a derived feature from a single text or data column using a custom transformation function. Use CustomPairColumnEval when your custom logic requires comparing or combining two columns (e.g., computing a similarity score between two text fields). These descriptors integrate with the Evidently report and test suite pipeline via the descriptor-to-feature pattern.

Code Reference

Source Location

Signature

class CustomColumnEval(FeatureDescriptor):
    class Config:
        type_alias = "evidently:descriptor:CustomColumnEval"

    func: Callable[[pd.Series], pd.Series]
    display_name: str
    feature_type: Union[str, ColumnType]
    name: str = ""

    def feature(self, column_name: str) -> GeneratedFeature: ...


class CustomPairColumnEval(GeneralDescriptor):
    class Config:
        type_alias = "evidently:descriptor:CustomPairColumnEval"

    func: Callable[[pd.Series, pd.Series], pd.Series]
    display_name: str
    first_column: str
    second_column: str
    feature_type: Union[str, ColumnType]

    def feature(self) -> GeneratedFeature: ...

Import

from evidently.legacy.descriptors.custom_descriptor import CustomColumnEval
from evidently.legacy.descriptors.custom_descriptor import CustomPairColumnEval

I/O Contract

Inputs

CustomColumnEval:

Name Type Required Description
func Callable[[pd.Series], pd.Series] Yes A function that takes a single pandas Series and returns a transformed Series.
display_name str Yes Human-readable name for the generated feature.
feature_type Union[str, ColumnType] Yes The column type of the resulting feature (e.g., "numerical", "categorical").
name str No Optional name identifier for the feature. Defaults to the function's __name__ or a generated UUID.
column_name str Yes (at call time) The column to apply the function to, passed to the feature() method.

CustomPairColumnEval:

Name Type Required Description
func Callable[[pd.Series, pd.Series], pd.Series] Yes A function that takes two pandas Series and returns a result Series.
display_name str Yes Human-readable name for the generated feature.
first_column str Yes Name of the first DataFrame column to pass to the function.
second_column str Yes Name of the second DataFrame column to pass to the function.
feature_type Union[str, ColumnType] Yes The column type of the resulting feature.

Outputs

Name Type Description
feature() return GeneratedFeature A CustomSingleColumnFeature or CustomPairColumnFeature instance ready for feature generation in the Evidently pipeline.

Usage Examples

import pandas as pd
from evidently.legacy.descriptors.custom_descriptor import CustomColumnEval, CustomPairColumnEval

# Single column: compute string length
length_descriptor = CustomColumnEval(
    func=lambda s: s.str.len(),
    display_name="Text Length",
    feature_type="numerical",
)
feature = length_descriptor.feature("response_text")

# Pair column: compute equality ratio
pair_descriptor = CustomPairColumnEval(
    func=lambda s1, s2: (s1 == s2).astype(int),
    display_name="Exact Match",
    first_column="prediction",
    second_column="target",
    feature_type="categorical",
)
pair_feature = pair_descriptor.feature()

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment