You are viewing the RapidMiner Developers documentation for version 2024.0 - Check here for latest version
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.
- Create a new package for your operator class. It should have the name
groupId.operator
. - 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:
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.
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.