Column mapping
How to use column mapping in Evidently.
Last updated
How to use column mapping in Evidently.
Last updated
Column mapping helps map your input data schema or specify column types. For example, to run evaluation on text data, you must specify which columns in your dataset contain texts. This allows Evidently to process the input data correctly.
You can create a ColumnMapping
object in Python prior to generating a Report or Test Suite or map the columns visually when working in the Evidently platform.
You only need to map columns that will be used in your evaluations.
If the column_mapping
is not specified or set as None
, Evidently will use the default mapping strategy, trying to match the columns automatically.
Column types:
All columns with numeric types (np.number) will be treated as Numerical.
All columns with DateTime format (np.datetime64) will be treated as DateTime.
All other columns will be treated as Categorical.
Dataset structure:
The column named "id" will be treated as an ID column.
The column named "datetime" will be treated as a DateTime column.
The column named "target" will be treated as a target column with a true label or value.
The column named "prediction" will be treated as a model prediction.
To run certain types of evaluations, you must include specific columns or provide a reference dataset. For example, to run text evaluations, you must have at least one column labeled as text. To run data drift checks, you always need a reference dataset.
Here are example requirements:
Text Evals
Required (Text)
Optional
Optional
Optional
Optional
Optional
Data Quality
Required (Any)
Optional
Optional
Optional
Optional
Optional
Data Drift
Required (Any)
Optional
Optional
Optional
Optional
Required
Target Drift
Optional
Target and/or prediction required
Target and/or prediction required
Optional
Optional
Required
Classification
Optional
Required
Required
Optional
Optional
Optional
Regression
Optional
Required
Required
Optional
Optional
Optional
Notebook example on specifying column mapping:
Imports. Imports to use column mapping:
To map columns containing DateTime and ID:
To map columns containing Target and Prediction:
To split the columns into numerical and categorical types, pass them as lists:
To specify columns that contain text data:
To specify which columns in your dataset contain embeddings, pass a dictionary where keys are embedding names and values are lists of columns.
Here is an example of how you point to the defined list of columns that contain embeddings:
You might have temporal features in your dataset. For example, “date of the last contact.”
To map them, pass them as a list:
It’s often important to specify whether your Target column is continuous or discrete. This impacts Data Quality, Data Drift, and Target Drift evaluations for the Target column.
To define it explicitly, specify the task parameter:
It accepts the following values:
regression
classification
recsys
(for ranking and recommenders)
Default: If you don't specify the task, Evidently will use a simple strategy: if the target has a numeric type and the number of unique values > 5: task == ‘regression.’ In all other cases, the task == ‘classification’.
Basic API. Once you create a ColumnMapping
object, you pass it along with the data when computing the . For example:
This matches regression or simple classification tasks. For more complex cases, check detailed instructions on how to map inputs for and .
Why map them: Column types impact evaluations. For example, the data selects statistical tests based on column type, or ColumnSummaryMetric
visualizations change with feature type. Manually mapping columns avoids errors, like numerical columns with few unique values being mistaken for categorical.