2016-09-08 4 views
0

저는 Spark을 배우고 CrossValidator를 사용하고 있습니다. 내 코드는 다음과 같습니다Pyspark에서 DF 유형을 Double에서 Int로 변경합니다.

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

아무도 그것을 해결하는 방법을 알고 있나요 :

# 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 

내가 내가이 오류를 컴파일 할 때?

답변

0

해결했습니다. maxDepth 속성은 정수 여야하므로 function addGrig에서 [2, 3]에 [2.0, 3.0]을 건 드리면됩니다.

관련 문제