Rule Cost

These modules provide a set of classes for calculating costs associated with different sets of rules. These cost calculations are integral to optimization problems, where the cost of a each specific rule is multiplied by the rule’s weight and added to the total error rate for minimization.

class ruleopt.rule_cost.Length

Calculate the cost of a rule based on its length.

class ruleopt.rule_cost.Gini

Calculate the Gini cost of a split.

\[Gini = 1 - \sum_{i=1}^{n}(p_i)^2,\]

where

  • \(p_i\) is the probability of an object being classified to a particular class.

class ruleopt.rule_cost.Mixed

Calculate the mixed cost, combining class separation and data selection terms with a weighting parameter.

The mixed cost for a rule is calculated as follows:

\[Mixed = w \times class\_separation\_term + (1 - w) \times data\_selection\_term,\]

where

  • \(w\) is the weighting parameter to balance class separation and data selection terms,

  • \(class\_separation\_term\) is \(1 - \left(1 - \left(\frac{\min(covers)}{number\_of\_classes}\right)\right)\),

  • \(data\_selection\_term\) is \(1 - \left(\frac{number\_of\_classes}{total\_samples}\right)\).

__init__(w=0.7)

Initialize the mixed cost calculation with a weighting parameter.

Parameters:

w (float, optional, default=0.7) – Weighting parameter to balance class separation and data selection terms.

class ruleopt.rule_cost.MixedSigmoid

Calculate the mixed cost with a sigmoid adjustment based on weighting and alpha parameters.

The sigmoid-adjusted mixed cost for a rule is calculated as follows:

\[MixedSigmoid = \frac{1}{1 + e^{-\alpha (w \times class\_separation\_term + (1 - w) \times data\_selection\_term - 0.5)}},\]

where

  • \(w\) is the weighting parameter to balance class separation and data selection terms,

  • \(\alpha\) is the scaling parameter to adjust the steepness of the sigmoid function,

  • \(class\_separation\_term\) is \(1 - \left(1 - \left(\frac{\min(covers)}{number\_of\_classes}\right)\right)\),

  • \(data\_selection\_term\) is \(1 - \left(\frac{number\_of\_classes}{total\_samples}\right)\).

__init__(w=0.7, alpha=10)

Initialize the sigmoid-adjusted mixed cost calculation with weighting and alpha parameters.

Parameters:
  • w (float, optional, default=0.7) – Weighting parameter to balance class separation and data selection terms.

  • alpha (float, optional, default=10) – Scaling parameter to adjust the steepness of the sigmoid function.