Categories

Versions

Creating an Operator Class

Time to create a new class for your operator. Each normal operator has to extend Operator or a subclass of Operator. There are many subclasses for more specialized operators (e.g., learning operators), but this example uses the simplest case. Frequently used subclasses of Operator are AbstractLearner, AbstractReader and AbstractWriter. If you are interested in more, take a look at the type hierarchy of Operator.

  1. Create a new package for your operator class. It should have the name groupId.operator.
  2. Create a new Java class with a meaningful name. The class has to extend Operator from the Altair RapidMiner core. You have to override the constructor.

That's it. Your operator class should look like this:

../img/operator-class.png

But wait! You want the operator to do something. Therefore, override the method doWork(). The default implementation simply does nothing. In this example, the operator will write logs to the Log panel.

../img/operator-class-do-work.png

package com.rapidminer.extension.operator;

import java.util.logging.Level;
import com.rapidminer.operator.Operator;
import com.rapidminer.operator.OperatorDescription;
import com.rapidminer.operator.OperatorException;
import com.rapidminer.tools.LogService;

/**
 * Describe what your operator does.
 *
 * @author Insert your name here
 *
 */
public class MyOwnOperator extends Operator {

    /**
     * @param description
     */
    public MyOwnOperator(OperatorDescription description) {
        super(description);
    }

    @Override
    public void doWork() throws OperatorException {
        LogService.getRoot().log(Level.INFO, "Doing something...");
    }

}

Once you have implemented an operator, you'll want to test it in Altair RapidMiner. Unfortunately, Altair RapidMiner isn't prophetic. (Actually it could be, but using data mining methods for guessing class usage would be overkill.) Instead, you must specify class use.