Created
January 29, 2019 15:27
-
-
Save pedroduartecosta/66e3094f7cb3a14404a1a615367545f2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val categoricalVariables = if(useCategorical){ | |
Array("Origin", "Dest") | |
}else{ | |
null | |
} | |
val categoricalIndexers = if(useCategorical){ | |
categoricalVariables.map(i => new StringIndexer().setInputCol(i).setOutputCol(i+"Index").setHandleInvalid("skip")) | |
}else{ | |
null | |
} | |
val categoricalEncoders = if(useCategorical){ | |
categoricalVariables.map(e => new OneHotEncoder().setInputCol(e + "Index").setOutputCol(e + "Vec").setDropLast(false)) | |
}else{ | |
null | |
} | |
val assembler = if(useCategorical){ | |
new VectorAssembler() | |
.setInputCols(Array("OriginVec", "DestVec", "DepDelayDouble", "TaxiOutDouble")) | |
.setOutputCol("features") | |
.setHandleInvalid("skip") | |
}else{ | |
new VectorAssembler() | |
.setInputCols(Array("DepDelayDouble", "TaxiOutDouble")) | |
.setOutputCol("features") | |
.setHandleInvalid("skip") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment