newbie here
E_N_R_I_C_O
New Altair Community Member
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.
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.
0
Answers
-
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,
Steffen0 -
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:
This is my code:
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)
Do you have maybe any idea or recommendation what i have to do?
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());
}
}
Thank you
Enrico0 -
Hello enrico
Operator testSource = OperatorService.createOperator(DatabaseExampleSource.class);
databaseExampleSource.setParameter("database_url",URL );
...
container = testSource.apply(new IOContainer());
happy mining
Steffen0 -
Hello Steffen,
well... Thank you0