Есть некоторые проблемы в «правилах» ОП
library(sets)
as.list(rules)
#[[1]]
#temperature %is% hot && precipitations %is% little.rain => weather %is% ok
#[[2]]
#Error in format.default(x$consequent) :
# Found no format() method for class "name"
По сути, третье правило не имеет значения
...
fuzzy_rule(temperature %is% cold && weather %is% bad), ###
...
Другая проблема - созданные «переменные» с fuzzy_cone
'радиусом', не перекрывающимся при создании набора NULL
variables
#{weather = (bad = {}, ok = {}, perfect = {}), humidity = (dry = <<gset(201)>>, good = <<gset(201)>>, wet = <<gset(201)>>),
#temperature = (cold = <<gset(201)>>, good = <<gset(201)>>, hot = <<gset(201)>>), precipitations = (no.rain = <<gset(201)>>,
#little.rain = <<gset(201)>>, rain = <<gset(201)>>)}
Если мы сделаем необходимые изменения, это будет работать
variables<-set(
temperature=
fuzzy_partition(varnames=
c(cold=30, good=70, hot=90),
sd=5),
humidity=
fuzzy_partition(varnames=
c(dry=30, good=60, wet=80),
sd=3),
precipitations=
fuzzy_partition(varnames=
c(no.rain=30, little.rain =60, rain=90), sd=7.5),
weather=fuzzy_partition(varnames=c(bad=40, ok=65, perfect=80), FUN=fuzzy_cone,
radius=75)
)
rules<-set(
fuzzy_rule(temperature %is% good && humidity %is% dry && precipitations %is% no.rain ,
weather %is% perfect),
fuzzy_rule(temperature %is% hot && humidity %is% wet && precipitations %is% rain,
weather %is% bad),
fuzzy_rule(temperature %is% cold,
weather %is% bad),
fuzzy_rule(temperature %is% good || humidity %is% good || precipitations %is% little.rain,
weather %is% ok),
fuzzy_rule(temperature %is% hot && precipitations %is% little.rain,
weather %is% ok),
fuzzy_rule(temperature %is% hot && humidity %is% dry && precipitations %is% little.rain,
weather %is% ok))
- проверьте правила
as.list(rules)
#[[1]]
#temperature %is% hot && precipitations %is% little.rain => weather %is% ok
#[[2]]
#temperature %is% hot && humidity %is% dry && precipitations %is% => weather %is% ok
# little.rain => weather %is% ok
#[[3]]
#temperature %is% hot && humidity %is% wet && precipitations %is% => weather %is% bad
# rain => weather %is% bad
#[[4]]
#temperature %is% good && humidity %is% dry && precipitations %is% => weather %is% perfect
# no.rain => weather %is% perfect
#[[5]]
#temperature %is% good || humidity %is% good || precipitations %is% => weather %is% ok
# little.rain => weather %is% ok
#[[6]]
#temperature %is% cold => weather %is% bad
сборка fuzzy_system
model <- fuzzy_system(variables, rules)
example <- fuzzy_inference(model,list(temperature=65,
humidity=0, precipitations=80))