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 Non Letter Char Feature

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

Overview

Provides a generated feature that computes the percentage of non-letter, non-space characters in each value of a specified text column.

Description

The NonLetterCharacterPercentage class extends ApplyColumnGeneratedFeature to compute a numerical feature representing the share of characters in a text value that are neither alphabetic letters nor spaces. The calculation iterates over each character in the value, counting those where isalpha() returns False and the character is not a space. The final result is expressed as a percentage: 100 * non_letters_num / len(value).

Special handling is provided for None values and NaN floats, which return 0. The feature type is ColumnType.Numerical.

The class uses a display_name_template class variable set to "Non Letter Character % for {column_name}" for automatic display naming.

Usage

Use this feature to detect text quality issues such as excessive punctuation, special characters, or encoded content. It is useful for monitoring text data drift or evaluating the quality of generated text in LLM pipelines.

Code Reference

Source Location

  • Repository: Evidentlyai_Evidently
  • File: src/evidently/legacy/features/non_letter_character_percentage_feature.py

Signature

class NonLetterCharacterPercentage(ApplyColumnGeneratedFeature):
    class Config:
        type_alias = "evidently:feature:NonLetterCharacterPercentage"

    __feature_type__: ClassVar = ColumnType.Numerical
    display_name_template: ClassVar = "Non Letter Character % for {column_name}"
    column_name: str

    def __init__(self, column_name: str, display_name: Optional[str] = None): ...
    def apply(self, value: Any): ...

Import

from evidently.legacy.features.non_letter_character_percentage_feature import NonLetterCharacterPercentage

I/O Contract

Inputs

Name Type Required Description
column_name str Yes Name of the text column in the DataFrame to analyze
display_name Optional[str] No Custom display name for the feature (defaults to template-based name)

Outputs

Name Type Description
return float (per row) Percentage (0-100) of characters that are neither letters nor spaces; returns 0 for None/NaN values

Usage Examples

from evidently.legacy.features.non_letter_character_percentage_feature import NonLetterCharacterPercentage

# Create the feature for a column named "text"
non_letter_feature = NonLetterCharacterPercentage(column_name="text")

# With a custom display name
non_letter_feature = NonLetterCharacterPercentage(
    column_name="response",
    display_name="Special Char Percentage"
)

Related Pages

Page Connections

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