在闪亮的应用程序中输入值的模糊化

时间:2016-12-21 18:25:02

标签: r shiny fuzzy-logic

我试图模糊输入值,并通过解析闪亮应用获得输出。但我不知道如何从输入中获取这些值。

那么可以使用输入值对它们进行模糊化,然后对值进行解密并将此值作为输出吗?如果有,怎么样?感谢

以下是代码的概念:

    library(shiny)
    library(sets)
    library(datasets)
    ui <- fluidPage(numericInput(inputId = "one", label="Type number",1, min=1, max=120),
    numericInput(inputId = "two", label="Type number",1, min = 1, max=120),
    numericInput(inputId = "three", label="Type number",1, min = 1, max=120),
    numericInput(inputId = "four", label="Type number",1, min = 1, max=120),
    textOutput("sub"), br(),
    actionButton("button", "Show"),

    br()


    )
    server <- function(input, output){

    variables <- set(wo = fuzzy_partition(varnames = c(notMany2 = 15, enough2 = 25, many2 = 35),FUN = fuzzy_cone, radius = 10),
    top = fuzzy_partition(varnames = c(notMany3 = 20, enough3 =   50, many3 = 100),FUN = fuzzy_cone, radius = 25),
    c = fuzzy_partition(varnames = c(k4 = 52, k3 = 42, k2 = 32,k1 = 22), sd = 3))
    rules <- set (fuzzy_rule(wo %is% notMany2 && top %is% notMany3 
                       || wo %is% notMany2 && top %is% notMany3 
                       || wo %is% notMany2 && top %is% notMany3 
                       , c %is% k1),
    fuzzy_rule( wo %is% notMany2 && top %is% enough3 
                        || wo %is% notMany2 && top %is% many3,c %is% k2))
    system <- fuzzy_system(variables,rules)
    fi <- fuzzy_inference(system, list(wo = 20, top= 10))


    fuz <- gset_defuzzify(fi, 'centroid')

    output$sub <- renderText({fuz})


    }


    shinyApp(ui = ui, server = server)

0 个答案:

没有答案