Skip to content

[BUG] GridSearchCV scoring=None gives AttributeError #1009

@MaazAli8460

Description

@MaazAli8460

Describe the bug
When scoring is left as None in GridSearchCV, fit crashes with an AttributeError. This appears to conflict with the documented behavior that scoring=None should default to CRPS.

To Reproduce

import pandas as pd
from sklearn.model_selection import KFold

from skpro.model_selection import GridSearchCV
from skpro.regression.dummy import DummyProbaRegressor

# Minimal data
X = pd.DataFrame({"x": [1, 2, 3, 4]})
y = pd.DataFrame({"y": [1.0, 2.0, 3.0, 4.0]})

gscv = GridSearchCV(
    estimator=DummyProbaRegressor(),
    cv=KFold(n_splits=2),
    param_grid={"strategy": ["empirical"]},
    scoring=None,
)

gscv.fit(X, y)

Observed Behavior

(.venv) D:\D drive\skpro>python x.py        
Traceback (most recent call last):
  File "D:\D drive\skpro\x.py", line 20, in <module>
    gscv.fit(X, y)
    ~~~~~~~~^^^^^^
  File "D:\D drive\skpro\skpro\regression\base\_base.py", line 116, in fit
    return self._fit(X_inner, y_inner)
           ~~~~~~~~~^^^^^^^^^^^^^^^^^^
  File "D:\D drive\skpro\skpro\model_selection\_tuning.py", line 111, in _fit
    scoring_name = f"test_{scoring.name}"
                           ^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'name'

Expected behavior

  1. If scoring is None, it should be resolved to a default metric CRPS. As stated in skpro\model_selection_tuning.py
Scoring:
* If None, defaults to CRPS()
  1. If None is no longer intended to be supported, docs should be updated.

Environment

Python version: 3.14.0 
skpro version: 2.12.0
skbase version: 0.13.1
scikit-learn version: 1.7.2
pandas version: 3.0.1
numpy version: 2.4.4
scipy version: 1.17.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions