I compute an array and it has a shape = 800*1140. The ndarray was generated from a previous step and the elements were stacked using hstack. I need to insert this into the scikitlearn for training and I have the following error:
ValueError: Found array with dim 1140. Expected 800
I think my error might be similar to this but I do not know how to proceed.
Can someone give me pointers ? Here is the code that causes the error : error is caused while running line XTrain.....
X_scaled = preprocessing.scale(self.featureMatrix)
imp = Imputer(missing_values='NaN', strategy='mean', axis=0)
X_scaled = imp.fit_transform(X_scaled)
classiFier = svm.SVC(C=10, cache_size=1500, class_weight=None, coef0=0.0, degree=3, gamma=0.0, kernel='rbf', max_iter=-1, probability=False, random_state=None, shrinking=True, tol=0.001, verbose=False)
XTrain, XTest, yTrain, yTest = cv.train_test_split(X_scaled,
self.classID,
test_size=0.4,
random_state=0)
Here is the entire Traceback:
Traceback (most recent call last):
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition
4.5.3\helpers\pydev\pydevd.py", line 2358, in <module>
globals = debugger.run(setup['file'], None, None, is_module)
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition
4.5.3\helpers\pydev\pydevd.py", line 1778, in run
pydev_imports.execfile(file, globals, locals) # execute the script
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition#
4.5.3\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "C:/Users/vaidvj/svn/idmt/core/wrappers/afp/test/data/Urban_Sound_DB
/train&testSVM_MF.py", line 133, in <module>
c.process()
File "C:/Users/vaidvj/svn/idmt/core/wrappers/afp/test/data/Urban_Sound_DB
/train&testSVM_MF.py", line 129, in process
self.confMatcal( self.MfeatureMatrix, self.classID, self.uniqueClassLabels)
File "C:/Users/vaidvj/svn/idmt/core/wrappers/afp/test/data/Urban_Sound_DB/train&testSVM_MF.py", line 49, in confMatcal
random_state=0)
File "C:\Anaconda3\lib\site-packages\sklearn\cross_validation.py", line 1556, in train_test_split
arrays = check_arrays(*arrays, **options)
File "C:\Anaconda3\lib\site-packages\sklearn\utils\validation.py", line 254, in check_arrays
% (size, n_samples))
ValueError: Found array with dim 1140. Expected 800
thank you.