I am working on a data, for preding output, I used SVR by bellow code:
from sklearn.svm import SVR
regressor = SVR(kernel = 'linear')
regressor.fit(trainX,trainY)
from sklearn.metrics import r2_score
pred = regressor.predict(testX)
print(pred)
The answer is : [0.58439621 0.58439621 0.58439621 ... 0.81262134 0.81262134 0.81262134]. I'm trying to inverse the scaling to real amount.
I search it in StackOverflow and reach this: https://stackoverflow.com/questions/49330195/how-to-use-inverse-transform-in-minmaxscaler-for-a-column-in-a-matrix, I implement every 2 answers in my code, but I get error yet. Can anyone help me with this?
I write this from above source:
import sklearn
from sklearn.preprocessing import MinMaxScaler
scale=sklearn.preprocessing.MinMaxScaler()
scale.min_,scale.scale_=scaler.min_[0],scaler.scale_[0]
scale.inverse_transform(pred)
but, I got same error as:
Blockquote Expected 2D array, got 1D array instead: array=[0.58439621 0.58439621 0.58439621 ... 0.81262134 0.81262134 0.81262134]. Reshape your data either using array.reshape(-1, 1) if your data has a single feature or array.reshape(1, -1) if it contains a single sample. Blockquote