July 2018
Intermediate to advanced
334 pages
8h 20m
English
Now, we invoke the createDataFrame method with a parameter, getRows. This returns DataFrame with featureVector and speciesLabel (for example, Iris-setosa):
val dataFrame = spark.createDataFrame(result5).toDF(featureVector, speciesLabel)
Display the top 20 rows in the new dataframe:
dataFrame.show+--------------------+-------------------------+|iris-features-column|iris-species-label-column|+--------------------+-------------------------+| [5.1,3.5,1.4,0.2]| Iris-setosa|| [4.9,3.0,1.4,0.2]| Iris-setosa|| [4.7,3.2,1.3,0.2]| Iris-setosa|..........................................+--------------------+-------------------------+only showing top 20 rows
We need to index the species label column by converting the strings Iris-setosa, ...
Read now
Unlock full access