Using SMOTE filter in Eclipse (Java/Weka API)

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

Using SMOTE filter in Eclipse (Java/Weka API)

lp77
I am attempting to use the SMOTE filter in my java file. I am using Eclipse
and have added weka.jar to the build path. However,
weka.filters.supervised.instance.SMOTE is not in the weka.jar file, so it is
not recognized. I understand there is a separate SMOTE.jar file, which I
have downloaded, but I am unsure of how to include it in Eclipse so that it
recognizes "weka.filter.supervised.instance.SMOTE". I have tried including
both jar files in the classpath, but that is giving me greater issues.



--
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: Using SMOTE filter in Eclipse (Java/Weka API)

Eibe Frank-2
Administrator
If you don’t want to mess with the addition of .jar files to your build path, you can use the WEKA package manager to load all installed packagers into the JVM at runtime. However, this means that you need to use reflection to create objects.

Here is some example code written in the Groovy dialect of Java:

weka.core.WekaPackageManager.loadPackages(false, true, false)
weka.filters.Filter smote = (weka.filters.Filter)Class.forName("weka.filters.supervised.instance.SMOTE").newInstance()
smote.setOptions(weka.core.Utils.splitOptions("-P 2 -K 10 -C last"))
weka.core.Instances data = new weka.core.Instances(new FileReader("/Users/eibe/datasets/UCI/diabetes.arff"))
data.setClassIndex(data.numAttributes() - 1)
smote.setInputFormat(data)
filteredData = weka.filters.Filter.useFilter(data, smote)

Cheers,
Eibe

> On 18/01/2019, at 2:18 PM, lp77 <[hidden email]> wrote:
>
> I am attempting to use the SMOTE filter in my java file. I am using Eclipse
> and have added weka.jar to the build path. However,
> weka.filters.supervised.instance.SMOTE is not in the weka.jar file, so it is
> not recognized. I understand there is a separate SMOTE.jar file, which I
> have downloaded, but I am unsure of how to include it in Eclipse so that it
> recognizes "weka.filter.supervised.instance.SMOTE". I have tried including
> both jar files in the classpath, but that is giving me greater issues.
>
>
>
> --
> 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