Converting Weka Explorer options

23 views
Skip to first unread message

Peter Reutemann

unread,
Feb 22, 2024, 10:54:12 PMFeb 22
to python-weka-wrapper

Hello Peter, could you please tell me what the format would be to enter through options=[....], the options of the JRip algorithm that is seen in the image, I think it would be options=["100", "True","False","False","3","2.0","2","2","135","True"]

image.png


The above are the properties as used by the GenericObjectEditor (GOE), which you can't use with pww3. But you can use the GOE to configure a classifier and the transfer the options quite easily:
- configure the classifier
- select OK to accept the options
- right-click on the panel displaying classifier name and options
- select "Copy configuration to clipboard"
Using the "from_commandline" method from the weka.core.classes module, you can convert that command-line into a classifier object:

import weka.core.jvm as jvm
from weka.core.classes import from_commandline
jvm.start()
cmdline = 'weka.classifiers.rules.JRip -F 3 -N 2.0 -O 2 -S 135'
classifier = from_commandline(cmdline, classname="weka.classifiers.Classifier")
print(classifier)
print(classifier.to_commandline())
jvm.stop()
 
Cheers, Peter
--
Peter Reutemann
Dept. of Computer Science
University of Waikato, Hamilton, NZ
https://www.cs.waikato.ac.nz/~fracpete/
http://www.data-mining.co.nz/

Dario Martinez

unread,
Feb 23, 2024, 6:11:21 AMFeb 23
to python-we...@googlegroups.com
Hello Peter, I have two doubts, the first is that you cannot use the options[...] command in the Jrip classifier, like the other classifiers?, and the second, in the example you gave me, I could construct a string to load it to "cmdline =", this in order to change the seed dynamically?

--
You received this message because you are subscribed to the Google Groups "python-weka-wrapper" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-weka-wra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python-weka-wrapper/CAHoQ12LiaNAKhNJdMeEn4hy_Dg_gT6_si99p_jhRSv3KcWD__Q%40mail.gmail.com.

Peter Reutemann

unread,
Feb 23, 2024, 10:00:21 PMFeb 23
to python-we...@googlegroups.com
> Hello Peter, I have two doubts, the first is that you cannot use the options[...] command in the Jrip classifier, like the other classifiers?,

No, you can use "options=[...]", just like with any classifier. I was
merely pointing a simple way of converting a setup from the Weka
Explorer into a pww3 classifier object. Since you posted the GOE
screenshot.

cls = Classifier(classname="weka.classifiers.rules.JRip",
options=["-F", "3", "-N", "2.0", "-O", "2", "-S", "135"])

Or, if you already have a JRip classifier object:
cls.options = ["-F", "3", "-N", "2.0", "-O", "2", "-S", "135"]

> and the second, in the example you gave me, I could construct a string to load it to "cmdline =", this in order to change the seed dynamically?

seed = 135
cmdline = 'weka.classifiers.rules.JRip -F 3 -N 2.0 -O 2 -S %d' % seed
Reply all
Reply to author
Forward
0 new messages