Reputation: 143
My code is supposed to read audio files and predict another audio file(I dont care about accruacy for now just the error)
regr = svm.SVR()
print('Fitting...')
regr.fit(data0, data1)
clf1= regr.fit(sample_rate1,sample_rate0)
clf0 = regr.fit(data,data1)
print('Done!')
predata = clf.predict(data2)
predrate = clf1.predict(sample_rate2)
wavfile.write('result.wav',predrate,predata)# using predicted ndarrays it saves the audio file
The error which I get is:
Traceback (most recent call last):
File "D:\ Folder\Python\module properties\wav.py", line 10, in <module>
regr.fit(data0, data1)
File "C:\Users\Admin1\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\svm\_base.py", line 169, in fit
X, y = self._validate_data(X, y, dtype=np.float64,
File "C:\Users\Admin1\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\base.py", line 433, in _validate_data
X, y = check_X_y(X, y, **check_params)
File "C:\Users\Admin1\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\utils\validation.py", line 63, in inner_f
return f(*args, **kwargs)
File "C:\Users\Admin1\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\utils\validation.py", line 826, in check_X_y
y = column_or_1d(y, warn=True)
File "C:\Users\Admin1\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\utils\validation.py", line 63, in inner_f
return f(*args, **kwargs)
File "C:\Users\Admin1\AppData\Local\Programs\Python\Python39\lib\site-packages\sklearn\utils\validation.py", line 864, in column_or_1d
raise ValueError(
ValueError: y should be a 1d array, got an array of shape (8960, 2) instead.
Upvotes: 0
Views: 56
Reputation: 186
Check your independent and dependent variable X and y assignments.
The 'fit' function is used in the form model.fit(X,y), and the code that establishes the model fit and that gave you the error seems to be:
regr.fit(data0, data1)
Thus your predictor variables as written should be X = data0, and your target (output) variable should be y = data1.
Make sure you don't have it in reverse, and it shouldn't be:
regr.fit(data1, data0)
If the data is correctly assigned, try flattening the array.
You are also given the ValueError, "y should be a 1d array, got an array of shape (8960, 2) instead."
Flattening means converting a multidimensional array to a one dimensional array. Try reshape(-1).
data1 = data1.reshape(-1)
I hope this helps! Without any additional information about the dataset and the model's code, it's hard to figure out what to do next.
Upvotes: 1