How to apply batch model to non batched data

hans94miguelhans94miguel Member Posts: 1 Contributor I
edited November 2018 in Help
hi!
i have created a model using batched validation, is there a way to apply this model to non-batched data?

Here is the sample process I created

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<process version="7.0.001">
  <context>
    <input/>
    <output/>
    <macros/>
  </context>
  <operator activated="true" class="process" compatibility="7.0.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="7.0.001" expanded="true" height="68" name="Retrieve distmodel3" width="90" x="45" y="136">
        <parameter key="repository_entry" value="../data/distmodel3"/>
      </operator>
      <operator activated="true" class="set_role" compatibility="7.0.001" expanded="true" height="82" name="Set Role" width="90" x="246" y="187">
        <parameter key="attribute_name" value="batchid"/>
        <parameter key="target_role" value="batch"/>
        <list key="set_additional_roles">
          <parameter key="Letter" value="label"/>
          <parameter key="Frame" value="batch"/>
          <parameter key="Feat1" value="regular"/>
          <parameter key="Feat2" value="regular"/>
          <parameter key="Feat3" value="regular"/>
          <parameter key="Feat4" value="regular"/>
          <parameter key="Feat5" value="regular"/>
          <parameter key="Feat6" value="regular"/>
          <parameter key="Feat7" value="regular"/>
          <parameter key="Feat8" value="regular"/>
          <parameter key="Gender" value="regular"/>
        </list>
      </operator>
      <operator activated="true" class="batch_x_validation" compatibility="7.0.001" expanded="true" height="124" name="Validation" width="90" x="380" y="85">
        <parameter key="create_complete_model" value="false"/>
        <parameter key="average_performances_only" value="true"/>
        <process expanded="true">
          <operator activated="false" class="weka:W-J48" compatibility="7.0.000" expanded="true" height="82" name="W-J48" width="90" x="112" y="34">
            <parameter key="U" value="true"/>
            <parameter key="C" value="0.25"/>
            <parameter key="M" value="2.0"/>
            <parameter key="R" value="false"/>
            <parameter key="B" value="true"/>
            <parameter key="S" value="false"/>
            <parameter key="L" value="false"/>
            <parameter key="A" value="false"/>
          </operator>
          <operator activated="true" class="k_nn" compatibility="7.0.001" expanded="true" height="82" name="k-NN" width="90" x="112" y="187">
            <parameter key="k" value="3"/>
            <parameter key="weighted_vote" value="false"/>
            <parameter key="measure_types" value="MixedMeasures"/>
            <parameter key="mixed_measure" value="MixedEuclideanDistance"/>
            <parameter key="nominal_measure" value="NominalDistance"/>
            <parameter key="numerical_measure" value="EuclideanDistance"/>
            <parameter key="divergence" value="GeneralizedIDivergence"/>
            <parameter key="kernel_type" value="radial"/>
            <parameter key="kernel_gamma" value="1.0"/>
            <parameter key="kernel_sigma1" value="1.0"/>
            <parameter key="kernel_sigma2" value="0.0"/>
            <parameter key="kernel_sigma3" value="2.0"/>
            <parameter key="kernel_degree" value="3.0"/>
            <parameter key="kernel_shift" value="1.0"/>
            <parameter key="kernel_a" value="1.0"/>
            <parameter key="kernel_b" value="0.0"/>
          </operator>
          <connect from_port="training" to_op="k-NN" to_port="training set"/>
          <connect from_op="k-NN" from_port="model" to_port="model"/>
          <portSpacing port="source_training" spacing="0"/>
          <portSpacing port="sink_model" spacing="0"/>
          <portSpacing port="sink_through 1" spacing="0"/>
        </process>
        <process expanded="true">
          <operator activated="true" class="apply_model" compatibility="7.0.001" expanded="true" height="82" name="Apply Model" width="90" x="45" y="34">
            <list key="application_parameters"/>
            <parameter key="create_view" value="false"/>
          </operator>
          <operator activated="true" class="performance_classification" compatibility="7.0.001" expanded="true" height="82" name="Performance" width="90" x="179" y="34">
            <parameter key="main_criterion" value="first"/>
            <parameter key="accuracy" value="true"/>
            <parameter key="classification_error" value="true"/>
            <parameter key="kappa" value="true"/>
            <parameter key="weighted_mean_recall" value="false"/>
            <parameter key="weighted_mean_precision" value="false"/>
            <parameter key="spearman_rho" value="false"/>
            <parameter key="kendall_tau" value="false"/>
            <parameter key="absolute_error" value="false"/>
            <parameter key="relative_error" value="false"/>
            <parameter key="relative_error_lenient" value="false"/>
            <parameter key="relative_error_strict" value="false"/>
            <parameter key="normalized_absolute_error" value="false"/>
            <parameter key="root_mean_squared_error" value="false"/>
            <parameter key="root_relative_squared_error" value="false"/>
            <parameter key="squared_error" value="false"/>
            <parameter key="correlation" value="false"/>
            <parameter key="squared_correlation" value="false"/>
            <parameter key="cross-entropy" value="false"/>
            <parameter key="margin" value="false"/>
            <parameter key="soft_margin_loss" value="false"/>
            <parameter key="logistic_loss" value="false"/>
            <parameter key="skip_undefined_labels" value="true"/>
            <parameter key="use_example_weights" value="true"/>
            <list key="class_weights"/>
          </operator>
          <connect from_port="model" to_op="Apply Model" to_port="model"/>
          <connect from_port="test set" to_op="Apply Model" to_port="unlabelled data"/>
          <connect from_op="Apply Model" from_port="labelled data" to_op="Performance" to_port="labelled data"/>
          <connect from_op="Performance" from_port="performance" to_port="averagable 1"/>
          <portSpacing port="source_model" spacing="0"/>
          <portSpacing port="source_test set" spacing="0"/>
          <portSpacing port="source_through 1" spacing="0"/>
          <portSpacing port="sink_averagable 1" spacing="0"/>
          <portSpacing port="sink_averagable 2" spacing="0"/>
        </process>
      </operator>
      <operator activated="true" class="legacy:write_model" compatibility="7.0.001" expanded="true" height="68" name="Write Model" width="90" x="514" y="187">
        <parameter key="model_file" value="C:\Users\Hans\Documents\ModelFile.mod"/>
        <parameter key="overwrite_existing_file" value="true"/>
        <parameter key="output_type" value="XML Zipped"/>
      </operator>
      <connect from_op="Retrieve distmodel3" from_port="output" to_op="Set Role" to_port="example set input"/>
      <connect from_op="Set Role" from_port="example set output" to_op="Validation" to_port="training"/>
      <connect from_op="Validation" from_port="model" to_op="Write Model" to_port="input"/>
      <connect from_op="Validation" from_port="training" to_port="result 1"/>
      <connect from_op="Validation" from_port="averagable 1" to_port="result 2"/>
      <portSpacing port="source_input 1" spacing="0"/>
      <portSpacing port="sink_result 1" spacing="0"/>
      <portSpacing port="sink_result 2" spacing="0"/>
      <portSpacing port="sink_result 3" spacing="0"/>
    </process>
  </operator>
</process>

Answers

  • earmijoearmijo Member Posts: 270 Unicorn
    The model that comes out of an operator of X-val uses the entire dataset. It's irrelevant if you used batch x-val or regular x-val. Store the model or write it to a file. Then you can apply it to a dataset with the same structure.
Sign In or Register to comment.