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

ASSOCIATION RULES WITH A PARTICULAR STRUCTURE

Legacy UserLegacy User Member Posts: 0 Newbie
I'm interesting in extracting association rules with RapidMiner. I would like to extract rules with a precise stucture. I have a database table LOG with some attributes a, b, c, d. I want only rules that have values of a and b in the antecedent and c and d in the consequent.
For instance, I'm interesting in a rule like

a="xxx" -> c="yyy"

but I'm not interested in a  rule like

d="zzz" -> b="ppp".

Does anyone know if it is possible to get rule of this kind with RapidMiner?

Thanks.

Answers

  • IngoRMIngoRM Employee-RapidMiner, RapidMiner Certified Analyst, RapidMiner Certified Expert, Community Manager, RMResearcher, Member, University Professor Posts: 1,751 RM Founder
    Hello,

    at least for the conclusions this is (partly) possible. Just have a look into the sample process "02_Learner/12_AssociationRules.xml" delivered together with RapidMiner. In the rule visualization, you can select one or more conclusions and define if they should all (Conjunction Type: AND) or at least one of them (Conjunction Type: OR) should be part of the conclusion.

    Together with the sorting of the result table by clicking on the table headers, this should hopefully bring you close to the desired result.

    Cheers,
    Ingo
  • haddockhaddock Member Posts: 849 Maven
    Greets all,

    Ingo is quite right that you can filter association rules on the fly, and that is handy. What I needed to do was to be able to store them and sift them, meaning that I needed to convert the rules to examples. No surprise that this is quite easy, as long as you are OK with regexes. Here is the code, obviously in crude form, as that is my forte..
    <operator name="Root" class="Process" expanded="yes">
        <description text=" "/>
        <parameter key="logverbosity" value="warning"/>
        <operator name="Define conclusion to look for" class="SingleMacroDefinition">
            <parameter key="macro" value="Look_for"/>
            <parameter key="value" value="car_practical"/>
        </operator>
        <operator name="Generate some data" class="DirectMailingExampleSetGenerator">
        </operator>
        <operator name="Preprocessing" class="OperatorChain" expanded="yes">
            <operator name="Make name the ID" class="ChangeAttributeRole">
                <parameter key="name" value="name"/>
                <parameter key="target_role" value="id"/>
            </operator>
            <operator name="Association rules, so make label normal attribute" class="ChangeAttributeRole">
                <parameter key="name" value="label"/>
            </operator>
            <operator name="Put numbers into bins" class="BinDiscretization">
                <parameter key="range_name_type" value="short"/>
            </operator>
            <operator name="Dichotomise the attributes" class="Nominal2Binominal">
            </operator>
        </operator>
        <operator name="Make and file away association rules" class="OperatorChain" expanded="yes">
            <operator name="Make frequent item sets" class="FPGrowth">
                <parameter key="find_min_number_of_itemsets" value="false"/>
                <parameter key="min_support" value="0.1"/>
            </operator>
            <operator name="Make some if then rules" class="AssociationRuleGenerator">
                <parameter key="min_confidence" value="0.7"/>
            </operator>
            <operator name="File the results as assocs" class="ResultWriter">
                <parameter key="result_file" value="assocs"/>
            </operator>
        </operator>
        <operator name="Look for the desired conclusion" class="OperatorChain" expanded="yes">
            <operator name="Load the results as 1 attribute examples, line by line" class="SimpleExampleSource">
                <parameter key="filename" value="assocs"/>
                <parameter key="column_separators" value="\n"/>
            </operator>
            <operator name="Rename attribute assoc (1) to assoc to make it usable" class="ChangeAttributeNamesReplace">
                <parameter key="replace_what" value="\s|\(|\)|1"/>
                <parameter key="apply_on_special" value="false"/>
            </operator>
            <operator name="Make example 1 binnable as it only has RM comments" class="SetData">
                <parameter key="attribute_name" value="assocs"/>
                <parameter key="example_index" value="1"/>
                <parameter key="value" value="x"/>
            </operator>
            <operator name="Make example two the attributes header" class="SetData">
                <parameter key="attribute_name" value="assocs"/>
                <parameter key="example_index" value="2"/>
                <parameter key="value" value="Premises|Conclusions|Confidence"/>
            </operator>
            <operator name="Bin example 1" class="ExampleFilter">
                <parameter key="condition_class" value="attribute_value_filter"/>
                <parameter key="parameter_string" value="assocs=x"/>
                <parameter key="invert_filter" value="true"/>
            </operator>
            <operator name="Mark out Premises, Conclusions, and Confidence columns" class="Replace">
                <parameter key="attributes" value=".*"/>
                <parameter key="replace_what" value="--&gt;|\("/>
                <parameter key="replace_by" value="|"/>
            </operator>
            <operator name="Clear remaining brackets and verbage" class="Replace">
                <parameter key="attributes" value=".*"/>
                <parameter key="replace_what" value="confidence|\[|\]|\)|\:|\s"/>
            </operator>
            <operator name="Write out the 1 attribute example set" class="ExampleSetWriter">
                <parameter key="example_set_file" value="assocs"/>
                <parameter key="quote_nominal_values" value="false"/>
            </operator>
            <operator name="Read it back as three attribute example set" class="SimpleExampleSource">
                <parameter key="filename" value="assocs"/>
                <parameter key="read_attribute_names" value="true"/>
                <parameter key="column_separators" value="\|"/>
            </operator>
            <operator name="Replace equals sign in Conclusion" class="Replace">
                <parameter key="attributes" value="Con.*"/>
                <parameter key="replace_what" value="="/>
                <parameter key="replace_by" value="_"/>
            </operator>
            <operator name="Remove all conclusions except what is looked for" class="Replace">
                <parameter key="attributes" value="Con.*"/>
                <parameter key="replace_what" value="\b(?:(?!%{Look_for})\w)+\b"/>
            </operator>
            <operator name="Remove commas" class="Replace">
                <parameter key="attributes" value="Con.*"/>
                <parameter key="replace_what" value="\,"/>
            </operator>
            <operator name="Remove all examples except what is looked for" class="ExampleFilter">
                <parameter key="condition_class" value="attribute_value_filter"/>
                <parameter key="parameter_string" value="Conclusions=\?"/>
                <parameter key="invert_filter" value="true"/>
            </operator>
        </operator>
    </operator>
    Have fun!  ;D

Sign In or Register to comment.