Options

Printing model summary of python models built using Python Learner .

Rahul_MRahul_M Member Posts: 4 Contributor I
Hi All, I have stored models which were built using Custom Python Learner in RapidMiner ? Is there any way to print the model information using these stored objects (.ioo) alone? I tried passing the Python model object as input to Execute Python and Python Transformer, but it failed to accept the input. 

Best Answer

  • Options
    rjones13rjones13 Member Posts: 180 Unicorn
    Solution Accepted
    Hi @Rahul_M,

    I've attached a small example, showing how you can use Execute Python to print the parameters to the log panel. The only challenge you may face is the exact code required will vary depending on the model type. I'd trained a simple sklearn model which I've also attached.

    Hope this helps,

    Best,

    Roland

    <?xml version="1.0" encoding="UTF-8"?><process version="10.3.001">
    
    <context>
    <input/>
    <output/>
    <macros/>
    </context>
    <operator activated="true" class="process" compatibility="10.3.001" expanded="true" name="Process">
    <parameter key="logverbosity" value="init"/>
    <parameter key="random_seed" value="2001"/>
    <parameter key="send_mail" value="never"/>
    <parameter key="notification_email" value=""/>
    <parameter key="process_duration_for_mail" value="30"/>
    <parameter key="encoding" value="SYSTEM"/>
    <process expanded="true">
    <operator activated="true" class="retrieve" compatibility="10.3.001" expanded="true" height="68" name="Retrieve python-model" width="90" x="45" y="34">
    <parameter key="repository_entry" value="//Local Repository/python-model"/>
    </operator>
    <operator activated="true" class="python_scripting:execute_python" compatibility="10.0.001" expanded="true" height="103" name="Execute Python" width="90" x="179" y="34">
    <parameter key="script" value="import pandas&#10;&#10;def rm_main(model):&#10; print(model.get_params())"/>
    <parameter key="notebook_cell_tag_filter" value=""/>
    <parameter key="use_default_python" value="true"/>
    <parameter key="package_manager" value="conda (anaconda)"/>
    <parameter key="use_macros" value="false"/>
    </operator>
    <connect from_op="Retrieve python-model" from_port="output" to_op="Execute Python" to_port="input 1"/>
    <connect from_op="Execute Python" from_port="output 1" to_port="result 1"/>
    <portSpacing port="source_input 1" spacing="0"/>
    <portSpacing port="sink_result 1" spacing="0"/>
    <portSpacing port="sink_result 2" spacing="0"/>
    </process>
    </operator>
    </process>

Answers

  • Options
    rjones13rjones13 Member Posts: 180 Unicorn
    Hi @Rahul_M,

    Is your goal to score new data with the model you've saved (I'm basing this on your comment on the other thread)? If so, I would recommend looking at the tutorial bundled with Python Learner. It shows how a model can be passed to the Apply Model operator directly for use on new data.

    Best,

    Roland
  • Options
    Rahul_MRahul_M Member Posts: 4 Contributor I
    Hi @rjones13,

    My goal is to examine the parameters of the python model stored as RapidMiner object, assuming I don't have access to the script which generated it, since the particular use case I'm working on requires this. I'm already able to score the model using Apply Model operator directly.

    Is there any RM operator which can extract the stored details of the model object ? Or can I pass the python model object as input to an Execute Python / Python Transformer where I can output the details.

    Thank you for your response!
  • Options
    rjones13rjones13 Member Posts: 180 Unicorn
    Hi @Rahul_M,

    I’ll have a look and see what I can come up with. Could you confirm which operator the Python model was saved with?

    Best,
    Roland
  • Options
    Rahul_MRahul_M Member Posts: 4 Contributor I
    Hi @rjones13, I'm using Python Learner to generate the model & using Store for storing it.

    Regards,
  • Options
    rjones13rjones13 Member Posts: 180 Unicorn
    Hi @Rahul_M,

    I've had a test and if you train the model using Python Learner, it should be stored as a viewable model. This can be seen if you add a Store operator to the tutorial for Python Learner. Would I be correct that you trained the model using something like Execute Python? So then it's saved as a .ioo file?

    Would you be able to provide an example model to build an example for you? I think it should be possible using Execute Python.

    Best,

    Roland
Sign In or Register to comment.