Reputation: 11
I am trying to get back the original values after predicting Cost.
I used MinMax feature scaling to scale the target feature. I got a scaled output. I am trying to convert them into original values but it shows me an error.
from sklearn.preprocessing import MinMaxScaler
scaler = MinMaxScaler()
food[["COST"]] = scaler.fit_transform(food[["COST"]])
scaler.inverse_transform(y)
pd.DataFrame(y,columns=["COST"])
y.to_excel("yg.xlsx",index=False)
I am trying to convert the predicted cost value to the original values and save a excel sheet with the original cost values. Please help!
Upvotes: 0
Views: 12893
Reputation: 91
Here is what you should do: Assume X is your original data, X_scaled is your scaled data, and you would like to get X_hat, which should be identical to X.
In other words:
X_scaled = scaler.fit_transform(X)
To get X_hat, first you have to create an external MinMaxScaler object:
obj = scaler.fit(X)
Then you use:
X_hat = obj.inverse_transform(X_scaled)
Upvotes: 7