我正在传递一个数据框,每行包含两列包含numpy数组的两个randomforestclassifier
它给了我这个错误
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-110-e0a56908e930> in <module>()
1 clf = RandomForestClassifier(max_depth=2)
----> 2 clf.fit(X_train, y_train)
sklearn\ensemble\forest.py in fit(self, X, y, sample_weight)
245 """
246 # Validate or convert input data
--> 247 X = check_array(X, accept_sparse="csc", dtype=DTYPE)
248 y = check_array(y, accept_sparse='csc', ensure_2d=False, dtype=None)
249 if sample_weight is not None:
sklearn\utils\validation.py in check_array(array, accept_sparse, dtype, order, copy, force_all_finite, ensure_2d, allow_nd, ensure_min_samples, ensure_min_features, warn_on_dtype, estimator)
431 force_all_finite)
432 else:
--> 433 array = np.array(array, dtype=dtype, order=order, copy=copy)
434
435 if ensure_2d:
ValueError: setting an array element with a sequence.
我在堆栈溢出时遇到了两个几乎相同的问题但是没有有用的答案,这就是我创建新问题的原因