ValueError: setting an array element with a sequence. while using SVM in scikit-learn ValueError: setting an array element with a sequence. while using SVM in scikit-learn arrays arrays

ValueError: setting an array element with a sequence. while using SVM in scikit-learn


Finally I found the answer to my question with the help of some ideas from @larsmans and @eickenberg. The problem was that X_train did not have the same number of elements in all the arrays. So, it was not able to form a 2D array. Now that I have added an additional value to that array, the dimensionality matched for all the 1D arrays and X_train was able to form a 2D array. Thanks for the ideas guys!


I had the same problem. The size of the data was consistent, so that did not help. What did work:clf.fit(list(X_train),Y_train)


I see the error when X_train has n elements and all n elements are of not same size.Workaround is to make sure all n elements in the X_train are of same size either by padding or trimming techniques.