Rana M Zubair
Rana M Zubair

Reputation: 37

I want to normalize my data values between range of 0 and 1

I have data values which are values of a vector and are stored in a List. I want those data values to be in range of (0,1) as I have to apply Inverse CDF on these values. The values are simple in a list

Suppose following are the values

val listOfValues = List(42.0,7.0,57.0,4.0)

I have seen some other solution but that involves complex data. Any help would be appreciated

Upvotes: 0

Views: 1003

Answers (1)

Som
Som

Reputation: 6323

Use VectorAssembler to convert Double -> Vector[Double] and then use MinMaxScaler

MinMaxScaler

MinMaxScaler transforms a dataset of Vector rows, rescaling each feature to a specific range (often [0, 1]). It takes parameters:

min: 0.0 by default. Lower bound after transformation, shared by all features. max: 1.0 by default. Upper bound after transformation, shared by all features.

Upvotes: 1

Related Questions