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)
# Defining the query window
pts_qw1 <- rbind(c(-73.92, 40.68527), c(-73.75, 40.68527),
c(-73.75, 40.75), c(-73.92, 40.75), c(-73.92, 40.68527))
qw1 <- st_polygon(list(pts_qw1))
# Recall that our running example is based on a small set of point datasets
# This means that inferred values will likely be the same
if (FALSE) {
# Example using the discretization method
fsi_qw_eval(fsi, qw1, approach = "discretization", target_lval = "great", k = 25)
# Example using the optimization method
fsi_qw_eval(fsi, qw1, approach = "pso", max_depth = 2)
}
Run the code above in your browser using DataLab