首页 > 解决方案 > Pyspark 与一个热编码列的相关性

问题描述

我是 pyspark 的新手。
我想计算 acolumn(int)与 another之间的相关性column(vector from onehotencoder)
我使用这段代码:

import six
for i in df.columns:
    if not(isinstance(df.select(i).take(1)[0][0], six.string_types)):
        print( "Correlation to label for", i, df.stat.corr('label',i))

当计算标签 onehotencoder 列之间的相关性时出现此错误:

Py4JJavaError: An error occurred while calling o9219.corr. :
  java.lang.IllegalArgumentException:
    requirement failed:
      Currently correlation calculation for columns with dataType org.apache.spark.ml.linalg.VectorUDT@3bfc3ba7 not supported

标签: pythonapache-sparkpysparkcorrelationone-hot-encoding

解决方案


推荐阅读