I am trying to convert a var assignment to a val assignment. Currently my code is
// Numerical vectorizing for normalization
var normNumericalColNameArray: Array[String] = Array()
if (!continousPredictors.sameElements(Array(""))) {
if (paramStandardize) {
println("Apply standardization")
stages += new VectorAssembler().setInputCols(continousPredictors).setOutputCol(NumericalFeaturesCol)
stages += new StandardScaler()
.setWithMean(true)
.setWithStd(true)
.setInputCol(NumericalFeaturesCol)
.setOutputCol(StandardizedNumericalFeaturesCol)
normNumericalColNameArray = Array(StandardizedNumericalFeaturesCol)
} else {
println("Not apply standardization")
stages += new VectorAssembler().setInputCols(continousPredictors).setOutputCol(NumericalFeaturesCol)
normNumericalColNameArray = Array(NumericalFeaturesCol)
}
}
stages += new VectorAssembler().setInputCols(normNumericalColNameArray ++ oneHotCatColNamesArray).setOutputCol(FeaturesCol)
and I want to do something like this
val normNumericalColNameArray =
if (continousPredictors.nonEmpty && paramStandardize) {
println("Apply standardization")
stages += new VectorAssembler().setInputCols(continousPredictors).setOutputCol(NumericalFeaturesCol)
stages += new StandardScaler()
.setWithMean(true)
.setWithStd(true)
.setInputCol(NumericalFeaturesCol)
.setOutputCol(StandardizedNumericalFeaturesCol)
Array(StandardizedNumericalFeaturesCol)
} else if (continousPredictors.nonEmpty){
println("Not apply standardization")
stages += new VectorAssembler().setInputCols(continousPredictors).setOutputCol(NumericalFeaturesCol)
Array(NumericalFeaturesCol)
}
stages += new VectorAssembler().setInputCols(normNumericalColNameArray ++ oneHotCatColNamesArray).setOutputCol(FeaturesCol)
and I run into this error
value ++ is not a member of Any
stages += new VectorAssembler().setInputCols(normNumericalColNameArray ++ oneHotCatColNamesArray).setOutputCol(FeaturesCol)
I am trying to return the Array from the if condition into my Val normNumericalColNameArray. Can somebody please help?