R_studio (association) performs Association Analysis on Data

Source: Internet
Author: User

 

 

Associate and analyze the data in the menu_orders.txt File

  

 

(1) make the support level 0.4 and the number of elements in the frequent item set greater than or equal to 2, view the changes in the number of association rules, and output the rules related to

# Import the arules package install. packages ("arules") Library (arules) setwd ('d: \ Data ') Gary <-read. transactions ("menu_orders.txt", format = "basket", SEP = ",") # set the number of elements in the frequent item set to be greater than or equal to 2 garysize <-size (Gary) gary_u <-Gary [garysize> 1] # view some rules inspect (gary_u) # support 0.4, confidence 0.5, output the rule gary_u = Apriori (gary_u, parameter = List (Support = 0.4, Confidence = 0.5) # gary_u = Apriori (gary_u, parameter = List (Support = 0.4, Confidence = 0.5 ), appearance = List (RHS = C ("A"), default = "LHS") # output the gary_u = subset (gary_u, items % pin % C ("A") # evaluate the required subset of association rules # view some rules inspect (gary_u)
Gary1.r

 

(2) filter out rules with LHS null

# Import the arules package install. packages ("arules") Library (arules) setwd ('d: \ Data ') Gary <-read. transactions ("menu_orders.txt", format = "basket", SEP = ",") # set the number of elements in the frequent item set to be greater than or equal to 2 garysize <-size (Gary) gary_u <-Gary [garysize> 1] # view some rules inspect (gary_u) # support 0.4, confidence 0.5, filter out rules gary_u = Apriori (gary_u, parameter = List (Support = 0.4, Confidence = 0.5, minlen = 2) # gary_u = Apriori (gary_u, parameter = List (Support = 0.4, Confidence = 0.5 ), appearance = List (RHS = C ("A"), default = "LHS") # view some rules inspect (gary_u)
Gary2.r

 

(3) filter out rules with a lifting degree less than 1

# Import the arules package install. packages ("arules") Library (arules) setwd ('d: \ Data ') Gary <-read. transactions ("menu_orders.txt", format = "basket", SEP = ",") # set the number of elements in the frequent item set to be greater than or equal to 2 garysize <-size (Gary) gary_u <-Gary [garysize> 1] # view some rules inspect (gary_u) # support 0.4, confidence 0.4 Gary _ u = Apriori (gary_u, parameter = List (Support =, confidence = 0.5) # gary_u = Apriori (gary_u, parameter = List (Support = 0.4, Confidence = 0.5), appearance = List (RHS = C ("A"), de Fault = "LHS") # filter out rules with an increase of less than 1. Gary_u <-subset (gary_u, lift> 1) # view some rules inspect (gary_u)
Gary3.r

 

(4) draw a diagram of the support level, confidence level, and improvement degree.

(Make up later ...)

 

(5) draw an association rule Diagram

(Make up later ...)

 

R_studio (association) performs Association Analysis on Data

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.