I have a pyspark dataframe on which I have applied Random Classifier model (from pyspark.ml.classification import RandomForestClassifier) for a multiclass data.
Now, I have the prediction and probability column (dense vector column). I want the single highest probability in a new column from the available probability column which corresponds to the prediction. Can you please let me know a way?
--------------------+----------+--------------+
| probability|prediction|predictedLabel|
+--------------------+----------+--------------+
|[0.04980166062108...| 9.0| 73.0|
|[0.09709955311030...| 2.0| 92.0|
|[0.00206441341895...| 1.0| 97.0|
|[0.01177280567423...| 8.0| 26.0|
|[0.09170364155771...| 4.0| 78.0|
|[0.09332145486133...| 0.0| 95.0|
|[0.15873541380236...| 0.0| 95.0|
|[0.21929050786626...| 0.0| 95.0|
|[0.08840100103254...| 1.0| 97.0|
|[0.06204585465363...| 1.0| 97.0|
|[0.06961837644280...| 1.0| 97.0|
|[0.04529447218955...| 1.0| 97.0|
|[0.02129073891494...| 2.0| 92.0|
|[0.02692350960234...| 1.0| 97.0|
|[0.02676868258573...| 8.0| 26.0|
|[0.01849528482881...| 1.0| 97.0|
|[0.10405735702064...| 1.0| 97.0|
|[0.01636762299564...| 1.0| 97.0|
|[0.01739759717529...| 1.0| 97.0|
|[0.02129073891494...| 2.0| 92.0|
+--------------------+----------+--------------+