Class RealHyp

Inheritance Relationships

Derived Type

Class Documentation

class RealHyp

The RealHyp class is responsible for extracting and managing decision rules based on hyperplanes in a dataset using a neural network.

This class interacts with a neural network and a virtual hyperplane representation to identify, confirm, and refine rules that classify data examples. The extracted rules are pruned, expanded, and evaluated for accuracy and fidelity.

Subclassed by RealHyp2

Public Functions

inline int TreeAborted() const

Checks if the decision tree construction was aborted.

Returns:

Returns 1 if the tree was aborted, otherwise 0.

void SetConfirmedVirt(DataSet &data)

Sets confirmed virtual hyperplanes based on the dataset.

Parameters:

data – The dataset used for confirming virtual hyperplanes.

void SetRealHyp(DataSet &data)

Sets real hyperplanes based on the dataset.

Parameters:

data – The dataset used for setting real hyperplanes.

void Gl2(int var, int indPat, int startVirt, int netAns)

Go right in the hyperplane search for rule extraction.

Adjusts the input variable to the left of a virtual hyperplane and checks for classification changes.

This function iterates through the virtual hyperplanes to the left of a given starting index for a specific variable. It adjusts the variable’s value to each hyperplane’s position, and after each adjustment, it forwards the example through the neural network to check if the classification changes. If a change is detected, the hyperplane is marked as relevant.

Parameters:
  • var – The variable index to adjust.

  • indPat – The index of the pattern (example) being processed.

  • startVirt – The starting index of the virtual hyperplane.

  • netAns – The network’s initial classification result.

void Gr2(int var, int indPat, int startVirt, int netAns)

Go left in the hyperplane search for rule extraction.

Adjusts the input variable to the right of a virtual hyperplane and checks for classification changes.

This function iterates through the virtual hyperplanes to the right of a given starting index for a specific variable. It adjusts the variable’s value to each hyperplane’s position, and after each adjustment, it forwards the example through the neural network to check if the classification changes. If a change is detected, the hyperplane is marked as relevant.

Parameters:
  • var – The variable index to adjust.

  • indPat – The index of the pattern (example) being processed.

  • startVirt – The starting index of the virtual hyperplane.

  • netAns – The network’s initial classification result.

void RuleExtraction(DataSet &data, const DataSet &train, const DataSet &trainClass, const DataSet &valid, const DataSet &validClass, const DataSet &test, const DataSet &testClass, const AttrName &attr, 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>())

Extracts rules from the dataset and writes them to the provided output stream.

This method performs the rule extraction process using the specified datasets. It builds a decision tree, prunes the rules, and then writes the extracted rules in an IF-THEN format to the provided output stream. The method can optionally denormalize the values using the provided means, standard deviations, and normalization indices.

The process involves the following steps:

  1. Build an initial decision tree from the dataset.

  2. Prune antecedents and rules to simplify the rule set.

  3. Optionally retry rule extraction with expanded rules.

  4. Write the final set of rules to the output stream.

Parameters:
  • data – The dataset used for rule extraction.

  • train – Training dataset.

  • trainClass – Training dataset classes.

  • valid – Validation dataset.

  • validClass – Validation dataset classes.

  • test – Testing dataset.

  • testClass – Testing dataset classes.

  • attr – Attribute names.

  • ruleFile – Output stream for writing rules.

  • mus – Means for normalization (optional).

  • sigmas – Standard deviations for normalization (optional).

  • normalizationIndices – Indices for normalization (optional).

virtual ~RealHyp() = default

Virtual destructor for the RealHyp class.

RealHyp(DataSet &data, std::shared_ptr<BpNN> nn, int nbBins, int nbIn, int multiple, int nbWeightLayers)

Constructs a RealHyp object and sets up hyperplanes based on the provided dataset and neural network.

Parameters:
  • data – The dataset used for rule extraction.

  • nn – The neural network used for rule extraction.

  • nbBins – The number of bins for virtual hyperplanes.

  • nbIn – The number of input variables.

  • multiple – The multiplicity factor for hyperplanes.

  • nbWeightLayers – The number of layers in the neural network.

RealHyp(DataSet &data, std::shared_ptr<BpNN> nn, int nbBins, int nbIn, int multiple, int nbWeightLayers, int dummy)

Constructs a RealHyp object with additional parameters for hyperplanes.

Parameters:
  • data – The dataset used for rule extraction.

  • nn – The neural network used for rule extraction.

  • nbBins – The number of bins for virtual hyperplanes.

  • nbIn – The number of input variables.

  • multiple – The multiplicity factor for hyperplanes.

  • nbWeightLayers – The number of layers in the neural network.

  • dummy – A dummy parameter for distinguishing constructors.

RealHyp(std::shared_ptr<VirtualHyp> globalVirt, int nbNets, float *out, int nbOut, DataSet &data, std::shared_ptr<BpNN> nn, int nbBins, int nbIn, int multiple, int nbWeightLayers)

Constructs a RealHyp object with a shared virtual hyperplane representation.

Parameters:
  • globalVirt – Shared virtual hyperplane representation.

  • nbNets – Number of neural networks.

  • out – Output values from the neural network.

  • nbOut – Number of output classes.

  • data – The dataset used for rule extraction.

  • nn – The neural network used for rule extraction.

  • nbBins – The number of bins for virtual hyperplanes.

  • nbIn – The number of input variables.

  • multiple – The multiplicity factor for hyperplanes.

  • nbWeightLayers – The number of layers in the neural network.

RealHyp(std::shared_ptr<VirtualHyp> globalVirt, int nbNets, float *out, int nbOut, DataSet &data, std::shared_ptr<BpNN> nn, int nbBins, int nbIn, int multiple, int nbWeightLayers, int dummy)

Constructs a RealHyp object with additional parameters for hyperplanes and a shared virtual hyperplane representation.

Parameters:
  • globalVirt – Shared virtual hyperplane representation.

  • nbNets – Number of neural networks.

  • out – Output values from the neural network.

  • nbOut – Number of output classes.

  • data – The dataset used for rule extraction.

  • nn – The neural network used for rule extraction.

  • nbBins – The number of bins for virtual hyperplanes.

  • nbIn – The number of input variables.

  • multiple – The multiplicity factor for hyperplanes.

  • nbWeightLayers – The number of layers in the neural network.

  • dummy – A dummy parameter for distinguishing constructors.