soft.fuzzy.linguistic package

Submodules

soft.fuzzy.linguistic.summary module

Implements the linguistic summary code and its necessary supporting functions.

class soft.fuzzy.linguistic.summary.Query(term, index)

Bases: tuple

index

Alias for field number 1

term

Alias for field number 0

class soft.fuzzy.linguistic.summary.Summary(knowledge_base, quantifier, truth, weights=None)

Bases: object

The linguistic summary class; provides methods to create and evaluate linguistic summaries of data.

calculate_dimension_cardinality(input_data, number_of_attributes, number_of_observations, alpha)

Calculate the dimensions’ cardinality; used for degree of appropriateness and degree of imprecision.

Parameters:
  • input_data

  • number_of_attributes

  • number_of_observations

  • alpha

Returns:

degree_of_appropriateness(input_data, alpha=0.0, query=None)

Considered to be the most relevant degree of validity.

For example, if a database contained employees and 50% of them are less than 25 years old and 50% are highly qualified, then we might expect that 25% of the employees would be less than 25 years old and highly qualified; this would correspond to a typical, fully expected situation. However, if the degree of appropriateness is, say, 0.39 (i.e., 39% are less than 25 years old and highly qualified), then the summary found reflects an interesting, not fully expected relation in our data.

This degree describes how characteristic for the particular database the summary found is. It is very important because, for instance, a trivial summary like ‘100% of sales is of any articles’ has full validity (truth) if we use the traditional degree of truth but its degree of appropriateness is equal to 0 which is correct.

Parameters:
  • input_data (torch.Tensor) – A collection of data observations.

  • alpha – The minimum degree of membership required in both the summary and query.

  • query (namedtuple) – A given query that needs to be adhered to, such as the attribute

  • 'young'. (age must be)

Returns:

(torch.Tensor) A ratio between 0 and 1 that describes how interesting the relation described by the summary is.

degree_of_covering(input_data, alpha=0.0, query=None)

How many objects in the data set (database) corresponding to the query are ‘covered’ by the particular summary (i.e., self.summarizer). Its interpretation is simple. For example, if it is equal to 0.15, then this means that 15% of the objects are consistent with the summary in question.

Parameters:
  • input_data (torch.Tensor) – A collection of data observations.

  • alpha – The minimum degree of membership required

  • query. (in both the summary and)

  • query (namedtuple) – A given query that needs to be adhered to,

  • 'young'. (such as the attribute age must be)

Returns:

(torch.Tensor) A ratio between 0 and 1 that describes how many objects are covered by this summary.

degree_of_imprecision(input_data, alpha=0.0)

Calculate the degree of imprecision of the linguistic summary.

Parameters:
  • input_data

  • alpha

Returns:

degree_of_truth(input_data, query=None)

Calculate the degree of truth given the quantifier.

Parameters:
  • input_data

  • query

Returns:

degree_of_validity(input_data, alpha=0.0, query=None)

The total degree of validity for a particular linguistic summary is defined as the weighted average of the above five degrees of validity (e.g., degree_of_truth, degree_of_covering, degree_of_appropriateness, length).

Parameters:
  • input_data

  • alpha

  • query

Returns:

length()

The length of a summary, which is relevant because a long summary is not easily comprehensible by the human user. This length may be defined in various ways, but the following has proven to be useful.

Returns:

(torch.Tensor) A ratio between 0 and 1 that describes how short a summary is, where 1 means extremely short and 0 means extremely long.

overall_summary_membership(input_data, query=None)

Intermediate function in determining how well the summary describes the overall data.

Parameters:
  • input_data (torch.Tensor) – A collection of data observations.

  • query (namedtuple) – A given query that needs to be adhered to,

  • 'young'. (such as the attribute age must be)

Returns:

(torch.Tensor) How much the overall data satisfied the object’s summarizer.

summarizer_membership(input_data, query=None)

Calculate how well the summarizer in this class describes the given data observation, given an optional query that constrains the degree.

Parameters:
  • input_data (torch.Tensor) – Data observations.

  • query (namedtuple) – A given query that needs

  • to (to be adhered)

  • 'young'. (such as the attribute age must be)

Returns:

How well the summarizer in this class describes the given data observation, given an optional query that constrains the degree.

soft.fuzzy.linguistic.summary.make_inference_engine(knowledge_base: KnowledgeBase, t_norm: str) TSKInference

Make a minimal working minimum inference engine to accelerate the relevant calculations.

Parameters:
  • knowledge_base – soft.computing.knowledge.KnowledgeBase

  • t_norm – The t-norm to use for the inference engine.

Returns:

soft.fuzzy.logic.inference.engines.MinimumInference

soft.fuzzy.linguistic.summary.most_quantifier(element)

Zadeh’s A Computational Approach to Fuzzy Quantifiers in Natural Languages (1983).

Parameters:
  • element – How much an element, y, satisfied some property

  • set) ((fuzzy)

  • F

  • data. (across the entire)

Returns:

The truth of the linguistically quantified proposition.

Module contents