You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@spark.apache.org by ansari <hi...@gmail.com> on 2016/10/21 00:12:20 UTC

[Spark ML] Using GBTClassifier in OneVsRest

It appears as if the inheritance hierarchy doesn't allow GBTClassifiers to be
used as the binary classifier in a OneVsRest trainer. Is there a simple way
to use gradient-boosted trees for multiclass (not binary) problems?

Specifically, it complains that GBTClassifier doesn't inherit from
Classifier[_, _, _].

I'm using Spark 2.0.1:

val gbt = new GBTClassifier()
  .setLabelCol("indexedLabel")
  .setFeaturesCol("features")
  .setMaxIter(10)
  .setMaxDepth(10)
 
val ovr = new OneVsRest().
    setClassifier(gbt)

fails saying

error: type mismatch;
 found   : org.apache.spark.ml.classification.GBTClassifier
 required: org.apache.spark.ml.classification.Classifier[_, _, _]
           setClassifier(gbt)



--
View this message in context: http://apache-spark-user-list.1001560.n3.nabble.com/Spark-ML-Using-GBTClassifier-in-OneVsRest-tp27933.html
Sent from the Apache Spark User List mailing list archive at Nabble.com.

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


Re: [Spark ML] Using GBTClassifier in OneVsRest

Posted by eliasah <ab...@gmail.com>.
Well as for now, the GBTClassifier is considered as a Predictor and not a
Classifier. That's why you get that error. Unless you'd want to re-write
your own GBTClassifier that extends Classifier there is no solution for now
to use the OneVsAll Estimator on it.

Nevertheless, there is a associated JIRA
https://issues.apache.org/jira/browse/SPARK-16739 to the topic. You can
follow the issue there.



--
View this message in context: http://apache-spark-user-list.1001560.n3.nabble.com/Spark-ML-Using-GBTClassifier-in-OneVsRest-tp27933p27961.html
Sent from the Apache Spark User List mailing list archive at Nabble.com.

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


Re: [Spark ML] Using GBTClassifier in OneVsRest

Posted by Guo-Xun Yuan <ea...@gmail.com>.
Same questions here.

GBTClassifier and MultilayerPerceptronClassifier extend Predictor[_,_]
rather than Classifier[_,_]. However, both are classifiers. It looks like
the class inheritance hierarchy is not strictly followed.

I wonder if the community considers it an issue, and has a plan for the fix?

Thanks!
Guo-Xun







On Thu, Oct 20, 2016 at 11:54 PM, Nick Pentreath <ni...@gmail.com>
wrote:

> Currently no - GBT implements the predictors, not the classifier
> interface. It might be possible to wrap it in a wrapper that extends the
> Classifier trait.
>
> Hopefully GBT will support multi-class at some point. But you can use
> RandomForest which does support multi-class.
>
> On Fri, 21 Oct 2016 at 02:12 ansari <hi...@gmail.com> wrote:
>
>> It appears as if the inheritance hierarchy doesn't allow GBTClassifiers
>> to be
>> used as the binary classifier in a OneVsRest trainer. Is there a simple
>> way
>> to use gradient-boosted trees for multiclass (not binary) problems?
>>
>> Specifically, it complains that GBTClassifier doesn't inherit from
>> Classifier[_, _, _].
>>
>> I'm using Spark 2.0.1:
>>
>> val gbt = new GBTClassifier()
>>   .setLabelCol("indexedLabel")
>>   .setFeaturesCol("features")
>>   .setMaxIter(10)
>>   .setMaxDepth(10)
>>
>> val ovr = new OneVsRest().
>>     setClassifier(gbt)
>>
>> fails saying
>>
>> error: type mismatch;
>>  found   : org.apache.spark.ml.classification.GBTClassifier
>>  required: org.apache.spark.ml.classification.Classifier[_, _, _]
>>            setClassifier(gbt)
>>
>>
>>
>> --
>> View this message in context: http://apache-spark-user-list.
>> 1001560.n3.nabble.com/Spark-ML-Using-GBTClassifier-in-
>> OneVsRest-tp27933.html
>> Sent from the Apache Spark User List mailing list archive at Nabble.com.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe e-mail: user-unsubscribe@spark.apache.org
>>
>>

Re: [Spark ML] Using GBTClassifier in OneVsRest

Posted by Nick Pentreath <ni...@gmail.com>.
Currently no - GBT implements the predictors, not the classifier interface.
It might be possible to wrap it in a wrapper that extends the Classifier
trait.

Hopefully GBT will support multi-class at some point. But you can use
RandomForest which does support multi-class.

On Fri, 21 Oct 2016 at 02:12 ansari <hi...@gmail.com> wrote:

> It appears as if the inheritance hierarchy doesn't allow GBTClassifiers to
> be
> used as the binary classifier in a OneVsRest trainer. Is there a simple way
> to use gradient-boosted trees for multiclass (not binary) problems?
>
> Specifically, it complains that GBTClassifier doesn't inherit from
> Classifier[_, _, _].
>
> I'm using Spark 2.0.1:
>
> val gbt = new GBTClassifier()
>   .setLabelCol("indexedLabel")
>   .setFeaturesCol("features")
>   .setMaxIter(10)
>   .setMaxDepth(10)
>
> val ovr = new OneVsRest().
>     setClassifier(gbt)
>
> fails saying
>
> error: type mismatch;
>  found   : org.apache.spark.ml.classification.GBTClassifier
>  required: org.apache.spark.ml.classification.Classifier[_, _, _]
>            setClassifier(gbt)
>
>
>
> --
> View this message in context:
> http://apache-spark-user-list.1001560.n3.nabble.com/Spark-ML-Using-GBTClassifier-in-OneVsRest-tp27933.html
> Sent from the Apache Spark User List mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe e-mail: user-unsubscribe@spark.apache.org
>
>