GeneticSearch

29 views
Skip to first unread message

Dario Martinez

unread,
Mar 6, 2024, 11:29:53 PMMar 6
to python-weka-wrapper
Hello everyone, I am trying to implement the GeneticSearch filter, with the following code:
assearch = ASSearch(classname="weka.attributeSelection.GeneticSearch",
                        options=["-Z", "20", "-G", "20", "-C", "0.6", "-M", "0.033", "-R", "20", "- S", "230"])

but I get the following error:
Failed to instantiate weka.attributeSelection.GeneticSearch: weka.attributeSelection.GeneticSearch
Class 'weka.attributeSelection.GeneticSearch' is available from package: attributeSelectionSearchMethods
Also, you need to start up the JVM with package support:
jvm.start(packages=True)

How can I enable the package: attributeSelectionSearchMethods ??

Juan José Expósito González

unread,
Mar 7, 2024, 1:05:31 AMMar 7
to python-weka-wrapper
Hi Darío,

You can use Genetic Search like this:

search = ASSearch( classname="weka.attributeSelection.GeneticSearch", options=ga_options)

where 

ga_options = f"-S {genetic_seed} -C {crossover_probability} -M {mutation_probability} -G {max_generations} -Z {population_size} -R {report_frequency}".split()

And then the evaluator:

eval_options = "-P 1 -E 1".split(" ")
evaluation = ASEvaluation(classname="weka.attributeSelection.CfsSubsetEval", options=eval_options)
attsel = AttributeSelection()
attsel.search(search)
attsel.evaluator(evaluation)
attsel.select_attributes(data)

And to select the attributes, you call the reduce_dimensionality function:

attsel.reduce_dimensionality(data)

Hope this helps.

Juanjo

Dario Martinez

unread,
Mar 7, 2024, 2:40:19 AMMar 7
to python-we...@googlegroups.com
Hola Juan, el eval y el filtro lo tengo montado sin problemas, no me presentan errores, te pongo una imagen del codigo que tengo y del error, ya le pase las opciones al search como propones, y continua el mismo error, lo que creo es que le falta una llamada a un paquete, te pongo al final la imagen de los imports que tengo en la cabecera. 
image.png
image.png

image.png

--
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/eafc1f6c-620d-429c-9796-39b0f80413e2n%40googlegroups.com.

Juanjo

unread,
Mar 7, 2024, 3:41:12 AMMar 7
to python-we...@googlegroups.com
Yo tengo esto importado:

from weka.attribute_selection import ASSearch, ASEvaluation, AttributeSelection

Y arranco la máquina de java así:
jvm.start(system_info=False, logging_level=logging.INFO,  auto_install=True,  packages=True )

Prueba primero la importación, y luego la forma de arrancar la máquina virtual de Java.

Saludos,

Juanjo


You received this message because you are subscribed to a topic in the Google Groups "python-weka-wrapper" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python-weka-wrapper/TKvTk0qfzKE/unsubscribe.
To unsubscribe from this group and all its topics, 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/CAH3SKwxcYkYnpUDcHASxt%2Bx9RgQHDAGSTkcyR7Fy65Lq_AVHnw%40mail.gmail.com.

Dario Martinez

unread,
Mar 7, 2024, 7:26:06 AMMar 7
to python-we...@googlegroups.com
Hola Juan, como pudiste ver en la última imagen del correo pasado tengo importada la misma linea de codigo, por lo cual ese no seria el problema, y en cuanto a  jvm.start que me sugieres ya la ensaye y me pone el error de la imagen a continuación es decir que logging no está definido:
image.png


Libre de virus.www.avast.com

Dario Martinez

unread,
Mar 7, 2024, 7:31:50 AMMar 7
to python-we...@googlegroups.com
Bueno ya encontre el problema, ya no presenta error, arranque la máquina con: jvm.start(system_cp=True, packages=True), antes la arrancaba con jvm.start(), tambien comente otras dos alusiones a los packages ver imagen siguiente, en todo caso ya desaparecio el error y voy a continuar adelante. Saludos
image.png

Libre de virus.www.avast.com

Dario Martinez

unread,
Mar 7, 2024, 7:40:07 AMMar 7
to python-we...@googlegroups.com
Hola de nuevo, tambien cai en cuenta que una advertencia que tenía al arrancar, era por iniciar varias veces la maquina virtual con diferentes parámetros, ya lo reduje a como que aparece en la imagen:
image.png

Libre de virus.www.avast.com

Juanjo

unread,
Mar 7, 2024, 9:08:42 AMMar 7
to python-we...@googlegroups.com
Hola Darío, 

Tienes que importar el módulo logging de Python.

import logging.

Con eso debería de funcionar.

Saludos,

Juanjo

Dario Martinez

unread,
Mar 7, 2024, 11:43:31 AMMar 7
to python-we...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages