undo scale data pyspark

Viewed 390
from pyspark.ml.feature import MinMaxScaler
from pyspark.ml.linalg import Vectors

df = spark.createDataFrame([
   (0, Vectors.dense([5.0, 0.1, -1.0]),),
   (1, Vectors.dense([2.0, 2.1, 1.0]),),
   (2, Vectors.dense([3.0, 10.1, 7.0]),)
], ["id", "features"])

scaler = MinMaxScaler(inputCol="features", outputCol="scaledFeatures")
scaler_model = scaler.fit(df)
scaled_data = scalerModel.transform(df)

scaled_data is the transformed data.

How I can do a inverse scale to analyse results after fitting a machine learning model ?

1 Answers

MinMaxScaler adds scaled features as a new scaledFeatures column, so your actual data isn't lost.

You can use the features column to analyse your scaledFeatures output column before using it into a machine learning model.

Related