Reputation: 6898
I'm trying to pass a set of [X_train, X_val] to X of random_search.fit()
and the same to y with:
random_search.fit(X=[X_train, X_val], y=[y_train, y_val])
But when the training occurs the below error is displayed:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
During handling of the above exception, another exception occurred:
TypeError: can not initialize DMatrix from list
I already tried using group
field of fit method but I got another error. There any way of pass train/test and his evaluations sets for the fit method of Random Search? I can't figure out how to do this.
Upvotes: 0
Views: 290
Reputation: 1125
Maybe I have not understood correctly but if you want to use RandomizedSearchCV
on
the training and the validation samples concatenated together and use CV on this whole sample,
I suggest using np.concatenate
instead of list comprehension as follows:
# taking examples for your X_train, X_val, y_train and y_val
import numpy as np
X_train = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
X_val = np.array([[1, 2, 3], [4, 5, 6]])
y_train = np.array([10, 11, 12])
y_val = np.array([13, 14])
data = np.concatenate((X_train, X_val), axis=0)
target = np.concatenate((y_train, y_val))
And you can pass data
and target
to the fit method.
Upvotes: 2