How to set parameter of class NominalToBinominal

mercyforevermercyforever Member Posts: 8 Contributor I
edited November 2018 in Help

I have created a 'NominalToBinominal' operator using n2bOprt = OperatorService.createOperator(NominalToBinominal.class);
I wonder how I can set the attribute filter(all, single, subset, ...) of that operator.


  • Options
    LostSummerLostSummer Member Posts: 2 Contributor I

    Hello, I'm just new here and I think I might know the answer to your question:


    If you check the API, there are many methods provided that can be used to set the parameters:


    setParameters(Parameters parameters);
    setParameter(String key, String value);
    setListParameter(String key, List<String[]> list);
    setPairParameter(String key, String firstValue, String secondValue);


     To understand these methods, you should have an overall understanding on both the parameters in an operator, and the various types of parameter. This means you might need to check the API or the source code under the package: com.rapidminer.parameter, where you can find all the parameter types used in RM core, ( and btw you can build your own by extending the classes ParameterType and CombinedParameterType).


    Moreover, you should know what parameters are used in the operator NominalToBinominal and what their types are.

    You can find the parameters on the GUI, but a better suggestion is to check the method

    public List<ParameterType> getParameterTypes();

    in this class, as well as in all of its super classes and other components (such as AttributeSubsetSlector and RandomGenerator).


    Here is a small example on AttributeSubsetSelector:


    import com.rapidminer.RapidMiner;
    import com.rapidminer.operator.OperatorCreationException;
    import com.rapidminer.operator.preprocessing.filter.NominalToBinominal;
    import com.rapidminer.operator.tools.AttributeSubsetSelector;
    import com.rapidminer.parameter.UndefinedParameterError;
    import com.rapidminer.tools.OperatorService;

    public class Test {

    public static void main(String[] args) throws OperatorCreationException, UndefinedParameterError{


    NominalToBinominal opt = OperatorService.createOperator(NominalToBinominal.class);

    // here we set the parameter using the method setParameter(String key, String value);
    // ""+int is just a quick way to convert single int into a string

    // now lets test whether the value is set
    String s = opt.getParameterAsString(AttributeSubsetSelector.PARAMETER_FILTER_TYPE);

    // change the value

    // check if the out put is changed
    String s1 = opt.getParameterAsString(AttributeSubsetSelector.PARAMETER_FILTER_TYPE);

    // actually you can also get the parameter as an integer or other applicable data type
    int i = opt.getParameterAsInt(AttributeSubsetSelector.PARAMETER_FILTER_TYPE);




Sign In or Register to comment.