2

I am very new to fuzzy toolkit in R. I have been trying to create fuzzy function as show in the image.

I am using this function do represent time as list of four variables

  1. Morning
  2. Noon
  3. Evening
  4. Midnight

For any given time all four variables have a specific value. For instance when time in 3:00 AM we would have Morning=0.5, Noon=0, Evening=0, Midnight=0.5

Also this is a cyclic membership function. the midnight variable wraps around 0:00 and 24:00

How could this be implemented in R using fuzzy toolkit. Thank you very much in advance.

image

  • 1
    you will need to clarify your question and describe what you've tried to get help. – Martin Serrano May 21 '14 at 17:29
  • Hello Martin, Thanks. I am building a neural network based system for time series prediction. I was searching for efficient way to denote time. When I stumbled upon a paper on Improving Airtemperature prediction using ANN. They use fuzzy based membership function which is set of 4 variables 1.Midnight 2.Morning 3. Noon 4. Evening. the values of these variables change depending on the time of day. So if I take 3:00 in the morning, I would have 1. Morning=0.5 2. Midnight=0.5 3. Noon=0 4. Evening=0 Also if you notice midnight variable wraps around 0:00 and 24:00 hours – Nithyakumaran May 21 '14 at 17:38
  • when you clarify a question you should update the original post rather than in a comment. fyi, i don't actually know anything about this topic, i'm just trying to help you with using stack overflow. – Martin Serrano May 21 '14 at 17:55

1 Answers1

0

I guess a start would be

FIS <- newFIS("daytest")
FIS <- addVar(FIS, "input", "daytime", 0:2400)
FIS <- addMF(FIS, "input", 1, triMF("Midnight", 0:2400, c(0,0,600,1)))
FIS <- addMF(FIS, "input", 1, triMF("Morning", 0:2400, c(0,600,1200,1)))
FIS <- addMF(FIS, "input", 1, triMF("Noon", 0:2400, c(600,1200,1800,1)))
FIS <- addMF(FIS, "input", 1, triMF("Evening", 0:2400, c(1200,1800,2400,1)))
FIS <- addMF(FIS, "input", 1, triMF("Mignight", 0:2400, c(1800,2400,2400,1)))


class(FIS)
plotMF(FIS, "input",1)

daytime FIS

The problem is that the documentation doesn't say anything explicitly about cyclic models, so it may be unlikely that it knows to wrap time around such that both midnights are the same. but by taking a peek at the object, it looks like you can somewwhat easily manipulate it such that you can make any shape you want. So i tried this

FIS$inputList[[1]]$membershipFunctionList[[1]]$mfVals <- 
    FIS$inputList[[1]]$membershipFunctionList[[1]]$mfVals+
    FIS$inputList[[1]]$membershipFunctionList[[5]]$mfVals
FIS$inputList[[1]]$membershipFunctionList[[1]]$mfType <- "wrapmf"
FIS$inputList[[1]]$membershipFunctionList[[5]]<-NULL

Here I manually combined the two midnight values, changed the "type" so it doesn't accidentally try to reset it at any point or make any wrong assumptions based on the fact it thinks it's triangular, and then removed the second midnight category. Not it produces this plot

cyclic FIS

You can see that the first and last peaks are now both red (and there is no separate label for the second one). Based on the limited amount i've read, that should work.

MrFlick
  • 195,160
  • 17
  • 277
  • 295