0

I am trying to input data into a random-forest classifier, but it keeps telling me I'm using a sequence. I'm not sure how to convert the sequence into anything that is acceptable

I have tried feeding it into the classifier inside a list(), but that didn't work either.

this is an example of X_train[1]:

array([30, array([[0, 0, 1]]), 5.2304265, 7.233890799999999,
       array([[0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]]),
       array([[0, 1, 0, 0, 0, 0, 0]]), array([[0, 0, 0, 0, 1]]), 0, 0, 0,
       2, 10000.0, 13000.0, 30, 1], dtype=object)

.

clf = RandomForestClassifier(n_estimators=100, max_depth=2, random_state=0)
clf.fit(X_train, y_train)

...produces... ValueError: setting an array element with a sequence.

I expected it to accept the data, since it it is numerical, but it appears to reject the data

3

1 Answer 1

1

Have a look at the documentation for the fit() method from sci-kit learn.

It clearly states that the training features X must be of the following format

X : array-like or sparse matrix of shape = [n_samples, n_features]

It is expecting a 2D array. You will have to modify your training data to match the required format.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.