Logic explanation metrics¶
- torch_explain.logic.metrics.complexity(formula: str, to_dnf: bool = False) → float¶
Estimates the complexity of the formula.
- Parameters
formula – logic formula.
to_dnf – whether to convert the formula in disjunctive normal form.
- Returns
The complexity of the formula.
- torch_explain.logic.metrics.concept_consistency(formula_list: List[str]) → dict¶
Computes the frequency of concepts in a list of logic formulas.
- Parameters
formula_list – list of logic formulas.
- Returns
Frequency of concepts.
- torch_explain.logic.metrics.formula_consistency(formula_list: List[str]) → float¶
Computes the average frequency of concepts in a list of logic formulas.
- Parameters
formula_list – list of logic formulas.
- Returns
Average frequency of concepts.
- torch_explain.logic.metrics.test_explanation(formula: str, x: torch.Tensor, y: torch.Tensor, target_class: int)¶
Tests a logic formula.
- Parameters
formula – logic formula
x – input data
y – input labels (MUST be one-hot encoded)
target_class – target class
- Returns
Accuracy of the explanation and predictions