Pysparkでランダムフォレストアルゴリズムを実行します。 Pyspark documentationには、VectorAssemblerが数値データ型またはブール型データ型のみを受け入れることが記述されています。だから、私のデータにStringtype変数、都市の名前などが含まれている場合は、ランダムフォレストの分類/回帰をさらに進めるために、それらをワンホットエンコードする必要がありますか?ここでPysparkのVectorAssemblerでの文字列変数の使用方法
は、私は、入力ファイルがhereで、しようとしているコードです:
train=sqlContext.read.format('com.databricks.spark.csv').options(header='true').load('filename')
drop_list = ["Country", "Carrier", "TrafficType","Device","Browser","OS","Fraud","ConversionPayOut"]
from pyspark.sql.types import DoubleType
train = train.withColumn("ConversionPayOut", train["ConversionPayOut"].cast("double"))#only this variable is actually double, rest of them are strings
junk = train.select([column for column in train.columns if column in drop_list])
transformed = assembler.transform(junk)
私は基本的な質問をするためのIllegalArgumentException: u'Data type StringType is not supported.'
P.S:謝罪することをerrrorを得続けます。私はRの背景から来た。 Rでは、ランダムフォレストを実行するときに、カテゴリ変数を数値変数に変換する必要はありません。