Issues importing SMOTE into java code (WEKA v. 3.8.3 SMOTE.jar v. 1.0.3)

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

Issues importing SMOTE into java code (WEKA v. 3.8.3 SMOTE.jar v. 1.0.3)

sh.br.alemi
Hello,

I am currently running into an issue involving the use and importing of
SMOTE in my java code.

- I have used the weka gui package manager to download the latest SMOTE
package.

- I then modified my bash profile to link the CLASSPATH to the SMOTE.jar
file located inside the wekafiles folder in my home directory.

- In my code I've included the import line:
"import weka.filters.supervised.instance.SMOTE;"

- even after a couple hours of trouble shooting I'm stuck trying to figure
out why I keep receiving the following compiler error:
"WekaCsv.java:6: error: cannot find symbol
import weka.filters.supervised.instance.SMOTE;"

I know this may be a more general java package management question- however
I'm very confused on how to deal with the external SMOTE.jar along with the
weka.jar.

NOTE:

the program that I'm trying to use SMOTE with has already successfully used
different weka api filters - so I have been able to properly use
classes/methods that are within the weka.jar file (which has its CLASSPATH
in my bash profile as well)

if anyone has a clue as to what is causing this issue and knows how to help
I would be beyond grateful.

Thank you :)



--
Sent from: https://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: Issues importing SMOTE into java code (WEKA v. 3.8.3 SMOTE.jar v. 1.0.3)

Eibe Frank-2
Administrator
Your approach is a valid one and should work. Apart from SMOTE.jar (and weka.jar), no additional .jar files are needed to run SMOTE. (There are no further .jar files in a lib folder in that package, for example.)

For example, the following command-line, which does not invoke the WEKA package manager to load package .jar files, works for me:

  java -cp $HOME/wekafiles/packages/SMOTE/SMOTE.jar:$HOME/weka-3-8-3/weka.jar weka.filters.supervised.instance.SMOTE -i ~/datasets/UCI/diabetes.arff -c las

Another way to use WEKA packages from your Java code is to load .jar files at runtime using the package manager and then use reflection to create objects and run methods on them. See, for example, here:

  https://weka.8497.n7.nabble.com/how-to-load-a-class-from-an-installed-package-in-java-code-td40937.html

This is more flexible because you do not need to import the package .jar files into your project.

Cheers,
Eibe

> On 29/08/2019, at 10:55 AM, sh.br.alemi <[hidden email]> wrote:
>
> Hello,
>
> I am currently running into an issue involving the use and importing of
> SMOTE in my java code.
>
> - I have used the weka gui package manager to download the latest SMOTE
> package.
>
> - I then modified my bash profile to link the CLASSPATH to the SMOTE.jar
> file located inside the wekafiles folder in my home directory.
>
> - In my code I've included the import line:
> "import weka.filters.supervised.instance.SMOTE;"
>
> - even after a couple hours of trouble shooting I'm stuck trying to figure
> out why I keep receiving the following compiler error:
> "WekaCsv.java:6: error: cannot find symbol
> import weka.filters.supervised.instance.SMOTE;"
>
> I know this may be a more general java package management question- however
> I'm very confused on how to deal with the external SMOTE.jar along with the
> weka.jar.
>
> NOTE:
>
> the program that I'm trying to use SMOTE with has already successfully used
> different weka api filters - so I have been able to properly use
> classes/methods that are within the weka.jar file (which has its CLASSPATH
> in my bash profile as well)
>
> if anyone has a clue as to what is causing this issue and knows how to help
> I would be beyond grateful.
>
> Thank you :)
>
>
>
> --
> Sent from: https://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