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 Text Evals Preset

From Leeroopedia
Knowledge Sources
Domains ML Monitoring, NLP, Text Analysis
Last Updated 2026-02-14 12:00 GMT

Overview

TextEvals is a metric preset that generates column summary metrics for a set of text descriptors applied to a specified text column.

Description

The TextEvals class extends MetricPreset and provides a convenient way to evaluate text quality characteristics on a given column. It applies a list of text feature descriptors to the target column and produces a ColumnSummaryMetric for each descriptor.

If no custom descriptors are provided, the preset uses a default set of five descriptors:

  • TextLength -- measures the length of text
  • SentenceCount -- counts the number of sentences
  • Sentiment -- computes sentiment scores
  • OOV -- measures out-of-vocabulary word ratio
  • NonLetterCharacterPercentage -- computes the percentage of non-letter characters

Each descriptor is applied to the specified column via desc.on(self.column_name), and the result is wrapped in a ColumnSummaryMetric.

The class is registered with the type alias "evidently:metric_preset:TextEvals".

Usage

Use this preset when you need to quickly evaluate text quality characteristics of a text column in your dataset. It is suitable for monitoring text data quality in NLP pipelines and detecting changes in text properties between reference and current data.

Code Reference

Source Location

Signature

class TextEvals(MetricPreset):
    class Config:
        type_alias = "evidently:metric_preset:TextEvals"

    column_name: str
    descriptors: Optional[List[FeatureDescriptor]] = None

    def __init__(self, column_name: str, descriptors: Optional[List[FeatureDescriptor]] = None):
        ...

    def generate_metrics(
        self, data_definition: DataDefinition, additional_data: Optional[Dict[str, Any]]
    ) -> List[AnyMetric]:
        ...

Import

from evidently.legacy.metric_preset.text_evals import TextEvals

I/O Contract

Inputs

Name Type Required Description
column_name str Yes The name of the text column to evaluate.
descriptors Optional[List[FeatureDescriptor]] No A list of feature descriptors to apply. Defaults to [TextLength, SentenceCount, Sentiment, OOV, NonLetterCharacterPercentage].

Outputs

Name Type Description
return List[AnyMetric] A list of ColumnSummaryMetric instances, one per descriptor applied to the specified text column.

Usage Examples

from evidently.legacy.metric_preset.text_evals import TextEvals
from evidently.legacy.report import Report

# Evaluate text column with default descriptors
report = Report(metrics=[TextEvals(column_name="review_text")])
report.run(reference_data=ref_df, current_data=curr_df)

# Evaluate text column with custom descriptors
from evidently.legacy.descriptors import TextLength, Sentiment
report = Report(metrics=[
    TextEvals(column_name="review_text", descriptors=[TextLength(), Sentiment()])
])
report.run(reference_data=ref_df, current_data=curr_df)

Related Pages

Page Connections

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