How to reverse OneHotEncoderEstimator transformation in Spark

Viewed 143

So In Spark you can you OneHotEncoderEstimator to one-hot encode a column like this

import org.apache.spark.ml.feature.OneHotEncoderEstimator

val oneHotEncoder = new OneHotEncoderEstimator()
  .setInputCols(Array(...))
  .setOutputCols(...))
  .setDropLast(false)
oneHotEncoder.fit(...)

But how would you do the inverse operation? i.e. the equivalent of sklearn inverse_transform

enter image description here

0 Answers
Related