Re: Issues accessing class attributes of external package distance function

Martin Trat <[email protected]> Wed, 20 Jul 2022 07:29:05 +0000
Newsgroups gmane.comp.ai.weka
Message-ID <[email protected]>
Dear Peter and Michael,

I followed your conversation and will try to use the augmentation provided in PWW3. I appreciate you considering my questions.

> The way I understand the OP, they only want to have to make their Python code
> available alongside the publication, not also an additional Weka package whose
> only purpose is to make the internal data structure of the DilcaDistance available. 
> That Python code uses python-weka-wrapper3, so Weka will be used under the
> hood. So, yes, Java and Weka packages will be used, just not explicitly.

This is exactly what I am attempting and aiming for.


Thank you Michael for proposing help to add a Weka package, based on DilcaDistance. I will reach out if I find that this is what suits the use case.
Thank you Peter for responding to my question on [GitHub] and augmenting PWW3 accordingly. I think it is great that PWW3 helps facilitate the use of javabridge for scientists focusing on Python for prototyping machine-learning-related solutions.

Best
Martin

[GitHub]: https://github.com/fracpete/python-weka-wrapper3/issues/42


…………………………………………………
Martin Trat, M.Sc.
Wissenschaftlicher Mitarbeiter | Research Associate
Intelligent Systems and Production Engineering (ISPE)

FZI Forschungszentrum Informatik
Haid-und-Neu-Str. 10–14
76131 Karlsruhe, Germany
Tel.: +49 721 9654-509
[email protected]

www.fzi.de/team/martin-trat 
www.fzi.de | www.twitter.com/FZI_official | www.linkedin.com/company/fzi-official | www.youtube.com/FZIchannel
…………………………………………………
FZI Forschungszentrum Informatik
Stiftung des bürgerlichen Rechts
Stiftung Az: 14-0563.1 Regierungspräsidium Karlsruhe
Vorstand: Prof. Dr. Andreas Oberweis, Jan Wiesenberger, Prof. Dr.-Ing. J. Marius Zöllner
Vorsitzender des Kuratoriums: Ministerialdirigent Günther Leßnerkraus
…………………………………………………



-----Ursprüngliche Nachricht-----
Von: Peter Reutemann <[email protected]> 
Gesendet: Mittwoch, 20. Juli 2022 05:38
An: Weka machine learning workbench list. <[email protected]>
Betreff: [Wekalist] Re: Issues accessing class attributes of external package distance function

> >> If the intention isn’t to include this in a Weka java based package I’m still unclear on how it is meant to be provided. Again possibly I don’t understand well enough how the Python works.
> >
> > Not quite sure what you mean. The DilcaDistance class (which is 
> > already available as a Weka package) has a protected field. OP wants 
> > to access this field directly and turn the stored matrices into 
> > numpy arrays with no precision loss which currently happens when 
> > parsing the
> > toString() output of said class.
>
> How it is intended to use the earlier python without somehow adding them to a package is what isn’t clear to me.
> A concern for how the research was going to be made available was indicated by the OP.
> That this is somehow possible in a python way without a package or java involved is what I’m not quite understanding.

The way I understand the OP, they only want to have to make their Python code available alongside the publication, not also an additional Weka package whose only purpose is to make the internal data structure of the DilcaDistance available. That Python code uses python-weka-wrapper3, so Weka will be used under the hood. So, yes, Java and Weka packages will be used, just not explicitly.

> > Accessing non-public members/methods is not a very common use-case, 
> > but sometimes required when you need internally computed/held data 
> > structures for further processing.
> > Over the years, I've had to sub-class plenty of classes to get 
> > access to such data structures. Annoying, but not really a biggie 
> > when you're already programming in Java.
> >
> Yes. As I mentioned I’ve done it before. Not plenty of times but once or twice.
> Really pretty simple and would work well I’d think if a package were provided. Without the need for a cross-language hack.

It's not really a cross-language hack. The "hack" happens purely on the Java side with "X.setAccessible(true);", giving access to a field/method. The Python code simply tells the Java process to execute the hack and then obtain the relevant data (and then convert it into Python data structures). ;-)

> But I tend to a java bias anyhow.

For some things Java is better, for other things Python. Whatever gets the job done, really.

Cheers, Peter
--
Peter Reutemann
Dept. of Computer Science
University of Waikato, NZ
+64 (7) 858-5174 (office)
+64 (7) 577-5304 (home office)
https://www.cs.waikato.ac.nz/~fracpete/
http://www.data-mining.co.nz/
_______________________________________________
Wekalist mailing list -- [email protected] Send posts to [email protected] To unsubscribe send an email to [email protected] To subscribe, unsubscribe, etc., visit https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html

_______________________________________________
Wekalist mailing list -- [email protected]
Send posts to [email protected]
To unsubscribe send an email to [email protected]
To subscribe, unsubscribe, etc., visit https://list.waikato.ac.nz/postorius/lists/wekalist.list.waikato.ac.nz
List etiquette: http://www.cs.waikato.ac.nz/~ml/weka/mailinglist_etiquette.html
smime.p7s (application/pkcs7-signature, 6.2 KB) - not displayed