"Storing Association Rules Results"

ocort
ocort New Altair Community Member
edited November 5 in Community Q&A
Hi,

Is there any way to store the Association Rules results as show in Table View to a database table or at least to a CSV.
I only found the TextWriter node but it lacks a lot of info and is difficult to handle.

Thanks in advance and congrats for the v5

Oriol.

Answers

  • IngoRM
    IngoRM New Altair Community Member
    Right.

    And by the way: Welcome to our forum and thanks for the kinde words about v5  ;D

    Cheers,
    Ingo
  • ocort
    ocort New Altair Community Member
    The model with Groovy works great. Thanks for your help I didn't found the topic.

    I'm using Weka embedded in my Java app but I'll consider to change to your library, it looks quite more powerful now.
  • IngoRM
    IngoRM New Altair Community Member
    It certainly is. I have just searched in my mails for a comment of one of our users about RapidMiner:

    "RapidMiner is like Weka + more algorithms + much more preprocessing and process control + better visualizations"


    Don't get me wrong: Weka has inspired us a lot and is a great library for the data mining step. But I think the citation above somehow captures some of the basic ideas of RapidMiner especially when it comes to preprocessing and supporting the whole data mining process.

    Cheers,
    Ingo

  • haddock
    haddock New Altair Community Member
    Hola Oriol,

    Thanks for the feedback, always useful. Actually I think that the Groovy gateway is a neat first step for oafs like myself who want to have a prod around inside. I'm even deluding myself about a java extension now...

    Apologies if my first reply was a bit abrupt - let me also welcome you to this puzzler's paradise  ;D

  • ocort
    ocort New Altair Community Member
    Thats true Ingo, and theres a key feature for me, its robust.
    I've been using your software since you were YALE as my Weka GUI, because Weka intefaces always give me problems with memory, crashes...
    But now I see you are far better in all senses  :D
    I'll wil spend sometime playing with 5.0

    No problem Haddock, I know it's boring replying always the same questions. I always make a search before asking :-)
    By the way, I said victory to soon, database writer don't accept the Execute Scirpt output as exampleset :-( Well I'll find a workaround, don't matter :-D
  • haddock
    haddock New Altair Community Member
    Hola,

    Looks like the dreaded infinity problem, but fear not, there is a ready made solution in the form of the "sleeping eight removal" operative! My MS 2005 data dustbin belches contentedly if I run the following...

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    <process version="5.0">
      <context>
        <input>
          <location/>
        </input>
        <output>
          <location/>
          <location/>
        </output>
        <macros/>
      </context>
      <operator activated="true" class="process" expanded="true" name="Root">
        <parameter key="logverbosity" value="warning"/>
        <process expanded="true" height="386" width="909">
          <operator activated="true" class="retrieve" expanded="true" height="60" name="Retrieve" width="90" x="45" y="30">
            <parameter key="repository_entry" value="//Samples/data/Iris"/>
          </operator>
          <operator activated="true" class="subprocess" expanded="true" height="76" name="Preprocessing" width="90" x="180" y="30">
            <process expanded="true" height="385" width="909">
              <operator activated="true" class="discretize_by_frequency" expanded="true" height="94" name="FrequencyDiscretization" width="90" x="45" y="30">
                <parameter key="number_of_bins" value="5"/>
                <parameter key="range_name_type" value="short"/>
              </operator>
              <operator activated="true" class="nominal_to_binominal" expanded="true" height="94" name="Nominal2Binominal" width="90" x="477" y="30">
                <parameter key="transform_binominal" value="true"/>
              </operator>
              <connect from_port="in 1" to_op="FrequencyDiscretization" to_port="example set input"/>
              <connect from_op="FrequencyDiscretization" from_port="example set output" to_op="Nominal2Binominal" to_port="example set input"/>
              <connect from_op="Nominal2Binominal" from_port="example set output" to_port="out 1"/>
              <portSpacing port="source_in 1" spacing="0"/>
              <portSpacing port="source_in 2" spacing="0"/>
              <portSpacing port="sink_out 1" spacing="0"/>
              <portSpacing port="sink_out 2" spacing="0"/>
            </process>
          </operator>
          <operator activated="true" class="fp_growth" expanded="true" height="76" name="FPGrowth" width="90" x="313" y="30">
            <parameter key="find_min_number_of_itemsets" value="false"/>
            <parameter key="min_support" value="0.1"/>
          </operator>
          <operator activated="true" class="create_association_rules" expanded="true" height="60" name="AssociationRuleGenerator" width="90" x="313" y="165">
            <parameter key="min_confidence" value="0.7"/>
          </operator>
          <operator activated="true" class="execute_script" expanded="true" height="76" name="Execute Script" width="90" x="447" y="255">
            <parameter key="script" value="import com.rapidminer.tools.Ontology;&#13;&#13;&#10;import com.rapidminer.operator.learner.associations.*;&#13;&#13;&#10;&#13;&#10;AssociationRules rules = input[0];&#13;&#13;&#10;&#10;&#13;// construct attribute set&#13;&#10;Attribute[] attributes= new Attribute[11];&#10;attributes[0] = AttributeFactory.createAttribute(&quot;Premise&quot;, Ontology.STRING);&#13;&#13;&#10;attributes[1] = AttributeFactory.createAttribute(&quot;Premise Items&quot;, Ontology.INTEGER);&#10;attributes[2] = AttributeFactory.createAttribute(&quot;Conclusion&quot;, Ontology.STRING);&#13;&#10;attributes[3] = AttributeFactory.createAttribute(&quot;Conclusion Items&quot;, Ontology.INTEGER);&#13;&#10;attributes[4] = AttributeFactory.createAttribute(&quot;Confidence&quot;, Ontology.REAL);&#13;&#10;attributes[5] = AttributeFactory.createAttribute(&quot;Conviction&quot;, Ontology.REAL);&#13;&#10;attributes[6] = AttributeFactory.createAttribute(&quot;Gain&quot;, Ontology.REAL);&#13;&#10;attributes[7] = AttributeFactory.createAttribute(&quot;Laplace&quot;, Ontology.REAL);&#13;&#13;&#10;attributes[8] = AttributeFactory.createAttribute(&quot;Lift&quot;, Ontology.REAL);&#13;&#10;attributes[9] = AttributeFactory.createAttribute(&quot;Ps&quot;, Ontology.REAL);&#10;&#13;&#13;attributes[10] = AttributeFactory.createAttribute(&quot;Total Support&quot;, Ontology.REAL);&#10;&#13;&#13;&#13;&#10;MemoryExampleTable table = new MemoryExampleTable(attributes);&#10;DataRowFactory ROW_FACTORY = new DataRowFactory(0);&#13;&#10;&#13;String[] strings= new String[11];&#13;&#10;&#10;for (AssociationRule rule : rules) {&#10;&#9;&#9;// construct example data&#10;        strings[0]=rule.toPremiseString();&#13;&#10;        strings[1]=rule.premise.size().toString();&#13;&#10;        strings[2]=rule.toConclusionString();&#13;&#10;        strings[3]=rule.conclusion.size().toString();&#13;&#10;        strings[4]=rule.getConfidence().toString();&#13;&#10;        strings[5]=rule.getConviction().toString();&#13;&#10;        strings[6]=rule.getGain().toString();&#13;&#10;        strings[7]=rule.getLaplace().toString();&#13;&#10;        strings[8]=rule.getLift().toString();&#13;&#10;&#13;        strings[9]=rule.getPs().toString();&#13;&#10;        strings[10]=rule.getTotalSupport().toString();&#13;&#13;&#10;        // make and add row&#13;&#10;        DataRow row = ROW_FACTORY.create(strings, attributes); &#13;&#10;        table.addDataRow(row);&#9;&#10;&#9;&#9;}&#10;&#13;&#10;ExampleSet exampleSet = table.createExampleSet();&#10;return exampleSet;&#10;"/>
          </operator>
          <operator activated="true" class="replace_infinite_values" expanded="true" height="94" name="Replace Infinite Values" width="90" x="581" y="165">
            <list key="columns"/>
          </operator>
          <operator activated="true" class="write_database" expanded="true" height="60" name="Write Database" width="90" x="715" y="75">
            <parameter key="connection" value="CJFP"/>
            <parameter key="table_name" value="testo"/>
            <parameter key="overwrite_mode" value="overwrite first, append then"/>
            <parameter key="set_default_varchar_length" value="true"/>
          </operator>
          <connect from_op="Retrieve" from_port="output" to_op="Preprocessing" to_port="in 1"/>
          <connect from_op="Preprocessing" from_port="out 1" to_op="FPGrowth" to_port="example set"/>
          <connect from_op="FPGrowth" from_port="frequent sets" to_op="AssociationRuleGenerator" to_port="item sets"/>
          <connect from_op="AssociationRuleGenerator" from_port="rules" to_op="Execute Script" to_port="input 1"/>
          <connect from_op="Execute Script" from_port="output 1" to_op="Replace Infinite Values" to_port="example set input"/>
          <connect from_op="Replace Infinite Values" from_port="example set output" to_op="Write Database" to_port="input"/>
          <connect from_op="Write Database" from_port="through" to_port="result 1"/>
          <portSpacing port="source_input 1" spacing="0"/>
          <portSpacing port="sink_result 1" spacing="0"/>
          <portSpacing port="sink_result 2" spacing="0"/>
        </process>
      </operator>
    </process>
    Ooops, I am in France, and my stomach shouts, so time for fodder and grog and I wish you all a v. jolly weekend.

    Pip pip.




  • ocort
    ocort New Altair Community Member
    Works fine!
    Thanks