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)))
if (FALSE) {
# Changing the default discretization
fsi_eval(fsi, st_point(c(-74.0, 40.7)), discret_by = 0.8)
fsi_eval(fsi, st_point(c(-74.0, 40.7)), discret_length = 200)
}
Run the code above in your browser using DataLab