Reputation: 1
I am using HistGradientBoostingRegressor
My code :-
X_train, X_test, y_train, y_test = train_test_split(Train, target, test_size=0.2, random_state=16)
model = HistGradientBoostingRegressor(learning_rate = 0.1,
max_iter=800,
random_state = 16,
validation_fraction=None,
verbose = 0,
max_depth=12,
min_samples_leaf=25,
l2_regularization=0.05)
model.fit(X_train, y_train)
I am getting the error as shown in the title from .fit() method, and didn't understand much from the documentation as I am new to ML. Error :
ValueError Traceback (most recent call last)
in
7 min_samples_leaf=25,
8 l2_regularization=0.05)
----> 9 model.fit(X_train, y_train)
/opt/conda/lib/python3.6/site-packages/sklearn/ensemble/_hist_gradient_boosting/gradient_boosting.py in fit(self, X, y)
102 # time spent predicting X for gradient and hessians update
103 acc_prediction_time = 0.
--> 104 X, y = check_X_y(X, y, dtype=[X_DTYPE], force_all_finite=False)
105 y = self._encode_y(y)
106
/opt/conda/lib/python3.6/site-packages/sklearn/utils/validation.py in check_X_y(X, y, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, multi_output, ensure_min_samples, ensure_min_features, y_numeric, warn_on_dtype, estimator)
753 ensure_min_features=ensure_min_features,
754 warn_on_dtype=warn_on_dtype,
--> 755 estimator=estimator)
756 if multi_output:
757 y = check_array(y, 'csr', force_all_finite=True, ensure_2d=False,
/opt/conda/lib/python3.6/site-packages/sklearn/utils/validation.py in check_array(array, accept_sparse, accept_large_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, ensure_min_samples, ensure_min_features, warn_on_dtype, estimator)
473
474 if all(isinstance(dtype, np.dtype) for dtype in dtypes_orig):
--> 475 dtype_orig = np.result_type(*dtypes_orig)
476
477 if dtype_numeric:
<array_function internals> in result_type(*args, **kwargs)
ValueError: at least one array or dtype is required
Thanks for any help
Upvotes: 0
Views: 3783
Reputation: 33
I had similar issue when I was using StandardScaler
to fit_transform()
.
I found, I had one column which was non-numeric causing :
ValueError: at least one array or dtype is required
I dropped that column to resolve the issue.
Please look into data types of your data.
Upvotes: 1