Skip to content

Instantly share code, notes, and snippets.

@ari-vedant-jain
Created March 16, 2017 16:31
Show Gist options
  • Save ari-vedant-jain/8835caf712de000bc3376428ec09f0aa to your computer and use it in GitHub Desktop.
Save ari-vedant-jain/8835caf712de000bc3376428ec09f0aa to your computer and use it in GitHub Desktop.
# From spark 1.x to spark 2.x
from pyspark.ml.linalg import VectorUDT
from pyspark.sql.functions import udf
as_ml = udf(lambda v: v.asML() if v is not None else None, VectorUDT())
result = labeledData.withColumn("features", as_ml("features"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment