Adding Rules Manually in the Rule Manager

The Rule Manager allows you not only to inspect, manipulate and optimize a set of rules created with the LLM tasks, but also to manually add heuristic rules, by simply linking it to a Data Manager.

Heuristic rules are important when you need to manually add simple and generic rules: this makes the complete rule analysis process easy and customizable.

The Rule Manager task is divided into two main tabs:

  1. In the Rules tab, you can visualize the rules, add new ones and sort or filter them.

  2. In the History tab, you can visualize all the operations performed and cancel them.


Prerequisites


Procedure

This procedure can be followed also if you already have some output rules coming from another task.

  1. After having selected the output attribute in a Data Manager task, drag the Rule Manager task onto the stage.

  2. Link it to a Data Manager.

  3. Double click the Rule Manager task.

  4. Right click on the white space at the left of the #Cond area.

  5. Click on Create Rule. A window opens.

  6. Choose the output attribute by clicking on the Order by drop down list. It must have been defined in the Data Manager. If multiple attributes have been defined, you can sort them by:

    1. Attribute: the attributes' names are sorted as they appear on the original dataset.

    2. Name: all the attributes' names will be sorted in alphabetical or crescent order.

    3. Type: attributes will be sorted following their type’s alphabetical order.

    4. Ignored: attributes are sorted with ignored attributes on top of the list.

    5. Role: attributes will be sorted according to their role within the dataset.

  7. Click Next to go to the Output value section.

  8. Select the output of the rule you are creating, then click Save.

  9. Right click onto the rule number, which is identified with the row number, and click Append condition to open the conditions dialog window.

  10. Choose the attribute on which you want to create the condition and click Next.

  11. Select the attribute’s value, then click Save.

  12. Repeat the operation for each condition.

  13. Save and compute the task.


Results spreadsheets

Rules spreadsheet

The Rule spreadsheet, with the generated ruleset, contains the following columns:

  • #Cond: the number of conditions in the rule.

  • Output: the output if that rule is matched.

  • Cond n: the n-th condition.

In this spreadsheet you can modify rules and conditions:

  • To delete a rule, select its row in the table and either click the minus icon above the spreadsheet or right-click and select Delete selected rules.

  • To add new rules either click the plus icon above the spreadsheets or by right-click within the spreadsheet and select Create rule. Once you have specified the output value for your rule, a blank rule will be added to the table to which you will then need to add/append conditions.  

  • To delete a condition select it in the spreadsheet, right-click and select Delete selected condition or simply press Delete. The conditions to be removed can belong to different rules. 

  • To edit a condition either select it in the spreadsheet, right-click and select Edit condition or simply double-click it. The changes you can make depend on whether the condition is an ordered or nominal condition.

Covering spreadsheet

The Covering spreadsheet, with additional information related to the covering of each rule in the following columns:

  • #Patt.: the number of patterns in the training set with the same output class of the rule.

  • Covering: the percentage of patterns (with the output class of the rule) matched by this rule in relation to the total number of patterns of that class.

  • w\o Cond n: the covering gain that would be obtained by removing the n-th condition.

Error spreadsheet

The Error spreadsheet, with additional information about the error scored by each rule in the following columns:

  • #Patt.: the number of patterns in the training set with the output class different from the output class of the rule.

  • Error: the percentage of patterns (with the output class different from that of the rule) matched by this rule in relation to the total number of patterns where the output class is different from the class of the rule.

  • w\o Cond n: the error increase that would be obtained by removing the n-th condition. 


Example

The following example uses the Go to work business rules dataset.

Description

Screenshot

Import the dataset through an Import from Excel File task, then drag a Data Manager and define the Transport attribute as Output by right clicking on the attribute in the attributes list and choosing Edit in the drop down menu.

Then, open the Role drop down list and select Output. Click Apply.

Save and compute the task.

Add a Rule Manager task and link it to the Data Manager.

Open it and in the spreadsheets section, right click on the blank space next to the #Cond column. Then, click on Create rule.

Select Transport as Output attribute, then click Next.

n this example we want to add three rules, stating that:

  1. IF Weather = Sunny AND IF Smart Working = No, THEN Transport = Bicycle

  2. IF Weather = Rain AND IF Smart Working = No, THEN Transport = Bus

  3. IF Smart Working = Yes, THEN Transport = None

Let’s start by adding the first rule, so select Bicycle as the output value and click Save. The rule has been added onto the Rules tab.

As this rule has only an Output, we need to add its conditions.

Right click onto the rule number (which is identified by the row number) and click on Append condition: in the Attribute section, select Weather, then click Next.

Select the Sunny value in the Append condition section, then click on Save to add the condition to the rule.

Repeat the same steps mentioned above and select Smart Working in the Attribute section.

Then, select No as the value in the Append Condition section.

Then, click Save.

The first rule has been created.

It must be read as follows: if Weather is Sunny and Smart Working is No, then the Transport is Bicycle, meaning that if it doesn’t rain and the smart working is not allowed, the chosen transport will be the bike.

Repeat the same operations mentioned above to add the other rules.

Go to the Analyzing Rules in the Rule Manager page to know more on how to read the rules in the Rule Manager and to know more on the other spreadsheets and the data they contain.