GAA-UAM / scikit-fda

Functional Data Analysis Python package

Home Page:https://fda.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

AttributeError: SmoothingParameterSearch object has no attribute param_name

Quentin62 opened this issue · comments

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

  • OS: Ubuntu 22.04
  • Python version: 3.10.12
  • scikit-fda version: 0.8.1
  • Version of other packages involved: scikit-learn 1.3.1

+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.

Are you using the develop branch?

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

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.

It works with the develop branch

grid
SmoothingParameterSearch(estimator=KernelSmoother(kernel_estimator=KNeighborsHatMatrix()),
                         param_name='kernel_estimator__n_neighbors',
                         param_values=[2, 3])

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

It works fine with the version 0.9 from Pypi