"SVM and Bootstrapping"

holdwater587holdwater587 Member Posts: 5 Contributor II
edited May 2019 in Help
Hi, i am a newbie

i have a data of 5 attributes and 200 rows and use epsilon-SVR.
First, i want to get 100 bootstrap sample and then use each sample on my SVM model.
Each SVM model will predict my test data.
And finally i want to plot these 100 predictions on the same graph.

Shortly, it is like i have 100 training data and so 100 different SVM model and i want to test all these on my test data.

Is it possible in rapidminer (can we use loop etc.)

Thx in advance
Tagged:

Answers

  • wesselwessel Member Posts: 537 Maven
    Like this?

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="5.1.008">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="5.1.008" expanded="true" name="Process">
        <process expanded="true" height="377" width="547">
          <operator activated="true" class="retrieve" compatibility="5.1.008" expanded="true" height="60" name="Retrieve" width="90" x="45" y="30">
            <parameter key="repository_entry" value="//Samples/data/Sonar"/>
          </operator>
          <operator activated="true" class="nominal_to_numerical" compatibility="5.1.008" expanded="true" height="94" name="Nominal to Numerical" width="90" x="179" y="30">
            <parameter key="attribute_filter_type" value="single"/>
            <parameter key="attribute" value="class"/>
            <parameter key="include_special_attributes" value="true"/>
          </operator>
          <operator activated="true" class="bootstrapping_validation" compatibility="5.1.008" expanded="true" height="112" name="Validation" width="90" x="313" y="30">
            <process expanded="true" height="409" width="165">
              <operator activated="true" class="support_vector_machine_libsvm" compatibility="5.1.008" expanded="true" height="76" name="SVM" width="90" x="45" y="30">
                <parameter key="svm_type" value="epsilon-SVR"/>
                <list key="class_weights"/>
              </operator>
              <connect from_port="training" to_op="SVM" to_port="training set"/>
              <connect from_op="SVM" 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" height="409" width="300">
              <operator activated="true" class="apply_model" compatibility="5.1.008" expanded="true" height="76" name="Apply Model" width="90" x="45" y="30">
                <list key="application_parameters"/>
              </operator>
              <operator activated="true" class="performance" compatibility="5.1.008" expanded="true" height="76" name="Performance (2)" width="90" x="179" y="30"/>
              <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 (2)" to_port="labelled data"/>
              <connect from_op="Performance (2)" 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>
          <connect from_op="Retrieve" from_port="output" to_op="Nominal to Numerical" to_port="example set input"/>
          <connect from_op="Nominal to Numerical" from_port="example set output" to_op="Validation" to_port="training"/>
          <connect from_op="Validation" from_port="averagable 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>
  • wesselwessel Member Posts: 537 Maven
    Here is a slightly more advanced example.
    This writes out predictions to a file, and retrieves them later to plot.
    Might be a better way to do this.
    If so, please let me know.

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="5.1.008">
     <context>
       <input/>
       <output/>
       <macros/>
     </context>
     <operator activated="true" class="process" compatibility="5.1.008" expanded="true" name="Process">
       <process expanded="true" height="409" width="815">
         <operator activated="true" class="retrieve" compatibility="5.1.008" expanded="true" height="60" name="Retrieve" width="90" x="45" y="30">
           <parameter key="repository_entry" value="//Samples/data/Polynomial"/>
         </operator>
         <operator activated="true" class="bootstrapping_validation" compatibility="5.1.008" expanded="true" height="112" name="Validation" width="90" x="313" y="30">
           <process expanded="true" height="409" width="165">
             <operator activated="true" class="support_vector_machine_libsvm" compatibility="5.1.008" expanded="true" height="76" name="SVM" width="90" x="45" y="30">
               <parameter key="svm_type" value="epsilon-SVR"/>
               <list key="class_weights"/>
             </operator>
             <connect from_port="training" to_op="SVM" to_port="training set"/>
             <connect from_op="SVM" 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" height="409" width="480">
             <operator activated="true" class="apply_model" compatibility="5.1.008" expanded="true" height="76" name="Apply Model" width="90" x="45" y="30">
               <list key="application_parameters"/>
             </operator>
             <operator activated="true" class="select_attributes" compatibility="5.1.008" expanded="true" height="76" name="Select Attributes" width="90" x="45" y="120">
               <parameter key="attribute_filter_type" value="single"/>
               <parameter key="attribute" value="prediction(label)"/>
               <parameter key="include_special_attributes" value="true"/>
             </operator>
             <operator activated="true" class="transpose" compatibility="5.1.008" expanded="true" height="76" name="Transpose" width="90" x="45" y="255"/>
             <operator activated="true" class="performance" compatibility="5.1.008" expanded="true" height="76" name="Performance (2)" width="90" x="313" y="30"/>
             <operator activated="true" class="write_special" compatibility="5.1.008" expanded="true" height="60" name="Write Special Format" width="90" x="179" y="255">
               <parameter key="example_set_file" value="C:\Users\wessel\Desktop\z"/>
               <parameter key="special_format" value="$a"/>
             </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="Select Attributes" to_port="example set input"/>
             <connect from_op="Select Attributes" from_port="example set output" to_op="Transpose" to_port="example set input"/>
             <connect from_op="Select Attributes" from_port="original" to_op="Performance (2)" to_port="labelled data"/>
             <connect from_op="Transpose" from_port="example set output" to_op="Write Special Format" to_port="input"/>
             <connect from_op="Performance (2)" 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="read_csv" compatibility="5.1.008" expanded="true" height="60" name="Read CSV" width="90" x="45" y="255">
           <parameter key="csv_file" value="C:\Users\wessel\Desktop\z"/>
           <parameter key="column_separators" value=" "/>
           <parameter key="first_row_as_names" value="false"/>
           <list key="annotations"/>
           <list key="data_set_meta_data_information"/>
         </operator>
         <operator activated="true" class="transpose" compatibility="5.1.008" expanded="true" height="76" name="Transpose (2)" width="90" x="313" y="255"/>
         <operator activated="true" class="generate_id" compatibility="5.1.008" expanded="true" height="76" name="Generate ID (2)" width="90" x="444" y="255"/>
         <operator activated="true" class="generate_id" compatibility="5.1.008" expanded="true" height="76" name="Generate ID" width="90" x="447" y="165"/>
         <operator activated="true" class="join" compatibility="5.1.008" expanded="true" height="76" name="Join" width="90" x="581" y="210"/>
         <operator activated="true" class="rename_by_replacing" compatibility="5.1.008" expanded="true" height="76" name="Rename by Replacing" width="90" x="715" y="210">
           <parameter key="replace_what" value="att"/>
           <parameter key="replace_by" value="pred"/>
         </operator>
         <connect from_op="Retrieve" from_port="output" to_op="Validation" to_port="training"/>
         <connect from_op="Validation" from_port="training" to_op="Generate ID" to_port="example set input"/>
         <connect from_op="Validation" from_port="averagable 1" to_port="result 1"/>
         <connect from_op="Read CSV" from_port="output" to_op="Transpose (2)" to_port="example set input"/>
         <connect from_op="Transpose (2)" from_port="example set output" to_op="Generate ID (2)" to_port="example set input"/>
         <connect from_op="Generate ID (2)" from_port="example set output" to_op="Join" to_port="right"/>
         <connect from_op="Generate ID" from_port="example set output" to_op="Join" to_port="left"/>
         <connect from_op="Join" from_port="join" to_op="Rename by Replacing" to_port="example set input"/>
         <connect from_op="Rename by Replacing" from_port="example set output" to_port="result 2"/>
         <portSpacing port="source_input 1" spacing="0"/>
         <portSpacing port="sink_result 1" spacing="0"/>
         <portSpacing port="sink_result 2" spacing="216"/>
         <portSpacing port="sink_result 3" spacing="0"/>
       </process>
     </operator>
    </process>
  • wesselwessel Member Posts: 537 Maven
    Here is the resulting plot:
    image
Sign In or Register to comment.