knitr::opts_chunk$set( collapse = TRUE, comment = "#>" ) options(width = 180)
This vignette illustrates the design of a Data Fusion system using the GeoFIS R package.
See Data fusion documentation for more details about concepts of data fusion.
The example is an agronomic case study detailed in "A fuzzy logic based soil chemical quality index for cacao" [@denys20].
library(GeoFIS)
The data fusion process accepts input dataset of class data.frame or Spatial*DataFrame of the sp R package.
Only the numeric attributes of the dataset can be used.
In this example we use the tolima dataset available in the GeoFIS R package [@denys20]:
data(tolima) fusion <- NewFusion(tolima)
The aggregation system is built as a tree, based on the data.tree R package.
Each aggregation node can also be used as an input for another aggregation step, yielding a hierarchical structure.
The goal of this step is to turn raw data of individual information sources into satisfaction degrees.
The NewFusionInput function that builds an input leaf for the aggregation system takes 3 parameters:
NewMfTrapezoidalInf: low values are preferred.NewMfTrapezoidalSup: high values are preferred.NewMfTrapezoidal: around an interval.NewMfTriangular: about a value.The goal of this step is to summarize the inputs satisfaction degrees into a single one through an aggregation operator.
The NewFusionAggreg function that builds the aggregation node takes several parameters:
In the GeoFIS R package, 4 aggregation operators are implemented:
NewAggregWam build a WAM operator with the specified weights.NewAggregOwa build an OWA operator with the specified weights.NewAggregFis build a linguistic rule-based operator based on a Fuzzy Inference System (Fis), a Fis object of FisPro R package.
The Fis can be built with the FisPro software or with the NewFisFusion function.
The NewFisFusion function helps to generate a Fis and take 5 parameters:
FisOutCrisp output will be added to the Fis.FisOutFuzzy output will be added to the Fis.NewAggregFunction build an operator based on a function.
The function must accepts a numeric vector as parameter, e.g. mean function or user-defined function.
In this application example [@denys20], we build a hierarchical system with 8 inputs, 2 rule-based aggregation nodes and 1 WAM node.
The inputs:
potassium <- NewFusionInput("K", NewMfTrapezoidalSup(0.2, 0.6)) phosphorus <- NewFusionInput("P", NewMfTrapezoidalSup(5, 15)) balance_gap <- NewFusionInput("Bal_Gap", NewMfTrapezoidalInf(0, 0.5), "BalanceGap") n_gap <- NewFusionInput("N_Gap", NewMfTriangular(0.5, 1, 1.5), "Ngap_N_OpN") base_sat <- NewFusionInput("Base_Sat", NewMfTrapezoidalSup(0.4, 0.6), "Base_S") org_matter <- NewFusionInput("OM", NewMfTrapezoidalSup(3, 5)) ph <- NewFusionInput("pH", NewMfTrapezoidal(5, 5.5, 6.5, 7.5)) cadmium <- NewFusionInput("Cd", NewMfTrapezoidalInf(0, 0.43), "Cadmium")
The Macronutrients rulebase:
macronutrients_fis <- NewFisFusion( "MacN", # Fis name c("Bal_Gap", "K", "P", "N_Gap", "Base_Sat"), # Fis inputs names c(2, 2, 2, 2, 2), # Fis inputs granularities "MacN", # Fis output name c( 0, 0.1, 0.15, 0.2, 0.25, 0.35, 0.4, 0.45, 0.3, 0.4, 0.45, 0.5, 0.55, 0.65, 0.7, 0.75, 0.4, 0.3, 0.4, 0.45, 0.5, 0.55, 0.65, 0.7, 0.55, 0.6, 0.7, 0.75, 0.8, 0.85, 0.9, 1 ) # Fis conclusions )
Print the Macronutrients rulebase:
print(macronutrients_fis)
The Macronutrients aggregation node:
macronutrients_aggreg <- NewFusionAggreg( "MacN", NewAggregFis(macronutrients_fis), balance_gap, potassium, phosphorus, n_gap, base_sat )
The Soil Nutritional Balance rulebase:
nutri_balance_fis <- NewFisFusion( "Nutri_Bal", # Fis name c("pH", "OM", "MacN"), # Fis inputs names c(2, 2, 2), # Fis inputs granularities "Nutri_Bal", # Fis output name c(0, 0.2, 0.3, 0.5, 0.4, 0.6, 0.7, 1.0) # Fis conclusions )
Print the Macronutrients rulebase:
print(nutri_balance_fis)
The Soil Nutritional aggregation node:
nutri_balance_aggreg <- NewFusionAggreg( "Nutri_Bal", NewAggregFis(nutri_balance_fis), ph, org_matter, macronutrients_aggreg )
The Chemical aggregation node:
chemical_aggreg <- NewFusionAggreg( "Chemical", NewAggregWam(weights = c(0.3, 0.7)), cadmium, nutri_balance_aggreg )
Print the Chemical aggregation tree with aggregation operators and input leafs:
print(chemical_aggreg, "aggreg", "mf")
Use the chemical_aggreg as the root node of the Data Fusion system:
fusion$aggregate <- chemical_aggreg
Perform the Data Fusion process and read output:
fusion$perform() output <- fusion$output()
The output data frame contains all satisfaction degrees of inputs leafs, the aggregation value of all nodes, defined into the aggregation system.
print(output, digits = 2)
To model the decision maker preferences, the parameters of the aggregation operator can be learned from data. The user must in this case provide an additional target, for each sample.
The rule conclusions of a FIS operator can be optimized using the FisPro software, the reader may refer to the specific documentation Learning with FisPro.
The weights of the WAM and the OWA can be learned using a least square minimization procedure under two constraints for the weights: they must be positive and their sum should be 1. The process is illustrated using a toy example, the fusion_cars dataset, but it was also applied to the previously mentioned tolima dataset [@denys20].
The fusion_cars data include four cars (from 1 to 4) described by four attributes:
The $\textit{ideal}$ vehicle should minimize A and C while maximizing V and S. The dataset is as follows:
data(fusion_cars) print(fusion_cars)
To turn the raw data into preference degrees, the following transformation data are used:
a <- NewFusionInput("µA", NewMfTrapezoidalInf(4, 20), "A") v <- NewFusionInput("µV", NewMfTrapezoidalSup(100, 500), "V") s <- NewFusionInput("µS", NewMfTrapezoidalSup(120, 220), "S") c <- NewFusionInput("µC", NewMfTrapezoidalInf(6, 16), "C")
This yields the following degrees:
fusion <- NewFusion(fusion_cars) fusion$aggregate <- list(a, v, s, c) fusion$perform() degrees <- fusion$output() print(degrees)
The first vehicle, which represents a good trade-off, is preferred to the others. This preference can modeled by any target with the highest value in the first location, for example:
target <- c(0.8, 0.6, 0.6, 0.6)
or by the binary following one, that is used in this example:
target <- c(1, 0, 0, 0)
The WAM learning gives the following results:
wam_weights <- LearnWamWeights(degrees, target) print(wam_weights)
with inferred values:
wam_aggreg <- NewFusionAggreg("wam", NewAggregWam(wam_weights), a, v, s, c) fusion$aggregate <- wam_aggreg fusion$perform() wam_inferred <- fusion$output()["wam"] print(wam_inferred)
The result is not the expected one, the car ‘4’ has the highest score, the preferred car ‘1’ is ranked second: the WAM operator is not able to model the compromise
The OWA learning gives the following results:
owa_weights <- LearnOwaWeights(degrees, target) print(owa_weights)
In this toy example, the OWA aggregator returns the minimum: the whole weight is put on the smallest degree. This ensures that the decision maker preference is accurately modeled:
owa_aggreg <- NewFusionAggreg("owa", NewAggregOwa(owa_weights), a, v, s, c) fusion$aggregate <- owa_aggreg fusion$perform() owa_inferred <- fusion$output()["owa"] print(owa_inferred)
nocite: | @gistam20, @agriculture8060073 ...
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.