Can't access random forest learner methods

Hello everyone,

in my node, I want to apply the KNIME random forest learner algorithm on my data, but when I try to import for example the TreeEnsembleLearnerConfiguration in the package org.knime.base.node.mine.treeensemble2.node.learner, I get an error saying ‘Access restriction: The type ‘TreeEnsembleLearner’ is not API’. Is it not intended by KNIME to access the random forest learner algorithm or am I doing something wrong? Also, when I modify the access rule in the treeensemble2.jar, when loading the node, I receive an error 'loader constraint violation: loader (instance of org/eclipse/osgi/internal/loader/EquinoxClassLoader) previously initiated loading for a different type with name “org/knime/base/node/mine/treeensemble2/node/learner/TreeEnsembleLearnerConfiguration” '. Thank you in advance.

Best wishes,
Morris

Hello @Morris_Kurz,

yes, the package org.knime.base.node.mine.treeensemble2.node.learner is not officially exported.
Your second problem indicates that the plugin exists multiple times, and one tries to load the non-exported classes of the other.
Do you import the jar outside of the target platform?

Best,

Adrian

2 Likes

Hello Adrian,

yes, I import the jar outside of the target platform, as I thought it would be the only way to circumvent the restriction access and it worked on a previous implementation of mine. When I remove the classpath entry and the .jar from my build path, I get the expected ClassNotFoundException. Is there a way to use the methods in org.knime.base.node.mine.treeensemble2.node.learner without importing the .jar?

Best,

Morris

Hi @Morris_Kurz,
you can check-out the treeensembles code yourself from:
https://github.com/knime/knime-core/tree/master/org.knime.base.treeensembles2
You can then export the packages in the runtime config tab of the plugin.xml. This should allow you to continue development for now without you needing to duplicate code.

best,
Gabriel

2 Likes

Hey @gab1one,

thank you, this resolved my problems while I am developing. Can you think of any long term solution though? Because this should make my node undeployable since every standard distribution of the treeensemble methods can’t be accessed by my node, right?
Anyways, thank you guys for all the help, now I can continue to work.

Best,
Morris

Hi @Morris_Kurz,
I am working on getting these packages exported in the next KNIME release :slight_smile:
best,
Gabriel

2 Likes

Hi @Morris_Kurz,
can you please tell me which packages you need exactly ? Not that I change the exported packages but miss something you need.

best,
Gabriel

Hey @gab1one,

first of all, thank you so much for doing this! I am again and again surprised at the helpfulness we receive in this forum.
So far, I accessed classes in following packages: (org.knime.base.node.mine.treeensemble2.) node.predictor, learner, node.learner, sample.row;

Best,
Morris

We are happy to help :blush:, regarding your node development I want to advise you to be careful with depending on implementation details of nodes that you do not control yourself. If at a future date, this code is refactored, your nodes will break. So it might be advisable for you to just copy the classes you need instead of relying on them. The only case where you need to use the classes from the treeensemble plugin are those, where you want to interact with its nodes, for example the port type (the problem you encountered in October).

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.