设置“闪亮”中的关联规则

问题描述

我正在尝试构建一个数据挖掘应用程序,该应用程序允许用户通过下拉列表指定应提供的支持和信心,以及通过支持,信心和提升来按顺序进行排序的选项。

我希望允许用户通过单独的自由文本框指定先行条件和结果。

这种子设置是在生成规则后执行的:

    library("arules")
    data("Adult")
    ## mine rules
    rules <- apriori(Adult,parameter = list(support = 0.3))
    
    subset(rules,subset = rhs %pin% "marital-status=")

我的处理过程是,如果文本字段为空,则从apriori算法返回所有规则,否则,如果文本字段不为空,则使用文本对规则进行子集化。我尝试使用if_else实现此功能,但出现以下错误

    object of type 'S4' is not subsettable

我的代码如下:

library(shiny)

# Define UI for application that computes association rules
ui <- fluidPage(

    # Application title
    titlePanel("Association Rules"),# Sidebar with drop down options for confidence,support and lift 
    sidebarLayout(
        sidebarPanel(
            selectInput("sup","Select the support value",choices = supportLevels),selectInput("conf","Select the confidence",choices = confidenceLevels),selectInput("order","Sorting Criteria",choices = c("support","confidence","lift")),width = 2,textInput("antecedent","Enter an antecedent",placeholder = "e.g. HUMALOG")
        ),mainPanel(
            verbatimtextoutput("mba"),width = 10
        )
    )
)

# Define server logic to mine frequent rules
server <- function(input,output) {
    output$mba <- renderPrint({
        rules <- apriori(transactions,parameter = list(support = as.numeric(input$sup),confidence = as.numeric(input$conf),minlen = 2,target = "rules"))
        inspect(sort(if_else(is.null(input$antecedent),rules,subset(rules,subset = lhs %pin% input$antecedent)),by = input$order))
        
    })
    }


# Run the application 
shinyApp(ui = ui,server = server)

有人可以帮助我如何在Shiny中将规则子集化,以便用户可以过滤出感兴趣的产品吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)