Skip to contents

Given a data frame or a matrix of truth values of predicates, compute truth values of given vector of conditions.

Usage

fire(x, condition, t_norm = "goguen")

Arguments

x

a matrix or data frame. The matrix must be numeric (double) or logical. If x is a data frame then each column must be either numeric (double) or logical.

condition

a character vector of conditions, each element as formatted by format_condition(). E.g., "{p1,p2,p3}" is a condition with three predicates "p1", "p2", and "p3". All predicates present in the condition must exist as column names in x.

t_norm

a t-norm used to compute conjunction of weights. It must be one of "goedel" (minimum t-norm), "goguen" (product t-norm), or "lukas" (Lukasiewicz t-norm).

Value

A numeric matrix with values from the interval \([0,1]\) indicating the truth values. The resulting matrix has nrow(x) rows and length(condition) columns. That is, a value on i-th row and j-th column corresponds to a truth value of j-th condition evaluated at i-th data row.

Details

Each element of condition is a character string of the format "{p1,p2,p3}", where "p1", "p2", and "p3" are predicates. Data x must contain columns whose names correspond to all predicates used in conditions. Each condition is evaluated on all data rows as an elementary conjunction, where the conjunction operation is specified by the t_norm argument. An empty condition, {}, is always evaluated as 1.

Author

Michal Burda

Examples

d <- data.frame(a = c(  1, 0.8, 0.5, 0.2,   0),
                b = c(0.5,   1, 0.5,   0,   1),
                c = c(0.9, 0.9, 0.1, 0.8, 0.7))
fire(d, c("{a,c}", "{}", "{a,b,c}"))
#>      [,1] [,2]  [,3]
#> [1,] 0.90    1 0.450
#> [2,] 0.72    1 0.720
#> [3,] 0.05    1 0.025
#> [4,] 0.16    1 0.000
#> [5,] 0.00    1 0.000