GAA-UAM / scikit-fda

Functional Data Analysis Python package
https://fda.readthedocs.io
BSD 3-Clause "New" or "Revised" License
308 stars 58 forks source link

AttributeError: SmoothingParameterSearch object has no attribute param_name #580

Closed Quentin62 closed 1 year ago

Quentin62 commented 1 year ago

When I run the following code (from the docs of SmoothingParameterSearch)

import numpy as np  # Note: this import is missing in the doc
import skfda
from skfda.preprocessing.smoothing import KernelSmoother
from skfda.misc.hat_matrix import KNeighborsHatMatrix
from skfda.preprocessing.smoothing.validation import SmoothingParameterSearch

x = np.linspace(-2, 2, 5)
fd = skfda.FDataGrid(x ** 2, x)
grid = SmoothingParameterSearch(
        KernelSmoother(
            kernel_estimator=KNeighborsHatMatrix()),
        [2,3],
        param_name='kernel_estimator__n_neighbors')
_ = grid.fit(fd)
np.array(grid.cv_results_['mean_test_score']).round(2)

grid is fitted and I can get its elements but when I run just grid

grid

I got

AttributeError: 'SmoothingParameterSearch' object has no attribute 'param_name'

Version information

eliegoudout commented 1 year ago

+1, I also encountered this when trying to update my project to sklearn 1.3.1.

I have not had time to try and fix anything yet.

vnmabus commented 1 year ago

Are you using the develop branch?

Quentin62 commented 1 year ago

no I use the version 0.8.1 from pypi (through poetry)

vnmabus commented 1 year ago

Please, try the development version, as I cannot reproduce it in the development branch.

If that works, I will try to release a version in the next days.

Quentin62 commented 1 year ago

It works with the develop branch

grid
SmoothingParameterSearch(estimator=KernelSmoother(kernel_estimator=KNeighborsHatMatrix()),
                         param_name='kernel_estimator__n_neighbors',
                         param_values=[2, 3])
vnmabus commented 1 year ago

As promised, I have just released version 0.9 in PyPI. If that version works for you, we can close this issue.

Quentin62 commented 1 year ago

It works fine with the version 0.9 from Pypi