Skip to contents

fsi_eval() evaluates a point inference query. Considering an FSI model, it answers the following question: what is the inferred value for a given single point location?

Usage

fsi_eval(fsi, point, ...)

Arguments

fsi

An FSI model built with the fsi_create() and populated by fsi_add_fsa(), fsi_add_cs(), and fsi_add_rules().

point

An sfg object of the type POINT.

...

<dynamic-dots> Informs the fsi_eval how the elements of the resulting fuzzy set should be discretized if the user does not want the default configuration (see below). Default values: discret_by is 0.5 and discret_length is NULL.

Value

A numeric value that belongs to the domain of the consequent of the FSI model and represents the result of a point inference query

Details

The fsi_eval() function evaluates a point inference query by using an FSI model populated with its fuzzy spatial antecedent, consequent, and fuzzy rules set. This evaluation is based on the algorithm specified by the references below.

The default behavior of fsi_eval() in the parameter ... is to consider a discrete interval of values with an increment of 0.5 between lower and upper values for the consequent domain (i.e., defined by fsi_add_cs() with the parameter bounds).

The user can modify the default behavior by using one of the following two ways:

  • define a value for the parameter discret_by by changing the incremental value.

  • define a desired length for the sequence of values domain of the consequent by using the parameter discret_length.

Examples

library(sf)

# Creating the FSI model from an example
fsi <- visitation()

# Creating a vector of fuzzy rules
## note that we make use of the linguistic variables and linguistic values previously defined
rules <- c(
 "IF accommodation review is reasonable AND 
    food safety is low 
  THEN visiting experience is awful",
 "IF accommodation price is expensive AND 
    accommodation review is reasonable 
  THEN visiting experience is awful",
 "IF accommodation price is affordable AND 
    accommodation review is good AND 
    food safety is medium 
  THEN visiting experience is average",
 "IF accommodation price is affordable AND 
    accommodation review is excellent AND 
    food safety is high 
  THEN visiting experience is great",
 "IF accommodation price is cut-rate AND 
    accommodation review is excellent AND 
    food safety is high 
  THEN visiting experience is great")

# Adding these rules to the FSI model previously instantiated
fsi <- fsi_add_rules(fsi, rules)

# Evaluating a point inference query
fsi_eval(fsi, st_point(c(-74.0, 40.7)))
#> [1] 50
# \dontrun{
# Changing the default discretization
fsi_eval(fsi, st_point(c(-74.0, 40.7)), discret_by = 0.8)
#> [1] 50
fsi_eval(fsi, st_point(c(-74.0, 40.7)), discret_length = 200)
#> [1] 50
# }