我是pyspark和ApacheSpark机器学习库的新手。 我正在尝试将OneHotEncoder应用于Spark MLlib中的几个分类列。 首先我使用了stringIndexer,它可以工作
categoricalColumns是数据集中我的分类列的列表
stringIndexer = StringIndexer(
inputCols=[categoricalCol for categoricalCol in categoricalColumns],
outputCols=[categoricalCol + "_index" for categoricalCol in categoricalColumns]
)
mod_si = stringIndexer.fit(spark_df)
indexed_si = mod_si.transform(spark_df)
indexed_si.printSchema()
下一个热编码器
encoder = OneHotEncoder(
inputCols=[indexer.getOutputCol() for indexer in indexed_si],
outputCols=["_encoded".format(indexer.getOutputCol()) for indexer in indexed_si]
)
我不断地发现这个错误:
TypeError: 'Column' object is not callable
我读了编程指南,但我还不能解决它。任何帮助都将不胜感激
https://spark.apache.org/docs/latest/ml-features.html#onehotencoder
多谢各位
目前没有回答
相关问题 更多 >
编程相关推荐