我正在学习Spark,我正在使用CrossValidator。我的代码是:
# 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 :(得分:2)
我解决了! maxDepth属性必须是整数,所以在函数addGrig中我们为[2,3]触摸[2.0,3.0]。