8000 SplineTransformer raises when passing knots explicity for n_knots=None · Issue #19598 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content
SplineTransformer raises when passing knots explicity for n_knots=None #19598
Closed
@mlondschien

Description

@mlondschien

On master,

import numpy as np

from sklearn.preprocessing import SplineTransformer

X = np.linspace(0, 1, 10)[:, None]
splt = SplineTransformer(
   knots=[[0], [1], [2], [3], [4]],
   n_knots=None,
   degree=3
)

splt.fit(X)

currently raises

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-5-86bffa93d84e> in <module>
     10 )
     11 
---> 12 splt.fit(X)

~/code/scikit-learn/sklearn/preprocessing/_polynomial.py in fit(self, X, y)
    226             isinstance(self.n_knots, numbers.Integral) and self.n_knots >= 2
    227         ):
--> 228             raise ValueError("n_knots must be a positive integer >= 2.")
    229 
    230         if isinstance(self.knots, str) and self.knots in [

ValueError: n_knots must be a positive integer >= 2.

IMO the n_knots argument should be allowed to be None (or any other value) if the knots are passed explicity.

cc: @lorentzenchr @ogrisel
xref #18368 and #19483

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0