A program to recognize and reward our most engaged community members
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_LAYERSRandomGenerator.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);