You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@spark.apache.org by rishikesh <ri...@hotmail.com> on 2015/07/15 09:30:10 UTC

Random Forest Error

Hi

I am trying to train a Random Forest over my dataset. I have a binary
classification problem. When I call the train method as below

model = RandomForest.trainClassifier(data, numClasses=2,
categoricalFeaturesInfo={},numTrees=3, featureSubsetStrategy="auto",
impurity='gini maxDepth=4, maxBins=32)

I get the error

15/07/15 16:24:28 ERROR Executor: Exception in task 1.0 in stage 95.0 (TID
145)
java.lang.IllegalArgumentException: GiniAggregator given label 2.0 but
requires label < numClasses (= 2).

What argument am I missing or not specifying correctly.

Thanks
Rishi



--
View this message in context: http://apache-spark-user-list.1001560.n3.nabble.com/Random-Forest-Error-tp23847.html
Sent from the Apache Spark User List mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@spark.apache.org
For additional commands, e-mail: user-help@spark.apache.org


Re: Random Forest Error

Posted by toufik <ti...@gmail.com>.
please provide code used to change labels thank you



--
Sent from: http://apache-spark-user-list.1001560.n3.nabble.com/

---------------------------------------------------------------------
To unsubscribe e-mail: user-unsubscribe@spark.apache.org


Re: Random Forest Error

Posted by rishikesh <ri...@hotmail.com>.
Thanks, that fixed the problem.

Cheers
Rishi



--
View this message in context: http://apache-spark-user-list.1001560.n3.nabble.com/Random-Forest-Error-tp23847p23850.html
Sent from the Apache Spark User List mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@spark.apache.org
For additional commands, e-mail: user-help@spark.apache.org


Re: Random Forest Error

Posted by Anas Sherwani <an...@gmail.com>.
For RandomForest classifier, labels should be within the range
[0,numClasses-1]. This means, you have to map your labels to 0,1 instead of
1,2.



--
View this message in context: http://apache-spark-user-list.1001560.n3.nabble.com/Random-Forest-Error-tp23847p23848.html
Sent from the Apache Spark User List mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@spark.apache.org
For additional commands, e-mail: user-help@spark.apache.org