This repository was archived by the owner on Dec 6, 2023. It is now read-only.
This repository was 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
Description
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.