inverse transformatio to the code written by python jupyter notebook

I have this code written by a friend of mine, he made transformation using minMax scaler, I need to transform the data back using inverse transformation, I tried to use the MinMaxScaler() but not worked, I hope to find the answer to my issue. the code: #Prepare dictionary with accuracy values accuracies = {}

#Iterate over each well for col in df: #Transform data using funciton made before x_train, y_train, x_test, y_test = prepare_data(df[col], 0.8, prev_data_samples=4)

#Build and fit a model for each well
knn = KNeighborsRegressor(n_neighbors=10), [i[0] for i in y_train])

#Make predictions on test data
predictions = knn.predict(x_test)

#scaler = MinMaxScaler()
#rescalData = scaler.inverse_transform(predictions.reshape(-1,1))
mae= mean_absolute_error(y_test,predictions)                
#Calculate Accuracy and store into dictionary
accuracy = np.abs(1 - np.average(np.abs(y_test - predictions) / y_test))
accuracies[col] = accuracy

Read more here:

Content Attribution

This content was originally published by Asem Shurrab at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: