DexiTabularFunction-class {DEXiR} | R Documentation |
DexiTabularFunction
Description
DexiTabularFunction
is a RC class, derived from DexiFunction.
Functions of this type aggregate attribute values according to decision rules,
defined in terms of a decision table.
Details
A decision table contains as many decision rules as there are possible combinations of
input attributes' values. For instance, if some attribute
has two inputs whose
discrete scales have three and four values, respectively (i.e., attribute$dim() == c(3,4)
),
then the number of rules is equal to prod(attribute$dim()) == 12
. Each rule defines the
value of attribute
for one of the possible combinations of values of attribute$inputs
.
Thus, a decision table can be interpreted as a lookup table that, given a vector
of values of attribute$inputs
(i.e., function arguments) returns the corresponding
attribute
value.
Objects of class DexiTabularFunction
store decision rules in values
, a multi-dimensional
list that contains rule values. In most cases, a rule value is a single integer,
representing an ordinal number of some value from attribute$scale
. In a general case, however,
a rule value can be an integer vector, representing a (sub)set of values from attribute$scale
.
Fields
attribute
DexiAttribute. The attribute this function is associated with. Both the attribute and its inputs are required to be discrete (i.e., associated with
DexiDiscreteScale
s).values
A multi-dimensional list of rule values. The dimensions of the list are equal to
attribute$dim()
, and the length of the list isnvals() == prod(dim)
. The list contains rule values that are in general value sets, i.e., integer vectors of value indices w.r.t.attribute$scale
.args
A list of integer vectors, containing all possible combinations of values of
attribute$inputs
.args
andvalues
are of the same length and ordered so that, for eachi
,args[[i]]
defines function arguments that map tovalues[[i]]
).
Methods
evaluate(x)
A silent wrapper around
value(x)
; it returnsNULL
whenvalue(x)
fails with an error.nargs()
Return the number of function arguments.
nvals()
Return the function size (number of rules).
to_string()
Return a short informative string about the size and dimensions of
values
.value(x)
Return the function value for arguments
x
, where arguments are a numeric vector of length equal toatt$inputs
. Additionally, arguments of aDexiTabularFunctions$value()
must be integer numbers, and the argument ofDexiDiscretizeFunctions$value()
must be a single number.verify()
Check the correctnes of this function object and its fields. Result:
error()
orTRUE
.
See Also
dexi_index()
, dexi_table()
, make_args()
Examples
# Load "Car.dxi"
CarDxi <- system.file("extdata", "Car.dxi", package = "DEXiR")
Car <- read_dexi(CarDxi)
# For example, consider the function of attribute CAR
fnc <- Car$attrib("CAR")$funct
# Print fields and basic properties of fnc
fnc$verify()
att_names(fnc$attribute)
fnc$values
fnc$args
fnc$nargs()
fnc$nvals()
fnc$to_string()
# Try some args to value mappings
fnc$evaluate(c(1, 1))
fnc$evaluate(c(2, 2))
fnc$evaluate(c(3, 4))
fnc$evaluate(c(4, 4)) # the first argument is out of bounds, returns NULL