Repository: evidentlyai/evidently
Issue: Regression metrics raise "No default regression in data definition" with valid mapping in v0.7.3
Root cause: Documentation Deficiency

Hi Evidently team,

I’m encountering a blocking issue with regression metrics in Evidently v0.7.3.
When generating a regression report using the modern API, I consistently get the following error, even though my dataframes and mapping are correct and follow the documentation.

Minimal reproducible code (no data shared):


```python
import pandas as pd
from evidently import Report
from evidently.metrics import MAE, RMSE, R2Score, MAPE

# Assume ref_df and cur_df are valid DataFrames with the columns below
TARGET = "cnt"
PRED = "prediction"
NUM_FEATS = [list of cols]
CAT_FEATS = [list of cols]

column_mapping = {
    "target": TARGET,
    "prediction": PRED,
    "numerical_features": NUM_FEATS,
    "categorical_features": CAT_FEATS
}

reg_report = Report(metrics=[
    MAE(target_column=TARGET, prediction_column=PRED),
    RMSE(target_column=TARGET, prediction_column=PRED),
    R2Score(target_column=TARGET, prediction_column=PRED),
    MAPE(target_column=TARGET, prediction_column=PRED)
])
reg_report.run(ref_df, cur_df, column_mapping)
```

Error:

```sh
ValueError: No default regression in data definition
```

Debug info:

- Both ref_df and cur_df have the same columns
- The mapping dict is: {'target': 'cnt', 'prediction': 'prediction', ...}
- Python version: 3.11.11
- Evidently version: 0.7.3

**What I expect:**
The regression metrics should work as documented when passing a mapping and valid columns.

**What happens:**
The error above is always raised, regardless of mapping or DataFrame structure.

Note:
Something is definitely going on with your last version.

Thanks for your help !

Hi @ssime-git,

It looks like you are actually using the old Evidently API (e.g. referencing column mapping instead of data definition) - not the one that is currently documented. (If there are any pages in the **current** documentation referencing it - please let us know, we'll correct it).

You can check the minimal example for regression here

https://github.com/evidentlyai/evidently/blob/main/examples/cookbook/metrics.ipynb 

For details about the change in API, check the docs.
https://docs.evidentlyai.com/faq/migration


Thank you for your reply and the documentation links.

However, I am still encountering the same error with the latest Evidently API, even after following the current documentation and using the new DataDefinition and Dataset workflow.

Here’s what I’m doing:

```python
from evidently import Dataset, DataDefinition, Report
from evidently.metrics import MAE, RMSE, R2Score, MAPE

schema = DataDefinition(
    numerical_columns=[list-of-col],
    categorical_columns=[list-of-col]
)
ref_dataset = Dataset.from_pandas(ref_df, data_definition=schema)
cur_dataset = Dataset.from_pandas(cur_df, data_definition=schema)

reg_report = Report([
    MAE(target_column="cnt", prediction_column="prediction"),
    RMSE(target_column="cnt", prediction_column="prediction"),
    R2Score(target_column="cnt", prediction_column="prediction"),
    MAPE(target_column="cnt", prediction_column="prediction")
])
reg_report.run(ref_dataset, cur_dataset)
```

But I still get:

```sh
ValueError: No default regression in data definition
```

The DataFrames have the correct columns (cnt, prediction, and all features).
The schema is passed as per the docs.
The metrics are instantiated with explicit target_column and prediction_column.
Debug print of schema:

```sh
schema: id_column=None timestamp=None numerical_columns=[...] categorical_columns=[...] text_columns=None datetime_columns=None classification=None regression=None llm=None ...
```

Question:
Is there an additional step needed to declare a regression task in the DataDefinition or elsewhere?
Or is there a breaking change in the API or a bug that prevents regression metrics from working, even with the new workflow?

If there is a minimal working example for regression with the latest release, could you please share it?
Thanks for your help!


You need to create Regression mapping as shown in the example: 

```
definition = DataDefinition(
    regression=[Regression(target="cnt", prediction="prediction")]
    )
```

Here are the docs on Data Definition https://docs.evidentlyai.com/docs/library/data_definition#regression

Then, when you create the Report you simply list the metrics. There is no need to pass column names as parameters.

```
reg_report = Report([
    MAE(),
    RMSE()
])
```

You can check all metric parameters here https://docs.evidentlyai.com/metrics/all_metrics#regression
(Regression metrics do not have any further parameters to specify.)

You can run the minimal working example in the notebook I linked, scroll to the regression section:
https://github.com/evidentlyai/evidently/blob/main/examples/cookbook/metrics.ipynb



Thank you, it worked. I will take another look at the doc since I got another issue. but thank you for your feedback

@ssime-git awesome, glad this one is solved! 🚀