@Override public void setParameter(String name, Object object) throws OperatorException { if (name.equals("proportion_threshold")) { String value = (String) object; try { this.setVarianceThreshold(Double.parseDouble(value)); } catch (NumberFormatException error) { super.setParameter(name, value); } } else if (name.equals("number_of_components")) { String value = (String) object; try { this.setNumberOfComponents(Integer.parseInt(value)); } catch (NumberFormatException error) { super.setParameter(name, value); } } else if (name.equals("keep_attributes")) { String value = (String) object; keepAttributes = false; if (value.equals("true")) { keepAttributes = true; } } else { super.setParameter(name, object); } }
/** * Helper wrapper for {@link #exampleSetInput that can be called by other operators to apply * this operator when it is created anonymously. */ public ExampleSet doWork(ExampleSet exampleSet) throws OperatorException { ExampleSet workingSet = (isSupportingAttributeRoles()) ? getSelectedAttributes(exampleSet) : new NonSpecialAttributesExampleSet(getSelectedAttributes(exampleSet)); AbstractModel model = createPreprocessingModel(workingSet); model.setParameter(PARAMETER_CREATE_VIEW, getParameterAsBoolean(PARAMETER_CREATE_VIEW)); model.setOperator(this); return model.apply(exampleSet); }
@Override public final ExampleSet apply(ExampleSet exampleSet) throws OperatorException { ExampleSet workingSet = (isSupportingAttributeRoles()) ? getSelectedAttributes(exampleSet) : new NonSpecialAttributesExampleSet(getSelectedAttributes(exampleSet)); AbstractModel model = createPreprocessingModel(workingSet); model.setParameter(PARAMETER_CREATE_VIEW, getParameterAsBoolean(PARAMETER_CREATE_VIEW)); if (getExampleSetOutputPort().isConnected()) { model.setOperator(this); exampleSet = model.apply(exampleSet); model.setOperator(null); } modelOutput.deliver(model); return exampleSet; }