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

newbie here

E_N_R_I_C_OE_N_R_I_C_O Member Posts: 7 Contributor II
edited November 2018 in Help
Hello,

i am a newbie..
I just finished installled my RapidMiner.

I want to use RapidMiner thru Java Code.

I want to make a DBaseExampleSource in my code and with BasicRuleLearner, i want to make rules from my database.
Could anyone please help me or at least give a link of java code that uses DBaseExampleSource?
Because until now, i still couldn't find any examples based on DBaseExampleSource.


I would be very glad if i get feedback from one of you.


Tagged:

Answers

  • steffensteffen Member Posts: 347 Maven
    Hello and welcome to RapidMiner

    there is a file called "tutorial.pdf" available at rapidminer download page at sourceforge. In this pdf you will find a chapter dealing with embedding rapidminer in a java application, where also is explained how to use operators in code. Understand the "pattern" and then switch to the operators of your preference.

    If the tutorial is not enough, feel free to come back and ask again :)

    regards,

    Steffen
  • E_N_R_I_C_OE_N_R_I_C_O Member Posts: 7 Contributor II
    Hello Steffen,

    thank you for your answer. I really appreciate it.

    I have read that tutorial.pdf and am still trying to connect to data base. It is still not working.

    There is a problem which is:

    G Nov 6, 2009 6:23:58 PM: [Error] Parameter 'database_url' is not set and has no default value.
    Exception in thread "main" com.rapidminer.parameter.UndefinedParameterError: A value for the parameter 'database_url' must be specified!
    at com.rapidminer.parameter.Parameters.getParameter(Parameters.java:157)
    at com.rapidminer.operator.Operator.getParameter(Operator.java:988)
    at com.rapidminer.operator.Operator.getParameterAsString(Operator.java:1002)
    at com.rapidminer.operator.io.DatabaseExampleSource.getConnectedDatabaseHandler(DatabaseExampleSource.java:254)
    at com.rapidminer.operator.io.DatabaseExampleSource.getResultSet(DatabaseExampleSource.java:269)
    at com.rapidminer.operator.io.ResultSetExampleSource.createExampleSet(ResultSetExampleSource.java:96)
    at com.rapidminer.operator.io.DatabaseExampleSource.createExampleSet(DatabaseExampleSource.java:153)
    at com.rapidminer.operator.io.AbstractExampleSource.read(AbstractExampleSource.java:44)
    at com.rapidminer.operator.io.AbstractExampleSource.read(AbstractExampleSource.java:1)
    at com.rapidminer.operator.io.AbstractReader.apply(AbstractReader.java:52)
    at com.rapidminer.operator.Operator.apply(Operator.java:671)
    at RapidMiner1.main(RapidMiner1.java:90)
    This is my code:

    public class RapidMiner1 {

     public final static String URL = "jdbc:mysql://localhost:3306/kehl";
     public final static String USER = "root";
     public final static String PASSWORD = "";

    public static void main(String[] args) throws Exception {

    RapidMiner. init ();

    Operator databaseExampleSource = OperatorService.createOperator(DatabaseExampleSource.class);
    System.out.println(databaseExampleSource);
    databaseExampleSource.setParameter("database_url",URL );
    databaseExampleSource.setParameter("username", USER);
    databaseExampleSource.setParameter("password", PASSWORD);
    databaseExampleSource.setParameter("label_attribute", "play");
    databaseExampleSource.setParameter("query","SELECT * FROM `test_weather`");

    IOContainer container = databaseExampleSource.apply(new IOContainer());
    ExampleSet exampleSet = container.get(ExampleSet.class);

    //getting Learner
    Learner learner = (Learner)OperatorService.createOperator(SimpleRuleLearner.class);
    Model model = learner.learn(exampleSet);

    // loading the test set (plus adding the model to result container )
    Operator testSource = OperatorService.createOperator(DatabaseExampleSource.class);
    databaseExampleSource.setParameter("database_url",URL );
    databaseExampleSource.setParameter("username", USER);
    databaseExampleSource.setParameter("password", PASSWORD);
    databaseExampleSource.setParameter("label_attribute", "play");
    databaseExampleSource.setParameter("query","SELECT * FROM `test_weather`");

    container = testSource.apply(new IOContainer());
    container = container.append(model);

    // applying the model
    Operator modelApp = OperatorService.createOperator(ModelApplier.class );
    container = modelApp.apply(container);

    // print results
    ExampleSet resultSet = container.get(ExampleSet.class);
                   System.out. println (resultSet.size());
                   
                   }

    }
    Do you have maybe any idea or recommendation what i have to do?


    Thank you

    Enrico
  • steffensteffen Member Posts: 347 Maven
    Hello enrico
    Operator testSource = OperatorService.createOperator(DatabaseExampleSource.class);
    databaseExampleSource.setParameter("database_url",URL );
    ...
    container = testSource.apply(new IOContainer());
    ;)

    happy mining

    Steffen
  • E_N_R_I_C_OE_N_R_I_C_O Member Posts: 7 Contributor II
    Hello Steffen,


    well... Thank you :)
Sign In or Register to comment.