# --- SEARCHING FOR RULES ---
# split data into training and testing set
testing <- CO2[1:5, ]
training <- CO2[-1 * 1:5, ]
# custom context of the RHS variable
uptakeContext <- c(7, 28.3, 46)
# convert training data into fuzzy sets
d <- lcut3(training, context=list(uptake=uptakeContext))
# search for rules
r <- searchrules(d, lhs=1:38, rhs=39:58)
# --- PBLD INFERENCE WITH FOUND RULES ---
# convert testing data info fuzzy sets
x <- lcut3(testing, context=list(uptake=uptakeContext))
# prepare values and partition
v <- slices(uptakeContext[1], uptakeContext[3], 1000)
p <- lcut3(v, name='uptake', context=uptakeContext)
# do the inference
pbld(x, r, p, v)
# --- FRBE TIME-SERIES FORECASTING ---
# prepare data (from the forecast package)
library(forecast)
horizon <- 10
train <- wineind[-1 * (length(wineind)-horizon+1):length(wineind)]
test <- wineind[(length(wineind)-horizon+1):length(wineind)]
# compute forecast
f <- frbe(as.ts(train), h=horizon)
# display the forecast
f$mean
# evaluate the results
evalfrbe(f, test)
Run the code above in your browser using DataLab