Random Forest Error

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Random Forest Error

rishikesh
This post has NOT been accepted by the mailing list yet.
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
Reply | Threaded
Open this post in threaded view
|

Re: Random Forest Error

Anas Sherwani
This post has NOT been accepted by the mailing list yet.
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.
Reply | Threaded
Open this post in threaded view
|

Re: Random Forest Error

rishikesh
This post has NOT been accepted by the mailing list yet.
Thanks, that fixed the problem.

Cheers
Rishi
Reply | Threaded
Open this post in threaded view
|

Re: Random Forest Error

toufik
please provide code used to change labels thank you



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

---------------------------------------------------------------------
To unsubscribe e-mail: [hidden email]