How to force Weka to use distributionsForInstances instead of distributionsForInstance

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to force Weka to use distributionsForInstances instead of distributionsForInstance

edkinsgael
Hi
I'm using Weka on java . I want to construct a J48 stack classifier with two
base classifiers : SMO and my own classifier I want to implement myself . I
implemented my classifier by mading it implements Classifier, BatchPredictor
classes . I overrided the function *p/ublic double[][]
distributionsForInstances(Instances insts) throws Exception/*, I set
setBatchSize("1000") .
My problem is that when  launch the training, weka keep calling the
*/function public double[] distributionForInstance(Instance instance) throws
Exception/* instead of the distributionsForInstances(Instances insts) .

Please I need help



--
Sent from: http://weka.8497.n7.nabble.com/
_______________________________________________
Wekalist mailing list
Send posts to: [hidden email]
To subscribe, unsubscribe, etc., visit https://list.waikato.ac.nz/mailman/listinfo/wekalist
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html
Reply | Threaded
Open this post in threaded view
|

Re: How to force Weka to use distributionsForInstances instead of distributionsForInstance

Eibe Frank-2
Administrator
This is a good question. WEKA’s classifier evaluation code will use batch prediction (i.e., distributionsForInstances) if and only if the classifier being evaluated is a BatchPredictor *and* the method implementsMoreEfficientBatchPrediction(), called on this classifier, returns value true.

So, if you want your classifier’s distributionsForInstances() method to be used instead of distributionForInstance(), you will need to include an implementation of implementsMoreEfficientBatchPrediction() in your classifier that returns value true.

However, this will not be sufficient to achieve efficient batch prediction in Stacking in WEKA 3.8.3/3.9.3 or earlier. In those versions of WEKA, Stacking does not check whether the base or meta classifiers implement efficient batch prediction and so cannot make use of efficient batch prediction. In those versions of Weka, the only classifiers in the meta package that check whether their base learners are efficient batch predictors are FilteredClassifier, AttributeSelectedClassifier, ClassificationViaRegression, and CostSensitiveClassifier.

Prompted by your question, I have just checked in a new version of Stacking that makes efficient use of batch prediction. You can grab this version from SVN. It should also be in the next nightly snapshot of WEKA. Because this new version supports efficient batch prediction, it is much faster when using classifiers such as MLRClassifier that are much more efficient when run in batch prediction mode.

Cheers,
Eibe


> On 17/11/2018, at 2:48 AM, edkinsgael <[hidden email]> wrote:
>
> Hi
> I'm using Weka on java . I want to construct a J48 stack classifier with two
> base classifiers : SMO and my own classifier I want to implement myself . I
> implemented my classifier by mading it implements Classifier, BatchPredictor
> classes . I overrided the function *p/ublic double[][]
> distributionsForInstances(Instances insts) throws Exception/*, I set
> setBatchSize("1000") .
> My problem is that when  launch the training, weka keep calling the
> */function public double[] distributionForInstance(Instance instance) throws
> Exception/* instead of the distributionsForInstances(Instances insts) .
>
> Please I need help
>
>
>
> --
> Sent from: http://weka.8497.n7.nabble.com/
> _______________________________________________
> Wekalist mailing list
> Send posts to: [hidden email]
> To subscribe, unsubscribe, etc., visit https://list.waikato.ac.nz/mailman/listinfo/wekalist
> List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html

_______________________________________________
Wekalist mailing list
Send posts to: [hidden email]
To subscribe, unsubscribe, etc., visit https://list.waikato.ac.nz/mailman/listinfo/wekalist
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html
Reply | Threaded
Open this post in threaded view
|

Re: How to force Weka to use distributionsForInstances instead of distributionsForInstance

edkinsgael
Thank you very much sir, the Stack.java class you updated was usefull . It
would be helpfull for others to inetegrate that modification in the next
versions .

Cheers,
Edkins Gael



--
Sent from: http://weka.8497.n7.nabble.com/
_______________________________________________
Wekalist mailing list
Send posts to: [hidden email]
To subscribe, unsubscribe, etc., visit https://list.waikato.ac.nz/mailman/listinfo/wekalist
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html