How to use Binary2MultiClassLearner

chenUser4321chenUser4321 Member Posts: 11 Contributor II
edited November 2018 in Help
Hi:

I want to wrote code to do multi-label classification. However, many of the existig RM classifiers only support binominal label. Binary2MultiClassLearner seems to be reasonable choice that makes these classifiers do multi-label classification.

However, I could not figure out a clear way to write the codes from rapidminer-4.6-tutorial.pdf and the javadoc. I also did some search in RM discussion forum, but found results are not directly related to development.

Could I have some specific instructions of using this learner? A sample java code that shows its usage is greatly appreciated!

I also posted this topic in the development forum. If it is not proper to post here, I will remove it.

Kindly regards,
Daozheng

Answers

  • awchisholmawchisholm RapidMiner Certified Expert, Member Posts: 458 Unicorn
    Hello Daozheng,

    I've used the operator "Polynomial by Binomial Classification" to do this sort of thing. Here's an example showing an SVM working on a three class problem.

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="5.0">
      <context>
        <input/>
        <output/>
        <macros/>
      </context>
      <operator activated="true" class="process" compatibility="5.0.10" expanded="true" name="Process">
        <process expanded="true" height="431" width="748">
          <operator activated="true" class="generate_data" compatibility="5.0.10" expanded="true" height="60" name="Generate Data" width="90" x="45" y="30">
            <parameter key="target_function" value="sum"/>
          </operator>
          <operator activated="true" class="discretize_by_user_specification" compatibility="5.0.10" expanded="true" height="94" name="Discretize" width="90" x="179" y="120">
            <parameter key="attribute_filter_type" value="single"/>
            <parameter key="attribute" value="label"/>
            <parameter key="include_special_attributes" value="true"/>
            <list key="classes">
              <parameter key="first" value="-10.0"/>
              <parameter key="second" value="0.0"/>
              <parameter key="third" value="10.0"/>
            </list>
          </operator>
          <operator activated="true" class="polynomial_by_binomial_classification" compatibility="5.0.10" expanded="true" height="76" name="Polynomial by Binomial Classification" width="90" x="313" y="210">
            <process expanded="true" height="682" width="783">
              <operator activated="true" class="x_validation" compatibility="5.0.0" expanded="true" height="112" name="Validation" width="90" x="112" y="30">
                <description>A cross-validation evaluating a decision tree model.</description>
                <parameter key="leave_one_out" value="true"/>
                <process expanded="true" height="654" width="466">
                  <operator activated="true" class="support_vector_machine_libsvm" compatibility="5.0.10" expanded="true" height="76" name="SVM" width="90" x="188" y="30">
                    <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="654" width="466">
                  <operator activated="true" class="apply_model" compatibility="5.0.0" 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.0.0" expanded="true" height="76" name="Performance" 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" 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>
              <connect from_port="training set" to_op="Validation" to_port="training"/>
              <connect from_op="Validation" from_port="model" to_port="model"/>
              <portSpacing port="source_training set" spacing="0"/>
              <portSpacing port="sink_model" spacing="0"/>
            </process>
          </operator>
          <operator activated="true" class="apply_model" compatibility="5.0.10" expanded="true" height="76" name="Apply Model (2)" width="90" x="447" y="300">
            <list key="application_parameters"/>
          </operator>
          <operator activated="true" class="performance" compatibility="5.0.10" expanded="true" height="76" name="Performance (2)" width="90" x="514" y="30"/>
          <connect from_op="Generate Data" from_port="output" to_op="Discretize" to_port="example set input"/>
          <connect from_op="Discretize" from_port="example set output" to_op="Polynomial by Binomial Classification" to_port="training set"/>
          <connect from_op="Polynomial by Binomial Classification" from_port="model" to_op="Apply Model (2)" to_port="model"/>
          <connect from_op="Polynomial by Binomial Classification" from_port="example set" to_op="Apply Model (2)" to_port="unlabelled data"/>
          <connect from_op="Apply Model (2)" from_port="labelled data" to_op="Performance (2)" to_port="labelled data"/>
          <connect from_op="Apply Model (2)" from_port="model" to_port="result 3"/>
          <connect from_op="Performance (2)" from_port="performance" to_port="result 1"/>
          <connect from_op="Performance (2)" from_port="example set" 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"/>
          <portSpacing port="sink_result 4" spacing="0"/>
        </process>
      </operator>
    </process>
    I'm no expert on Java code  but maybe this will give you a place to start.

    regards

    Andrew
  • chenUser4321chenUser4321 Member Posts: 11 Contributor II
    Thank you very much and sorry for the late reply! I will to understand this example and see how write the java code.

    Daozheng
  • SeyhanSeyhan Member Posts: 6 Contributor II
    Hi,

    I try to run multiclass classification(10 classes in the target attribute) with 10 fold X-val of below example, but it did not work.

    Am I missing anything? It used to be Binary2MultiClassLearner in previous community versions but not with the version 5.

    Regards,

    Seyhan
Sign In or Register to comment.