Skip to content

Instantly share code, notes, and snippets.

@ajayborra
Created November 5, 2018 19:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ajayborra/243c7e17679c12e7df946875a1a2f9f1 to your computer and use it in GitHub Desktop.
Save ajayborra/243c7e17679c12e7df946875a1a2f9f1 to your computer and use it in GitHub Desktop.
Creating Features and Lables
// create features
val featureCols = Array("medianIncome", "housingMedianAge", "totalRooms", "totalBedrooms",
"population", "households", "latitude", "longitude")
val vectorAssembler = new VectorAssembler().setInputCols(featureCols).setOutputCol("features")
//create Label and Features
val featuresDf = vectorAssembler.transform(castedDF).select("medianHouseValue", "features")
//print label/feature
featuresDf.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment