Sample code for Model Learner

Hi,

I am trying to develop a new PP component that learns a model (similar to the components in the "Data Modeling - Learners" category).

I noticed that these learner components create a new model component on the user tab under "Learned Properties".

Can anyone point me to sample code on how to do that (preferrably Java) or to the relevant APIs?

Specifically, how can I create a new component on the fly from another component?

Thanks for any pointers.

Christian

Answers 1
DH
DH 2012-10-30

To answer your last question first: the way to create a component from another component is to read in the base or template component using the Component Reader. Then use PilotScript functions within a Custom Manipulator to add or change the component's parameters. Finally, use the Component Writer to save the new component (e.g., to your user tab).

The best examples of this approach in action are the components in the R Statistics/Learners folder. Each of these components is implemented as a subprotocol which you can open up in order to see the implementation details. (The learners under Data Modeling are not as useful because they rely on compiled C++ code to create the new model components.)

To show what I'm talking about, let's use the Learn R Linear Model component as an example. Drag this component into an empty protocol and double-click on it to open it up. Inside, you'll see another shortcut named Learn R Model Internal. Double-click on this to open it. There is a lot going on there, most of which is not directly involved in the new component creation. Scroll down to pipe number 9. The component labeled "Read R Model component" reads the model template component (located in R Statistics/Utilities/Internals). The component labeled "Set parameters for R Model" uses PilotScript to set all of the required model state. Finally, the component labeled "Write new R Model" is a Component Writer, which writes the final model to your user tab (or whichever destination you specified).