Hi, I am trying to use the fuzzy_inference system on multiple input values. Basically I combine two variables (depth, velocity) into the variable suitability. Both depth and velocity have 3 trapezoid classes (verylow,medium,high) each. The consequent (suitability) has 4 fuzzy levels (none,low,medium,high) and should finally range between 0 and 1. I already set up the level definitions (trapez-corners) and the rules (a combination of all depth-levels with all velocity-levels and the consequent suitability).
Now I wanted to test the system on a dataframe with dummy variables (in the range of values I will supply), but some how I get for some combinations of depth and velocity no resulting suitablilty. I provide here now some code (simpler than my actual) that produces also this NaN values: # Load "sets" library(sets) ## set universe sets_options("universe", seq(from = 0, to = 1, by = 0.001)) ## set up fuzzy variables variables <- set(depth = fuzzy_variable(verylow = fuzzy_trapezoid(corners = c(-3,0,0.2,0.5)), medium = fuzzy_trapezoid(corners =c(0.45,0.55,0.7,0.9)), veryhigh = fuzzy_trapezoid(corners = c(0.85,1,15,20))), velocity = fuzzy_variable(verylow = fuzzy_trapezoid(corners = c(-3,0,0.2,0.5)), medium = fuzzy_trapezoid(corners = c(0.35,0.55,0.65,0.8)), veryhigh = fuzzy_trapezoid(corners = c(0.7,0.9,15,20))), suitability = fuzzy_partition(varnames = c(none = 0.2, low = 0.4, medium = 0.6, high = 0.8),FUN = fuzzy_cone, radius = 0.15)) ## set up rules rules <- set( fuzzy_rule(depth %is% verylow && velocity %is% verylow, suitability %is% low), fuzzy_rule(depth %is% medium && velocity %is% verylow, suitability %is% medium), fuzzy_rule(depth %is% veryhigh && velocity %is% verylow, suitability %is% low), fuzzy_rule(depth %is% verylow && velocity %is% medium, suitability %is% medium), fuzzy_rule(depth %is% medium && velocity %is% medium, suitability %is% high), fuzzy_rule(depth %is% veryhigh && velocity %is% medium, suitability %is% medium), fuzzy_rule(depth %is% verylow && velocity %is% veryhigh, suitability %is% none), fuzzy_rule(depth %is% medium && velocity %is% veryhigh, suitability %is% low), fuzzy_rule(depth %is% veryhigh && velocity %is% veryhigh, suitability %is% none) ) ## combine to a system system <- fuzzy_system(variables, rules) print(system) plot(system) ## plots variables # test df test_df <- data.frame(depth=round(runif(20,0,2),2),velocity=round(runif(20,0,1.5),2),suitability=NA) # do inference on test_df fuzzy_result <- function(df){ gset_defuzzify(fuzzy_inference(system, list(depth = df["depth"], velocity = df["velocity"])),"centroid") } apply(test_df,1,fuzzy_result) Does anyone know what is happening there? /Johannes [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.