15
我正在以CSV格式讀取Spark DataFrame並對其執行機器學習操作。我不斷得到一個Python序列化EOFError - 任何想法爲什麼?我認爲這可能是一個內存問題 - 即文件超出了可用內存 - 但是大幅減小DataFrame的大小並不能防止EOF錯誤。PySpark序列化EOFError
玩具代碼和錯誤如下。
#set spark context
conf = SparkConf().setMaster("local").setAppName("MyApp")
sc = SparkContext(conf = conf)
sqlContext = SQLContext(sc)
#read in 500mb csv as DataFrame
df = sqlContext.read.format('com.databricks.spark.csv').options(header='true',
inferschema='true').load('myfile.csv')
#get dataframe into machine learning format
r_formula = RFormula(formula = "outcome ~ .")
mldf = r_formula.fit(df).transform(df)
#fit random forest model
rf = RandomForestClassifier(numTrees = 3, maxDepth = 2)
model = rf.fit(mldf)
result = model.transform(mldf).head()
在單個節點上運行與上面的代碼反覆引發以下錯誤,即使數據幀的尺寸被擬合模型之前減小(例如tinydf = df.sample(False, 0.00001)
:
Traceback (most recent call last):
File "/home/hduser/spark1.6/python/lib/pyspark.zip/pyspark/daemon.py", line 157,
in manager
File "/home/hduser/spark1.6/python/lib/pyspark.zip/pyspark/daemon.py", line 61,
in worker
File "/home/hduser/spark1.6/python/lib/pyspark.zip/pyspark/worker.py", line 136,
in main if read_int(infile) == SpecialLengths.END_OF_STREAM:
File "/home/hduser/spark1.6/python/lib/pyspark.zip/pyspark/serializers.py", line 545,
in read_int
raise EOFError
EOFError
你可以給Spark 2.1.0(剛發佈)一個機會嗎? –
你也可以用'df'創建另一個DataFrame(手動)並重新開始嗎? –
你可以把csv文件,你試圖讀取一些服務?所以我們可以看看。 –