The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here

setParameter Problems

aleatorioaleatorio Member Posts: 6 Contributor II
edited November 2018 in Help
Hi, I´m creating a sample operator with balanced data, but when I want to set the parameter PARAMETER_SAMPLE_RATIO_LIST i don´t know how to do it.I want to take all the example that has the label=good  and half of label=bad so the values would be: good-> 1.0 and bad -> 0.5.How should I set this parameter.
My code is:
public ExampleSet randomSampling(ExampleSet ES,String ProcessPath){
       
      try{
                Operator op= OperatorService.createOperator(SamplingOperator.class);
                op.setParameter(SamplingOperator.PARAMETER_SAMPLE, "relative");
                op.setParameter(SamplingOperator.PARAMETER_BALANCE_DATA, "true");
                op.setParameter(SamplingOperator.PARAMETER_SAMPLE_RATIO_LIST, "good, 1.0");
                op.getInputPorts().getPortByIndex(0).receive(ES);
                op.doWork();
                ExampleSet result=null;
                if(op.getOutputPorts().getPortByIndex(0).getAnyDataOrNull() instanceof ExampleSet)
                    result=(ExampleSet) op.getOutputPorts().getPortByIndex(0).getAnyDataOrNull();
                return result;
            }catch(OperatorCreationException | OperatorException e){
                System.out.println(e);
                return null;
            }
           
       
    }
Tagged:

Answers

  • Marco_BoeckMarco_Boeck Administrator, Moderator, Employee-RapidMiner, Member, University Professor Posts: 1,996 RM Engineering
    Hi,

    you can use a List<String> as the parameter vaue.

    Regards,
    Marco
  • aleatorioaleatorio Member Posts: 6 Contributor II
    Thanks a lot  ;D.
    I didn´t realice about that, i was able to make it work with your help.
Sign In or Register to comment.