Skip to content

Commit

Permalink
renamed shiny_arules to ruleExplorer. Some fixes and new release.
Browse files Browse the repository at this point in the history
  • Loading branch information
mhahsler committed Apr 24, 2018
1 parent 4d79028 commit 4b9aa69
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 34 deletions.
3 changes: 2 additions & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@ proj$
^LICENSE
^README/
^Work/
_pkgdown
^_pkgdown\.yml
^_config\.yml
^docs/
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: arulesViz
Version: 1.3-0.2
Date: 2018-xx-xx
Version: 1.3-1
Date: 2018-04-23
Title: Visualizing Association Rules and Frequent Itemsets
Authors@R: c(person("Michael", "Hahsler", role = c("aut", "cre", "cph"),
email = "[email protected]"),
Expand Down
8 changes: 5 additions & 3 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export("inspectDT")
S3method(inspectDT, rules)
S3method(inspectDT, itemsets)

export("shiny_arules")
export("plotly_arules")
export("saveAsGraph")
export("ruleExplorer")
export("saveAsGraph")

## Deprecated
export("plotly_arules")
7 changes: 5 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# arulesViz 1.3-0.1 (xx/xx/2018)
# arulesViz 1.3-1 (04/23/2018)

## New features
* ruleExplorer: interactive visualization with shiny was added.
* plot method matrix now supports different reordering methods: 'none',
'measure', 'support/confidence', 'similarity'. Default is measure,
the measure for used for shading.
* measure and shading now auto-completes measure names.
* interactive visualization with arules_shiny was added.

## Changes
* plotly_arules is deprecated use plot with engine = "plotly" instead

## Bug Fix
* Fixed problem with quality measures (offset of 1) when creating igraph
Expand Down
14 changes: 11 additions & 3 deletions R/plotly.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,22 @@

# plotly interactive plots using d3.js

#plot <- function(x, method = NULL, measure = "support",
# shading = "lift", interactive = FALSE, data = NULL, control = NULL, ...) {


plotly_arules <- function(x, method = "scatterplot",
measure = c("support", "confidence"), shading = "lift",
max = 1000, ...) {

.Deprecated("plot")

.plotly_arules(x, method,
measure, shading,
1000, ...)
}

.plotly_arules <- function(x, method = "scatterplot",
measure = c("support", "confidence"), shading = "lift",
max = 1000, ...) {

if(!is(x, "associations")) stop("x has to be a set of rules.")

methods <- c("scatterplot", "two-key plot", "matrix")
Expand Down
24 changes: 12 additions & 12 deletions R/shiny.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# https://github.com/brooksandrew/Rsenal
#

shiny_arules <- function(x, parameter = NULL) {
ruleExplorer <- function(x, parameter = NULL) {

if (!requireNamespace("shiny", quietly = TRUE)) {
stop("Package shiny is required to run this method.", call. = FALSE)
Expand Down Expand Up @@ -86,19 +86,19 @@ shiny_arules <- function(x, parameter = NULL) {
shiny::uiOutput("yAxisSelectInput"),
shiny::uiOutput("cAxisSelectInput"),
shiny::br(),
shiny::sliderInput("supp", "Support:", min = minSupp, max = maxSupp, value = supp , step = (maxSupp-minSupp)/1000, sep =""),
shiny::sliderInput("conf", "Confidence:", min = minConf, max = maxConf, value = conf , step = (maxConf-minConf)/1000, sep = ""),
shiny::sliderInput("lift", "Lift:", min = minLift, max = maxLift, value = lift , step = (maxLift-minLift)/1000, sep = ""),
shiny::sliderInput("supp", "Minimum Support:", min = minSupp, max = maxSupp, value = supp , step = (maxSupp-minSupp)/1000, sep =""),
shiny::sliderInput("conf", "Minimum Confidence:", min = minConf, max = maxConf, value = conf , step = (maxConf-minConf)/1000, sep = ""),
shiny::sliderInput("lift", "Minimum Lift:", min = minLift, max = maxLift, value = lift , step = (maxLift-minLift)/1000, sep = ""),
shiny::numericInput("minL", "Min. items in rule:", 2),
shiny::numericInput("maxL", "Max. items in rule:", 10),
shiny::br(),
shiny::HTML('<b>Filter items</b>'),
shiny::HTML('<b>Filter rules by items:</b>'),
shiny::br(),
shiny::selectInput('colsType',NULL,c('Remove rules including:'='rem','Require rules to include:'='req')),
shiny::selectInput('colsType',NULL,c('Exclude items:'='rem','Require items:'='req')),
shiny::uiOutput("choose_columns"),
shiny::selectInput('colsLHSType',NULL,c('Remove rules with LHS including:'='rem','Require rules to have LHS include:'='req')),
shiny::selectInput('colsLHSType',NULL,c('Exclude items from LHS:'='rem','Require items in LHS:'='req')),
shiny::uiOutput("choose_lhs"),
shiny::selectInput('colsRHSType',NULL,c('Remove rules with RHS including:'='rem','Require rules to have RHS include:'='req')),
shiny::selectInput('colsRHSType',NULL,c('Exclude items from RHS:'='rem','Require items in RHS:'='req')),
shiny::uiOutput("choose_rhs"),
shiny::br(),
shiny::downloadButton('rules.csv', 'Download Rules as CSV')
Expand Down Expand Up @@ -236,7 +236,7 @@ shiny_arules <- function(x, parameter = NULL) {

if(is(dataset, 'transactions')) {

# cat("input supp: ", input$supp, "\n")
# cat("input supp: ", input$supp, "\n")
# cat("cached supp: ", cachedSupp, "\n")
# cat("abs supp: ", input$supp*length(dataset), "\n")
# cat("override: ", override(), "\n")
Expand Down Expand Up @@ -268,7 +268,7 @@ shiny_arules <- function(x, parameter = NULL) {

if(input$conf > cachedConf) {
### FIXME: R CMD check complains about:
### shiny_arules : <anonymous>: no visible binding for global variable confidence
### shiny_arules : <anonymous>: no visible binding for global variable 'confidence'
#ar <- subset(ar, subset = quality(ar)$confidence > input$conf)
ar <- subset(ar, subset = quality(ar)$confidence > input$conf)
}
Expand Down Expand Up @@ -372,7 +372,7 @@ shiny_arules <- function(x, parameter = NULL) {
shiny::req(input$xAxis, input$yAxis, input$cAxis)
handleErrors()

plotly_arules(rules(), method = 'scatterplot',
.plotly_arules(rules(), method = 'scatterplot',
measure=c(input$xAxis, input$yAxis), shading = input$cAxis)
})

Expand All @@ -389,7 +389,7 @@ shiny_arules <- function(x, parameter = NULL) {
output$matrixPlot <- renderPlotly({
handleErrors()

plotly_arules(rules(), method='matrix', shading=input$cAxis)
.plotly_arules(rules(), method='matrix', shading=input$cAxis)
})

## Rules Data Table ##########################
Expand Down
2 changes: 2 additions & 0 deletions man/plotly_arules.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
\title{Interactive Scatter Plot for Association Rules using plotly}
\description{
Plot an interactive scatter plot for association rules using \pkg{plotly}.
This function is \bold{deprecated}. Use \code{\link{plot}} with parameter
\code{engine = "plotly"} instead.
}
\usage{
plotly_arules(x, method = "scatterplot", measure = c("support", "confidence"),
Expand Down
23 changes: 12 additions & 11 deletions man/shiny.Rd
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
\name{shiny}
\name{ruleExplorer}
\Rdversion{1.1}
\alias{shiny_arules}
\title{Visualize Association Rules and Itemsets with Shiny}
\alias{ruleExplorer}
\alias{explore}
\title{Explore Association Rules Interactively}
\description{
Visualize assocation rules and itemsets using \pkg{shiny}.
Explore assocation rules using interactive manipulations and visualization using \pkg{shiny}.
}
\usage{
shiny_arules(x, parameter)
ruleExplorer(x, parameter = NULL)
}
\arguments{
\item{x}{ a set of rules, a transactions object or a data.frame. }
\item{parameter}{a list with parameters passed on to \code{\link[arules]{apriori}}.
the list can be used to set the initial support and confidence, etc.
Values are ignored if \code{x} contains rules.}
the list can be used to set the initial support and confidence thresholds.
Values are ignored if \code{x} contains a set of rules.}
}
%\details{}
%\value{}
Expand All @@ -27,13 +28,13 @@ See https://github.com/brooksandrew/Rsenal for the original code.
\dontrun{
data(Groceries)

# visualize pre-mined rules
# explore pre-mined rules
rules <- apriori(Groceries, parameter=list(support=0.001, confidence=0.8))
rules

shiny_arules(rules)
ruleExplorer(rules)

# mine and visualize rules on the fly
shiny_arules(Groceries)
# mine and explore rules on the fly
ruleExplorer(Groceries)
}
}

0 comments on commit 4b9aa69

Please sign in to comment.