2016-09-08 89 views
0

我正在學Spark,並且正在使用CrossValidator。我的代碼是:Pyspark更改DF類型從Double到Int

# Let's just reuse our CrossValidator with the new dtPipeline, RegressionEvaluator regEval, and 3 fold cross validation 
crossval.setEstimator(dtPipeline) 

# Let's tune over our dt.maxDepth parameter on the values 2 and 3, create a paramter grid using the ParamGridBuilder 
paramGrid = ParamGridBuilder().addGrid(dt.maxDepth, [2.0, 3.0]).build() 

# Add the grid to the CrossValidator 
crossval.setEstimatorParamMaps(paramGrid) 

# Now let's find and return the best model 
dtModel = crossval.fit(trainingSetDF).bestModel 

當我編譯它,我有這樣的錯誤:

java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.Integer 

是否有人知道如何解決呢?

回答

0

我解決了! maxDepth屬性必須是整數,所以在函數addGrig中,我們已經爲[2,3]觸及[2.0,3.0]。