RapidMiner

RapidMiner

How to set Parameter on a Filter Example Operator

Contributor

How to set Parameter on a Filter Example Operator

Hi,

I'm trying to change the filter parameters of a Filter Example operator , I'm not sure how have to be written

Operator op = process.getOperator("Filter Examples (8)");
op.setParameter("ExampleFilter.PARAMETER_PARAMETER_STRING",??); // Here is where i don't know what to write.


I hope someone could help me, i'll be very greatful
1 REPLY
Contributor

Re: How to set Parameter on a Filter Example Operator

Hello there,

 

Here is how Operator.setParameter(String key, String value) works.

 

The first argument is the key, or the name of the parameter. The type is String, and usually, we refere these keys in the way

ClassName.KEY_NAME

e.g.

ImprovedNeuralNetLearner.PARAMETER_HIDDEN_LAYERS
RandomGenerator.PARAMETER_USE_LOCAL_RANDOM_SEED

In this way, you may code quicker, avoid type mistake, and keep your program stable.

 

The second argument is also a String, for the value of this parameter. This means even for numerics or booleans, you should cast them in to String.

e.g. "true", "0".

 

Here is an example that may help you know how to set and retrieve parameters:

 

 // 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
 opt.setParameter(AttributeSubsetSelector.PARAMETER_FILTER_TYPE, 
	""+(AttributeSubsetSelector.CONDITION_ALL));
		
 // now lets test whether the value is set
 String s = opt.getParameterAsString(AttributeSubsetSelector.PARAMETER_FILTER_TYPE);
 System.out.println(s);

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

 

RapidMiner China - IT Engineer, Extension Developer.