Skip to content
This repository has been archived by the owner on Dec 6, 2023. It is now read-only.

Usability: Earth.fit exception when fitted multiple times on different X num_features #198

Open
hdinh opened this issue May 17, 2019 · 1 comment
Labels

Comments

@hdinh
Copy link

hdinh commented May 17, 2019

Getting ValueError: Wrong number of columns in X. Reshape your data. exception if Earth is fitted multiple times if the number of features of X changes. From a usability standpoint, this seems weird because this doesn't seem to be consistent with other sklearn estimators.

As a user, I would expect the classifier to ignore the past basis_ value and refit at each fit call.

from sklearn.base import RegressorMixin
from sklearn.datasets import make_friedman1
from sklearn.utils.testing import all_estimators
from pyearth import Earth

def check_classifier(clf):
    X, y = make_friedman1(100, 6)
    clf.fit(X, y)
    X2, y2 = make_friedman1(100, 5)
    clf.fit(X2, y2)

classifiers = [(klass_name, klass) for klass_name, klass in all_estimators() if issubclass(klass, RegressorMixin)]
for klass_name, klass in classifiers:
    if 'MultiTask' in klass_name: continue
    check_classifier(klass())

check_classifier(Earth()) # only one that throws, ValueError: Wrong number of columns in X. Reshape your data.

@jcrudy
Copy link
Collaborator

jcrudy commented Jul 28, 2019

@hdinh Thanks for reporting this. This should be an easy enough fix, but I won't have time to make it for a while. If you're interested, I would welcome a pull request and would have time to review and offer feedback. Also, I'm curious what the use case is for fitting the same model on new data. I'm probably missing something here, but wouldn't it make more sense to just create a new model?

@jcrudy jcrudy added the bug label Jul 28, 2019
kesumab added a commit to hamiddimyati/stacking-regression-comparative-study that referenced this issue Dec 6, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants