Next-Generation Machine Learning with Spark by Butch Quinto

Next-Generation Machine Learning with Spark by Butch Quinto

Author:Butch Quinto
Language: eng
Format: epub
ISBN: 9781484256695
Publisher: Apress


val features = Array("avg_area_income","avg_area_house_age",

"avg_area_num_rooms","avg_area_num_bedrooms","area_population")

// Combine our features into a single feature vector.

import org.apache.spark.ml.feature.VectorAssembler

val assembler = new VectorAssembler()

.setInputCols(features)

.setOutputCol("features")

val dataDF2 = assembler.transform(dataDF)

dataDF2.select("price","features").show(20,50)

+------------------+--------------------------------------------------+

| price| features|

+------------------+--------------------------------------------------+

|1059033.5578701235|[79545.45857431678,5.682861321615587,7.00918814...|

| 1505890.91484695|[79248.64245482568,6.0028998082752425,6.7308210...|

|1058987.9878760849|[61287.067178656784,5.865889840310001,8.5127274...|

|1260616.8066294468|[63345.24004622798,7.1882360945186425,5.5867286...|

| 630943.4893385402|[59982.197225708034,5.040554523106283,7.8393877...|

|1068138.0743935304|[80175.7541594853,4.9884077575337145,6.10451243...|

|1502055.8173744078|[64698.46342788773,6.025335906887153,8.14775958...|

|1573936.5644777215|[78394.33927753085,6.9897797477182815,6.6204779...|

| 798869.5328331633|[59927.66081334963,5.36212556960358,6.393120980...|

|1545154.8126419624|[81885.92718409566,4.423671789897876,8.16768800...|

| 1707045.722158058|[80527.47208292288,8.09351268063935,5.042746799...|

| 663732.3968963273|[50593.69549704281,4.496512793097035,7.46762740...|

|1042814.0978200927|[39033.809236982364,7.671755372854428,7.2500293...|

|1291331.5184858206|[73163.6634410467,6.919534825456555,5.993187900...|

|1402818.2101658515|[69391.3801843616,5.344776176735725,8.406417714...|

|1306674.6599511993|[73091.86674582321,5.443156466535474,8.51751271...|

|1556786.6001947748|[79706.96305765743,5.067889591058972,8.21977112...|

| 528485.2467305964|[61929.07701808926,4.788550241805888,5.09700955...|

|1019425.9367578316|[63508.19429942997,5.947165139552473,7.18777383...|

|1030591.4292116085|[62085.27640340488,5.739410843630574,7.09180810...|

+------------------+--------------------------------------------------+

only showing top 20 rows



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.