Skip to content
Advertisement

Singleton array array(, dtype=object) cannot be considered a valid collection

Not sure how to fix . Any help much appreciate. I saw thi Vectorization: Not a valid collection but not sure if i understood this

JavaScript

error below :

JavaScript

Not sure how to fix . Any help much appreciate. I saw thi Vectorization: Not a valid collection but not sure if i understood this

Advertisement

Answer

This error arises because your function train masks your variable train, and hence it is passed to itself.

Explanation:

You define a variable train like this:

JavaScript

Then after some lines, you define a method train like this:

JavaScript

So what actually happens is, your previous version of train is updated with new version. That means that the train now does not point to the Dataframe object as you wanted, but points to the function you defined. In the error it is cleared.

JavaScript

See the function train inside the error statement.

Solution:

Rename one of them (the variable or the method). Suggestion: Rename the function to some other name like training or training_func or something like that.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement