Class CleanRuleStruct
Defined in File cleanRS.h
Nested Relationships
Nested Types
Class Documentation
-
class CleanRuleStruct
Class CleanRuleStruct is used to simplify and manage the rules derived from the rule extraction process.
This class provides functionalities to:
Simplify the rule set using else-clauses.
Prune and expand rules to ensure they are both minimal and effective.
Calculate and track the accuracy and coverage of the rules on different datasets (training, testing, validation).
Handle the classification and representation of rules.
Ensure the fidelity of the rules, meaning that the rules correctly cover all examples.
Public Functions
-
void WriteRules(int def, std::ostream &ruleFile, const std::vector<double> &mus = std::vector<double>(), const std::vector<double> &sigmas = std::vector<double>(), const std::vector<int> &normalizationIndices = std::vector<int>())
Writes the rules to a file.
- Parameters:
def – Flag indicating whether to include the default rule.
ruleFile – Output stream to write the rules.
mus – Means for denormalization (optional).
sigmas – Standard deviations for denormalization (optional).
normalizationIndices – Indices of normalized attributes (optional).
-
void ElseRepresentation()
Represents the rules using else-clauses for various datasets.
This function resets certain fields and then applies the else-clause representation for all datasets including the full dataset, training set, testing set, and validation set. The else-clause ensures that each instance in the datasets is covered by a rule, providing a classification even when no specific rule applies to the instance.
-
void SimplifyElse(ThresDescr *descr)
Simplifies the rules using else-clauses.
This function performs a series of operations to simplify the rule set by using else-clauses. It follows these steps:
Sorts the rules.
Flags all rules for processing.
Iteratively prunes and expands the rules:
RandomPruneAnt()
: Randomly prunes antecedents from the rules.PruneRule()
: Prunes rules that do not significantly contribute to the classification.OrderedExpand(ThresDescr *descr)
: Expands the rules by adjusting the thresholds.
Ensures fidelity, which means that the simplified rules still cover all examples correctly.
Creates a new cleaned set of rules.
Sets the default class for cases not covered by any rule.
Prunes the rules again to ensure optimal simplification.
Writes the number of rules and antecedents.
- Parameters:
descr – Description of thresholds used to expand and adjust the rules.
-
inline void Del()
Deletes all rules.
-
void SetAttr(std::vector<std::string> listAttr) const
Sets the attribute names for the rules.
- Parameters:
listAttr – List of attribute names.
-
void SetAttr()
Sets the attribute names for the rules using attribute ids.
-
void SetStrClass(std::vector<std::string> listClass, int def) const
Sets the class names for the rules.
- Parameters:
listClass – List of class names.
def – Default class flag.
-
void SetStrClass(int def)
Sets the class names for the rules using class ids.
- Parameters:
def – Default class flag.
Constructs a CleanRuleStruct object.
- Parameters:
all – All data.
train – Training data.
trainClass – Training class labels.
valid – Validation data.
validClass – Validation class labels.
test – Testing data.
testClass – Testing class labels.
processed – Processed rules.
bpNn – Neural network pointer.
out – Neural network output.
nbOut – Number of output classes.