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
W-Apriori in Rapidminer Java Code
E_N_R_I_C_O
Member Posts: 7 Contributor II
Hello everybody,
i am a newbie in Rapidminer.
I just checked Rapidminer learner. There is a "W-Apriori" option in unsupervised learner Rapidminer.
Because i am using my Rapidminer in Javacode.
So, i thought i have to write like this:
import com.rapidminer.RapidMiner;
import com.rapidminer.example.ExampleSet;
import com.rapidminer.operator.IOContainer;
import com.rapidminer.operator.Model;
import com.rapidminer.operator.Operator;
import com.rapidminer.operator.OperatorCreationException;
import com.rapidminer.operator.io.DatabaseExampleSource;
import com.rapidminer.tools.OperatorService;
import com.rapidminer.operator.learner.Learner;
import com.rapidminer.operator.learner.rules.SingleRuleLearner;
import com.rapidminer.operator.learner.weka.GenericWekaLearner;
import com.rapidminer.operator.learner.weka.WekaAssociator;
import com.rapidminer.operator.learner.weka.GenericWekaAssociationLearner;
public static void main(String[] args) throws Exception {
RapidMiner.init();
Operator databaseExampleSource = OperatorService.createOperator(DatabaseExampleSource.class);
databaseExampleSource.setParameter("database_url",URL );
databaseExampleSource.setParameter("username", USER);
databaseExampleSource.setParameter("password", PASSWORD);
databaseExampleSource.setParameter("label_attribute", "eventname");
// databaseExampleSource.setParameter("query","SELECT * FROM `test_weather`");
databaseExampleSource.setParameter("query","SELECT eventname,device6 FROM `v_assoc_rules_dev6`");
IOContainer container = databaseExampleSource.apply(new IOContainer());
ExampleSet exampleSet = container.get(ExampleSet.class);
//getting Learner
Learner learner = (Learner)OperatorService.createOperator(GenericWekaAssociationLearner.class);
Model model = learner.learn(exampleSet);
System.out.println("Result");
System.out.println(model.toResultString());
But there's an error when i run this code:
Exception in thread "main" com.rapidminer.operator.OperatorCreationException: No operator description object given for 'com.rapidminer.operator.learner.weka.GenericWekaAssociationLearner'
at com.rapidminer.tools.OperatorService.createOperator(OperatorService.java:564)
at datamining.rapidminer.RapidMiner1.main(RapidMiner1.java:83)
Can anyone please help me??????
Thank you
i am a newbie in Rapidminer.
I just checked Rapidminer learner. There is a "W-Apriori" option in unsupervised learner Rapidminer.
Because i am using my Rapidminer in Javacode.
So, i thought i have to write like this:
import com.rapidminer.RapidMiner;
import com.rapidminer.example.ExampleSet;
import com.rapidminer.operator.IOContainer;
import com.rapidminer.operator.Model;
import com.rapidminer.operator.Operator;
import com.rapidminer.operator.OperatorCreationException;
import com.rapidminer.operator.io.DatabaseExampleSource;
import com.rapidminer.tools.OperatorService;
import com.rapidminer.operator.learner.Learner;
import com.rapidminer.operator.learner.rules.SingleRuleLearner;
import com.rapidminer.operator.learner.weka.GenericWekaLearner;
import com.rapidminer.operator.learner.weka.WekaAssociator;
import com.rapidminer.operator.learner.weka.GenericWekaAssociationLearner;
public static void main(String[] args) throws Exception {
RapidMiner.init();
Operator databaseExampleSource = OperatorService.createOperator(DatabaseExampleSource.class);
databaseExampleSource.setParameter("database_url",URL );
databaseExampleSource.setParameter("username", USER);
databaseExampleSource.setParameter("password", PASSWORD);
databaseExampleSource.setParameter("label_attribute", "eventname");
// databaseExampleSource.setParameter("query","SELECT * FROM `test_weather`");
databaseExampleSource.setParameter("query","SELECT eventname,device6 FROM `v_assoc_rules_dev6`");
IOContainer container = databaseExampleSource.apply(new IOContainer());
ExampleSet exampleSet = container.get(ExampleSet.class);
//getting Learner
Learner learner = (Learner)OperatorService.createOperator(GenericWekaAssociationLearner.class);
Model model = learner.learn(exampleSet);
System.out.println("Result");
System.out.println(model.toResultString());
But there's an error when i run this code:
Exception in thread "main" com.rapidminer.operator.OperatorCreationException: No operator description object given for 'com.rapidminer.operator.learner.weka.GenericWekaAssociationLearner'
at com.rapidminer.tools.OperatorService.createOperator(OperatorService.java:564)
at datamining.rapidminer.RapidMiner1.main(RapidMiner1.java:83)
Can anyone please help me??????
Thank you
0
Answers
are you still working with RapidMiner 4.x? The code looks like that.
Anyway you cannot build weka operators like that, because the class you entered is not one operator. Instead it's a generic adapter, which can be used for many operators. As far as I know, you could use the constructor with the String parameter instead. Simply enter the name of the operator, RapidMiner will search the implementing class itself.
By the way: Why not try FP-Growth? As far as you have sufficient memory, it will outperform Apriori around a magnitude.
Greetings,
Sebastian
thank you for ur answer.
Sorry.. I am new .. Really really new and have no experience at all with Rapidminer.
Yes.. I am still using RapidMiner 4.x in my Java Code.
What do u think? Should i change into RapidMiner 5 into my Java?
And i still have another question.
Could you give me a simple example of constructor with string paramater?
So you mean if i make a new constructor with a string parameter.
This string parameter will be read as the name of the operator that RapidMiner should use?
Thank u
I think the code of RapidMiner 5 has been improved a lot, so I guess you should convert anyway. The code base of 4.6 will not be maintained anymore in a few month.
The operator creation is simple: If you want to create operators of RapidMiner in RapidMiner 5, you will have to look up the key of the operator in the operators.xml
Greetings,
Sebastian
sorry, what the difference between w-apriori and fp-growth?
and i have data about sell transaction, how i process this data using rapidminer and w-apriori algorithm?
thank u