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

NominalTo Numeric

JorgeJorge Member Posts: 19 Maven
edited November 2018 in Help
Hi,

I'm trying to do in Java the same that I do in the interface.
But...I don't know how to create and apply the NominalToNumeric preprocessing.

I've a exampleSet and I want to convert it in another exampleSet modified.

Can anyone help me?

Thanks in advance,
Jorge

Answers

  • landland RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 2,531 Unicorn
    Hi Jorge,
    • use the static method Operator operator = OperatorService.createOperator(..)
    • set the parameters using operator.setParameter(..)
    • create an IOContainer with the exampleSet
    • use the apply method to apply the operator onto the IOContainer
    Greetings,
      Sebastian
  • JorgeJorge Member Posts: 19 Maven
    Hi Sebastian,

    but the problem is that...

    When I execute this line of my code...

    Operator n2n = OperatorService.createOperator(NominalToNumeric.class);

    The result is that...

    Exception in thread "main" java.lang.NullPointerException
    at com.rapidminer.operator.OperatorCreationException.createMessage(OperatorCreationException.java:69)
    at com.rapidminer.operator.OperatorCreationException.<init>(OperatorCreationException.java:53)
    at com.rapidminer.tools.OperatorService.createOperator(OperatorService.java:567)
    at ProcessCreator.main(ProcessCreator.java:45)

    Where's the problem?

    Greetings,
    Jorge
  • landland RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 2,531 Unicorn
    Hi,
    did you call RapidMiner.init(..) before?

    Greetings,
      Sebastian
  • JorgeJorge Member Posts: 19 Maven
    Yes,

    All works ok except that step


    That's my code:

    RapidMiner.init();

    Process process = new Process();

    try {
    Operator inputOperator = OperatorService.createOperator(ArffExampleSource.class);
    inputOperator.setParameter("data_file","C:\\provincias.arff");
    process.getRootOperator().addOperator(inputOperator);
    IOContainer container;
    try {
    container = inputOperator.apply(new IOContainer());
    ExampleSet exampleSet = container.get(ExampleSet.class);


    System.out.println("///////////////////////////////////////");
    System.out.println("NOW TO NUMERIC");
    System.out.println("///////////////////////////////////////");

    Operator n2n = OperatorService.createOperator(NominalToNumeric.class);

    ...
    ...
    ...(THE REST OF THE CODE)

    Greetings,
    Jorge
  • landland RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 2,531 Unicorn
    Hi,
    could you please post the log message of the rapid miner initialization?

    Greetings,
      Sebastian
  • JorgeJorge Member Posts: 19 Maven
    Hi,
    Here you have it...

    G Dec 16, 2008 2:11:13 PM: rapidminer.home is 'C:\eclipse_gan\Workspace\yale'.
    G Dec 16, 2008 2:11:13 PM: ----------------------------------------------------
    G Dec 16, 2008 2:11:13 PM: Initialization Settings
    G Dec 16, 2008 2:11:13 PM: ----------------------------------------------------
    G Dec 16, 2008 2:11:13 PM: Default system encoding for IO: windows-1252
    G Dec 16, 2008 2:11:13 PM: Load core operators...
    G Dec 16, 2008 2:11:13 PM: Load Weka operators: true
    G Dec 16, 2008 2:11:13 PM: Load JDBC drivers from lib directory: true
    G Dec 16, 2008 2:11:13 PM: Load JDBC drivers from classpath: false
    G Dec 16, 2008 2:11:13 PM: Load plugins: true
    G Dec 16, 2008 2:11:13 PM: Load plugins from 'C:\eclipse_gan\Workspace\yale\lib\plugins'
    G Dec 16, 2008 2:11:13 PM: ----------------------------------------------------
    G Dec 16, 2008 2:11:13 PM: Read rcfile 'C:\eclipse_gan\Workspace\yale\etc\rapidminerrc'.
    G Dec 16, 2008 2:11:13 PM: Trying rcfile 'C:\eclipse_gan\Workspace\yale\etc\rapidminerrc.Windows XP'...skipped
    G Dec 16, 2008 2:11:13 PM: Trying rcfile 'C:\Documents and Settings\jorge.palacio\.rapidminer\4_3_0_rapidminerrc'...skipped
    G Dec 16, 2008 2:11:13 PM: Read rcfile 'C:\Documents and Settings\jorge.palacio\.rapidminer\4_3_0_rapidminerrc.Windows XP'.
    G Dec 16, 2008 2:11:13 PM: Trying rcfile 'C:\eclipse_gan\Workspace\Reputacion\rapidminerrc'...skipped
    G Dec 16, 2008 2:11:13 PM: Trying rcfile 'C:\eclipse_gan\Workspace\Reputacion\rapidminerrc.Windows XP'...skipped
    G Dec 16, 2008 2:11:13 PM: Trying rapidminer.rcfile. Property not specified...skipped
    G Dec 16, 2008 2:11:13 PM: Loading operators from 'operators.xml'.
    G Dec 16, 2008 2:11:19 PM: Loading JDBC driver information from 'etc:jdbc_properties.xml'.
    ///////////////////////////////////////
    NOW TO NUMERIC
    ///////////////////////////////////////
    Exception in thread "main" java.lang.NullPointerException
    at com.rapidminer.operator.OperatorCreationException.createMessage(OperatorCreationException.java:69)
    at com.rapidminer.operator.OperatorCreationException.<init>(OperatorCreationException.java:53)
    at com.rapidminer.tools.OperatorService.createOperator(OperatorService.java:567)
    at ProcessCreator.main(ProcessCreator.java:53)
    Greetings,
    Jorge
  • landland RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 2,531 Unicorn
    Hi Jorge,
    thank you for this detailed informations. It now was easy to track down the bug occuring only while trying to construct renamed operators. Because of the renaming there is more than one descriptions available. We will remove the bug, but this will last more than a minute.
    So I will give you a hint, how to prevent this.
    In the ressources directory is a file named operators.xml. Delete the following token:
      <operator 
        name        = "Nominal2Numeric"   
        class      = "com.rapidminer.operator.preprocessing.filter.NominalToNumeric"
        description = "Maps all values to real values (usually simply using the internal indices)."
        deprecation = "Please use the operator 'Nominal2Numerical' instead"
        group      = "Preprocessing.Attributes.Filter.Converter"/>
    After saving and probably performing Ant target "Copy-Ressources" your problem should be solved, since the second description isn't present any more.

    Greetings,
      Sebastian
  • JorgeJorge Member Posts: 19 Maven
    Hi Sebastian,

    I deleted that token and the error persists...

    I tried to redefine the path of the operators.xml and I configured another time the project in eclipse, but the problem doesn't want to go out xD

    Another idea?

    Thanks for your time,
    Jorge
  • landland RapidMiner Certified Analyst, RapidMiner Certified Expert, Member Posts: 2,531 Unicorn
    Hi,
    probably you deleted it in the wrong version. This is always a little bit confusing: There is one version in <eclipseProjectDir>/ressources and one in <eclipseProjectDir>/<buildDir>/ressources. You have to edit the first one and then perform the Ant Target "Copy-Ressources"
    Another way around would be to create the Operator using its name, not its class name.

    Greetings,
      Sebastian
  • JorgeJorge Member Posts: 19 Maven
    Thanks for all Sebastian,

    The problem was in the "Copy-Resources" target  ;)

    It works perfectly now  ;D

    Greetings,
    Jorge
Sign In or Register to comment.