soft.fuzzy.logic.rules.creation package

Submodules

soft.fuzzy.logic.rules.creation.common module

Implements various functions that are useful or common between various fuzzy logic rule generation procedures, such as the namedtuple “Rule”.

soft.fuzzy.logic.rules.creation.common.find_maximum_fuzzy_terms(data_observation: Tensor, antecedents: List[ContinuousFuzzySet], offset: int = 0)

Given a data observation and antecedents, find the fuzzy set in each dimension that has maximum membership.

Parameters:
  • data_observation – A data observation.

  • antecedents – The antecedents.

  • offset – An offset to start counting from with respect to variable index, default is 0.

Returns:

A compound proposition (frozenset) of 2-tuple elements, where the first item in the element refers to the indexed variable, and the second item in the element refers to the indexed term or value for that variable. Also, a second object is returned as well, a list of membership degrees (represented as float).

soft.fuzzy.logic.rules.creation.latent module

Functions related to the fuzzy logic rule creation process outlined as the Latent Lockstep Method.

soft.fuzzy.logic.rules.creation.latent.latent_lockstep_method(dataset: SupervisedDataset, linguistic_variables: LinguisticVariables, autoencoder: Module, config: Config) Set[Rule]

The Latent-Lockstep Method for High-Dimensional Fuzzy Logic Rule Generation (by John Wesley Hostetter).

Find the input data’s representation in the latent space, then apply CLIP, followed by the Latent Lockstep Method to produce the

Parameters:
  • dataset – The input data.

  • linguistic_variables – The antecedents (in the original space).

  • autoencoder – The auto-encoder.

  • config – YACS.yacs.Config

Returns:

A set of fuzzy logic rules.

soft.fuzzy.logic.rules.creation.latent.latent_lockstep_method_helper(input_data: Tensor, antecedents, autoencoder: Module, hidden_antecedents) Set[Rule]

A helper method for the Latent-Lockstep Method. Given the input data, the auto-encoder, antecedents (in the original space), and a configuration, generate only the fuzzy logic rules that are unique in the latent space.

Parameters:
  • input_data – The input data.

  • autoencoder – The auto-encoder.

  • antecedents – The antecedents (in the original space).

  • hidden_antecedents – The antecedents (in the latent space).

Returns:

A set of fuzzy logic rules.

soft.fuzzy.logic.rules.creation.latent.latent_space(input_data: Tensor, autoencoder: Module) Tensor

Given the input data and its auto-encoder, convert the input data to its latent space representation.

Parameters:
  • input_data – The input data.

  • autoencoder – The auto-encoder.

Returns:

The latent space representation.

soft.fuzzy.logic.rules.creation.rough_compatibility module

Implements various code necessary to making fuzzy logic rules compatible with the in-house implementation of rough set theory. Typically, enabling rough set theory compatibility of fuzzy logic rules may slow down the addition or creation of these rules to the KnowledgeBase object.

soft.fuzzy.logic.rules.creation.rough_compatibility.convert_rules_to_rough_compatible(rules: set, rough_compatibility=True) -> (<class 'set'>, <class 'dict'>, <class 'set'>)

Converts the readable set of fuzzy logic rules to a slightly less readable format that allows rough set theory to easily manipulate the fuzzy logic rules.

Example input rules: frozenset({(0, 1), (1, 1), (2, 0), (3, 1)}) aka A1 frozenset({(1, 0), (2, 0), (3, 0), (0, 0)}) aka A2 frozenset({(0, 1), (1, 1), (2, 0), (3, 2)}) aka A3

Example output: Relation(0, {{A2}, {A1, A3}})

for equivalence classes w.r.t. input variable 0

Relation(1, {{A2}, {A1, A3}})

for equivalence classes w.r.t. input variable 1

Relation(2, {{A1, A2, A3}})

for equivalence classes w.r.t. input variable 2

Relation(3, {{A2}, {A1}, {A3}})

for equivalence classes w.r.t. input variable 3

Parameters:
  • rules – A set of rules.

  • rough_compatibility – Whether to create the necessary data for rough set compatibility within PySoft.

  • in (Disabling this feature with False may improve the speed) – which rules are added to the KnowledgeBase.

Returns:

A set of rule names created, a dictionary for compatibility with PySoft’s rough set theory, and a set of edges required for that compatibility.

soft.fuzzy.logic.rules.creation.wang_mendel module

Functions related to the fuzzy logic rule creation process outlined in the Wang-Mendel Method.

soft.fuzzy.logic.rules.creation.wang_mendel.wang_mendel_method(dataset: SupervisedDataset, linguistic_variables: LinguisticVariables) Set[Rule]

The Wang-Mendel Method for fuzzy logic rule generation.

Parameters:
  • dataset – The dataset.

  • linguistic_variables – The linguistic variables involved and their terms.

Returns:

A set of Rule objects.

soft.fuzzy.logic.rules.creation.wang_mendel.wang_mendel_method_helper(consequence, consequence_resolution, consequences, offset: int = 0) None

A helper method for the Wang-Mendel Method. Given the consequence, consequence resolution, and consequences, assist in generating the consequence of the current fuzzy logic rule.

Parameters:
  • consequence

  • consequence_resolution

  • consequences

  • offset – The offset to apply to the output variable indices. Default is zero. For example, if the input variables are [0, 1, 2] and the output variables are [3, 4, 5], then the offset should be 3.

Returns:

None

Module contents

Various code related to the creation of fuzzy logic rules (e.g., Wang-Mendel Method, Latent Lockstep Method).