library(frbs) ## 1. Preparing data: ## In this example, we use the gas furnace dataset included in the frbs package. ## Therefore, we only need to load it. data(frbsData) data.train <- frbsData$GasFurnance.dt[1 : 204, ] data.fit <- data.train[, 1 : 2] data.tst <- frbsData$GasFurnance.dt[205 : 292, 1 : 2] real.val <- matrix(frbsData$GasFurnance.dt[205 : 292, 3], ncol = 1) range.data <- matrix(c(-2.716, 2.834, 45.6, 60.5, 45.6, 60.5), nrow = 2) ## 2. Constructing an FRBS model: ## Set the method and its parameters. See the frbs manual for more detail. method.type <- "WM" control <- list(num.labels = 3, type.mf = "GAUSSIAN", type.defuz = "WAM", type.tnorm = "MIN", type.implication.func = "ZADEH", name = "sim-0") ## Generate fuzzy model object <- frbs.learn(data.train, range.data, method.type, control) ## 3. Exporting the model to PMML format: ## In this step, we provide two ways as follows. ## a. by calling frbsPMML() function directly. objPMML <- frbsPMML(object) ## b. by calling write.frbsPMML() function. the result will be saved as a file ## in the working directory. write.frbsPMML(objPMML, file = "MAMDANI.GasFur") ## 4. Importing the frbsPMML format to an FRBS model: ## There are two ways: using frbs and frbsJpmml. ## If we want to import frbsPMML format using frbs, we execute the following command in the R environment. ## In case of frbsJpmml, we import and predict at the same time. It will be explained on step 5. object <- read.frbsPMML("MAMDANI.GasFur.frbsPMML") ## 5. Prediction over data: ## a. Using frbs: res.test <- predict(object, data.tst) ## b. Using frbsJpmml: ## It should be noted that the following command is executed on command prompt, and GasFur.tst.txt is a file containing testing data. See the file. java -jar frbsJpmml.jar "MAMDANI.GasFur.frbsPMML" "GasFur.tst.txt"