creating itemsets in apriori algorithm












0














I am reading about association analysis in book titled Machine learning in action. Following code is given in book




The k-2 thing may be a little confusing. Let’s look at that a little
further. When you were creating {0,1} {0,2}, {1,2} from {0}, {1}, {2},
you just combined items. Now, what if you want to use {0,1} {0,2},
{1,2} to create a three-item set? If you did the union of every set,
you’d get {0, 1, 2}, {0, 1, 2}, {0, 1, 2}. That’s right. It’s the same
set three times. Now you have to scan through the list of three-item
sets to get only unique values. You’re trying to keep the number of
times you go through the lists to a minimum. Now, if you compared the
first element {0,1} {0,2}, {1,2} and only took the union of those that
had the same first item, what would you have? {0, 1, 2} just one time.
Now you don’t have to go through the list looking for unique values.




def aprioriGen(Lk, k): #creates Ck
retList =
lenLk = len(Lk)
for i in range(lenLk):
for j in range(i+1, lenLk):
L1 = list(Lk[i])[:k-2]; L2 = list(Lk[j])[:k-2] # Join sets if first k-2 items are equal
L1.sort(); L2.sort()
if L1==L2:
retList.append(Lk[i] | Lk[j])
return retLis


Suppose i am calling above function



Lk = [frozenset({2, 3}), frozenset({3, 5}), frozenset({2, 5}), frozenset({1, 3})]

k = 3

aprioriGen(Lk,3)


I am geting following output



[frozenset({2, 3, 5})]


I think there is bug in above logic since we are missing other combinations like {1,2,3}, {1,3,5}. Isn't it? Is my understanding right?










share|improve this question



























    0














    I am reading about association analysis in book titled Machine learning in action. Following code is given in book




    The k-2 thing may be a little confusing. Let’s look at that a little
    further. When you were creating {0,1} {0,2}, {1,2} from {0}, {1}, {2},
    you just combined items. Now, what if you want to use {0,1} {0,2},
    {1,2} to create a three-item set? If you did the union of every set,
    you’d get {0, 1, 2}, {0, 1, 2}, {0, 1, 2}. That’s right. It’s the same
    set three times. Now you have to scan through the list of three-item
    sets to get only unique values. You’re trying to keep the number of
    times you go through the lists to a minimum. Now, if you compared the
    first element {0,1} {0,2}, {1,2} and only took the union of those that
    had the same first item, what would you have? {0, 1, 2} just one time.
    Now you don’t have to go through the list looking for unique values.




    def aprioriGen(Lk, k): #creates Ck
    retList =
    lenLk = len(Lk)
    for i in range(lenLk):
    for j in range(i+1, lenLk):
    L1 = list(Lk[i])[:k-2]; L2 = list(Lk[j])[:k-2] # Join sets if first k-2 items are equal
    L1.sort(); L2.sort()
    if L1==L2:
    retList.append(Lk[i] | Lk[j])
    return retLis


    Suppose i am calling above function



    Lk = [frozenset({2, 3}), frozenset({3, 5}), frozenset({2, 5}), frozenset({1, 3})]

    k = 3

    aprioriGen(Lk,3)


    I am geting following output



    [frozenset({2, 3, 5})]


    I think there is bug in above logic since we are missing other combinations like {1,2,3}, {1,3,5}. Isn't it? Is my understanding right?










    share|improve this question

























      0












      0








      0







      I am reading about association analysis in book titled Machine learning in action. Following code is given in book




      The k-2 thing may be a little confusing. Let’s look at that a little
      further. When you were creating {0,1} {0,2}, {1,2} from {0}, {1}, {2},
      you just combined items. Now, what if you want to use {0,1} {0,2},
      {1,2} to create a three-item set? If you did the union of every set,
      you’d get {0, 1, 2}, {0, 1, 2}, {0, 1, 2}. That’s right. It’s the same
      set three times. Now you have to scan through the list of three-item
      sets to get only unique values. You’re trying to keep the number of
      times you go through the lists to a minimum. Now, if you compared the
      first element {0,1} {0,2}, {1,2} and only took the union of those that
      had the same first item, what would you have? {0, 1, 2} just one time.
      Now you don’t have to go through the list looking for unique values.




      def aprioriGen(Lk, k): #creates Ck
      retList =
      lenLk = len(Lk)
      for i in range(lenLk):
      for j in range(i+1, lenLk):
      L1 = list(Lk[i])[:k-2]; L2 = list(Lk[j])[:k-2] # Join sets if first k-2 items are equal
      L1.sort(); L2.sort()
      if L1==L2:
      retList.append(Lk[i] | Lk[j])
      return retLis


      Suppose i am calling above function



      Lk = [frozenset({2, 3}), frozenset({3, 5}), frozenset({2, 5}), frozenset({1, 3})]

      k = 3

      aprioriGen(Lk,3)


      I am geting following output



      [frozenset({2, 3, 5})]


      I think there is bug in above logic since we are missing other combinations like {1,2,3}, {1,3,5}. Isn't it? Is my understanding right?










      share|improve this question













      I am reading about association analysis in book titled Machine learning in action. Following code is given in book




      The k-2 thing may be a little confusing. Let’s look at that a little
      further. When you were creating {0,1} {0,2}, {1,2} from {0}, {1}, {2},
      you just combined items. Now, what if you want to use {0,1} {0,2},
      {1,2} to create a three-item set? If you did the union of every set,
      you’d get {0, 1, 2}, {0, 1, 2}, {0, 1, 2}. That’s right. It’s the same
      set three times. Now you have to scan through the list of three-item
      sets to get only unique values. You’re trying to keep the number of
      times you go through the lists to a minimum. Now, if you compared the
      first element {0,1} {0,2}, {1,2} and only took the union of those that
      had the same first item, what would you have? {0, 1, 2} just one time.
      Now you don’t have to go through the list looking for unique values.




      def aprioriGen(Lk, k): #creates Ck
      retList =
      lenLk = len(Lk)
      for i in range(lenLk):
      for j in range(i+1, lenLk):
      L1 = list(Lk[i])[:k-2]; L2 = list(Lk[j])[:k-2] # Join sets if first k-2 items are equal
      L1.sort(); L2.sort()
      if L1==L2:
      retList.append(Lk[i] | Lk[j])
      return retLis


      Suppose i am calling above function



      Lk = [frozenset({2, 3}), frozenset({3, 5}), frozenset({2, 5}), frozenset({1, 3})]

      k = 3

      aprioriGen(Lk,3)


      I am geting following output



      [frozenset({2, 3, 5})]


      I think there is bug in above logic since we are missing other combinations like {1,2,3}, {1,3,5}. Isn't it? Is my understanding right?







      python machine-learning merge set






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Dec 28 '18 at 9:43









      venkysmartyvenkysmarty

      4,4101767143




      4,4101767143
























          1 Answer
          1






          active

          oldest

          votes


















          0














          I think you are following the below link, Output set depends on the minSupport what we pass.



          http://adataanalyst.com/machine-learning/apriori-algorithm-python-3-0/



          If we reduce the minSupport value to 0.2, we get all sets.



          Below is the complete code



          # -*- coding: utf-8 -*-
          """
          Created on Mon Dec 31 16:57:26 2018

          @author: rponnurx
          """

          from numpy import *

          def loadDataSet():
          return [[1, 3, 4], [2, 3, 5], [1, 2, 3, 5], [2, 5]]

          def createC1(dataSet):
          C1 =
          for transaction in dataSet:
          for item in transaction:
          if not [item] in C1:
          C1.append([item])

          C1.sort()
          return list(map(frozenset, C1))#use frozen set so we
          #can use it as a key in a dict

          def scanD(D, Ck, minSupport):
          ssCnt = {}
          for tid in D:
          for can in Ck:
          if can.issubset(tid):
          if not can in ssCnt: ssCnt[can]=1
          else: ssCnt[can] += 1
          numItems = float(len(D))
          retList =
          supportData = {}
          for key in ssCnt:
          support = ssCnt[key]/numItems
          if support >= minSupport:
          retList.insert(0,key)
          supportData[key] = support
          return retList, supportData

          dataSet = loadDataSet()
          print(dataSet)

          C1 = createC1(dataSet)

          print(C1)

          #D is a dataset in the setform.

          D = list(map(set,dataSet))
          print(D)

          L1,suppDat0 = scanD(D,C1,0.5)
          print(L1)

          def aprioriGen(Lk, k): #creates Ck
          retList =
          print("Lk")
          print(Lk)
          lenLk = len(Lk)
          for i in range(lenLk):
          for j in range(i+1, lenLk):
          L1 = list(Lk[i])[:k-2]; L2 = list(Lk[j])[:k-2]
          L1.sort(); L2.sort()
          if L1==L2: #if first k-2 elements are equal
          retList.append(Lk[i] | Lk[j]) #set union
          return retList

          def apriori(dataSet, minSupport = 0.5):
          C1 = createC1(dataSet)
          D = list(map(set, dataSet))
          L1, supportData = scanD(D, C1, minSupport)

          L = [L1]
          k = 2
          while (len(L[k-2]) > 0):
          Ck = aprioriGen(L[k-2], k)
          Lk, supK = scanD(D, Ck, minSupport)#scan DB to get Lk
          supportData.update(supK)
          L.append(Lk)
          k += 1
          return L, supportData

          L,suppData = apriori(dataSet,0.2)

          print(L)


          Output:
          [[frozenset({5}), frozenset({2}), frozenset({4}), frozenset({3}), frozenset({1})], [frozenset({1, 2}), frozenset({1, 5}), frozenset({2, 3}), frozenset({3, 5}), frozenset({2, 5}), frozenset({1, 3}), frozenset({1, 4}), frozenset({3, 4})], [frozenset({1, 3, 5}), frozenset({1, 2, 3}), frozenset({1, 2, 5}), frozenset({2, 3, 5}), frozenset({1, 3, 4})], [frozenset({1, 2, 3, 5})], ]



          Thanks,
          Rajeswari Ponnuru






          share|improve this answer





















          • @ Thanks for answering. Still I am not getting when we combine data for example from two element set to three element set we don't check for confidence yet, so we have to find all three elements sets Isn't it. For example {1,3} and {3,5} are two elements sets which are to be combined to form {1,3,5} and then we check for confidence level before we decidie to use it for 4 element set or not. Isn't it?
            – venkysmarty
            2 days ago













          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53956461%2fcreating-itemsets-in-apriori-algorithm%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          I think you are following the below link, Output set depends on the minSupport what we pass.



          http://adataanalyst.com/machine-learning/apriori-algorithm-python-3-0/



          If we reduce the minSupport value to 0.2, we get all sets.



          Below is the complete code



          # -*- coding: utf-8 -*-
          """
          Created on Mon Dec 31 16:57:26 2018

          @author: rponnurx
          """

          from numpy import *

          def loadDataSet():
          return [[1, 3, 4], [2, 3, 5], [1, 2, 3, 5], [2, 5]]

          def createC1(dataSet):
          C1 =
          for transaction in dataSet:
          for item in transaction:
          if not [item] in C1:
          C1.append([item])

          C1.sort()
          return list(map(frozenset, C1))#use frozen set so we
          #can use it as a key in a dict

          def scanD(D, Ck, minSupport):
          ssCnt = {}
          for tid in D:
          for can in Ck:
          if can.issubset(tid):
          if not can in ssCnt: ssCnt[can]=1
          else: ssCnt[can] += 1
          numItems = float(len(D))
          retList =
          supportData = {}
          for key in ssCnt:
          support = ssCnt[key]/numItems
          if support >= minSupport:
          retList.insert(0,key)
          supportData[key] = support
          return retList, supportData

          dataSet = loadDataSet()
          print(dataSet)

          C1 = createC1(dataSet)

          print(C1)

          #D is a dataset in the setform.

          D = list(map(set,dataSet))
          print(D)

          L1,suppDat0 = scanD(D,C1,0.5)
          print(L1)

          def aprioriGen(Lk, k): #creates Ck
          retList =
          print("Lk")
          print(Lk)
          lenLk = len(Lk)
          for i in range(lenLk):
          for j in range(i+1, lenLk):
          L1 = list(Lk[i])[:k-2]; L2 = list(Lk[j])[:k-2]
          L1.sort(); L2.sort()
          if L1==L2: #if first k-2 elements are equal
          retList.append(Lk[i] | Lk[j]) #set union
          return retList

          def apriori(dataSet, minSupport = 0.5):
          C1 = createC1(dataSet)
          D = list(map(set, dataSet))
          L1, supportData = scanD(D, C1, minSupport)

          L = [L1]
          k = 2
          while (len(L[k-2]) > 0):
          Ck = aprioriGen(L[k-2], k)
          Lk, supK = scanD(D, Ck, minSupport)#scan DB to get Lk
          supportData.update(supK)
          L.append(Lk)
          k += 1
          return L, supportData

          L,suppData = apriori(dataSet,0.2)

          print(L)


          Output:
          [[frozenset({5}), frozenset({2}), frozenset({4}), frozenset({3}), frozenset({1})], [frozenset({1, 2}), frozenset({1, 5}), frozenset({2, 3}), frozenset({3, 5}), frozenset({2, 5}), frozenset({1, 3}), frozenset({1, 4}), frozenset({3, 4})], [frozenset({1, 3, 5}), frozenset({1, 2, 3}), frozenset({1, 2, 5}), frozenset({2, 3, 5}), frozenset({1, 3, 4})], [frozenset({1, 2, 3, 5})], ]



          Thanks,
          Rajeswari Ponnuru






          share|improve this answer





















          • @ Thanks for answering. Still I am not getting when we combine data for example from two element set to three element set we don't check for confidence yet, so we have to find all three elements sets Isn't it. For example {1,3} and {3,5} are two elements sets which are to be combined to form {1,3,5} and then we check for confidence level before we decidie to use it for 4 element set or not. Isn't it?
            – venkysmarty
            2 days ago


















          0














          I think you are following the below link, Output set depends on the minSupport what we pass.



          http://adataanalyst.com/machine-learning/apriori-algorithm-python-3-0/



          If we reduce the minSupport value to 0.2, we get all sets.



          Below is the complete code



          # -*- coding: utf-8 -*-
          """
          Created on Mon Dec 31 16:57:26 2018

          @author: rponnurx
          """

          from numpy import *

          def loadDataSet():
          return [[1, 3, 4], [2, 3, 5], [1, 2, 3, 5], [2, 5]]

          def createC1(dataSet):
          C1 =
          for transaction in dataSet:
          for item in transaction:
          if not [item] in C1:
          C1.append([item])

          C1.sort()
          return list(map(frozenset, C1))#use frozen set so we
          #can use it as a key in a dict

          def scanD(D, Ck, minSupport):
          ssCnt = {}
          for tid in D:
          for can in Ck:
          if can.issubset(tid):
          if not can in ssCnt: ssCnt[can]=1
          else: ssCnt[can] += 1
          numItems = float(len(D))
          retList =
          supportData = {}
          for key in ssCnt:
          support = ssCnt[key]/numItems
          if support >= minSupport:
          retList.insert(0,key)
          supportData[key] = support
          return retList, supportData

          dataSet = loadDataSet()
          print(dataSet)

          C1 = createC1(dataSet)

          print(C1)

          #D is a dataset in the setform.

          D = list(map(set,dataSet))
          print(D)

          L1,suppDat0 = scanD(D,C1,0.5)
          print(L1)

          def aprioriGen(Lk, k): #creates Ck
          retList =
          print("Lk")
          print(Lk)
          lenLk = len(Lk)
          for i in range(lenLk):
          for j in range(i+1, lenLk):
          L1 = list(Lk[i])[:k-2]; L2 = list(Lk[j])[:k-2]
          L1.sort(); L2.sort()
          if L1==L2: #if first k-2 elements are equal
          retList.append(Lk[i] | Lk[j]) #set union
          return retList

          def apriori(dataSet, minSupport = 0.5):
          C1 = createC1(dataSet)
          D = list(map(set, dataSet))
          L1, supportData = scanD(D, C1, minSupport)

          L = [L1]
          k = 2
          while (len(L[k-2]) > 0):
          Ck = aprioriGen(L[k-2], k)
          Lk, supK = scanD(D, Ck, minSupport)#scan DB to get Lk
          supportData.update(supK)
          L.append(Lk)
          k += 1
          return L, supportData

          L,suppData = apriori(dataSet,0.2)

          print(L)


          Output:
          [[frozenset({5}), frozenset({2}), frozenset({4}), frozenset({3}), frozenset({1})], [frozenset({1, 2}), frozenset({1, 5}), frozenset({2, 3}), frozenset({3, 5}), frozenset({2, 5}), frozenset({1, 3}), frozenset({1, 4}), frozenset({3, 4})], [frozenset({1, 3, 5}), frozenset({1, 2, 3}), frozenset({1, 2, 5}), frozenset({2, 3, 5}), frozenset({1, 3, 4})], [frozenset({1, 2, 3, 5})], ]



          Thanks,
          Rajeswari Ponnuru






          share|improve this answer





















          • @ Thanks for answering. Still I am not getting when we combine data for example from two element set to three element set we don't check for confidence yet, so we have to find all three elements sets Isn't it. For example {1,3} and {3,5} are two elements sets which are to be combined to form {1,3,5} and then we check for confidence level before we decidie to use it for 4 element set or not. Isn't it?
            – venkysmarty
            2 days ago
















          0












          0








          0






          I think you are following the below link, Output set depends on the minSupport what we pass.



          http://adataanalyst.com/machine-learning/apriori-algorithm-python-3-0/



          If we reduce the minSupport value to 0.2, we get all sets.



          Below is the complete code



          # -*- coding: utf-8 -*-
          """
          Created on Mon Dec 31 16:57:26 2018

          @author: rponnurx
          """

          from numpy import *

          def loadDataSet():
          return [[1, 3, 4], [2, 3, 5], [1, 2, 3, 5], [2, 5]]

          def createC1(dataSet):
          C1 =
          for transaction in dataSet:
          for item in transaction:
          if not [item] in C1:
          C1.append([item])

          C1.sort()
          return list(map(frozenset, C1))#use frozen set so we
          #can use it as a key in a dict

          def scanD(D, Ck, minSupport):
          ssCnt = {}
          for tid in D:
          for can in Ck:
          if can.issubset(tid):
          if not can in ssCnt: ssCnt[can]=1
          else: ssCnt[can] += 1
          numItems = float(len(D))
          retList =
          supportData = {}
          for key in ssCnt:
          support = ssCnt[key]/numItems
          if support >= minSupport:
          retList.insert(0,key)
          supportData[key] = support
          return retList, supportData

          dataSet = loadDataSet()
          print(dataSet)

          C1 = createC1(dataSet)

          print(C1)

          #D is a dataset in the setform.

          D = list(map(set,dataSet))
          print(D)

          L1,suppDat0 = scanD(D,C1,0.5)
          print(L1)

          def aprioriGen(Lk, k): #creates Ck
          retList =
          print("Lk")
          print(Lk)
          lenLk = len(Lk)
          for i in range(lenLk):
          for j in range(i+1, lenLk):
          L1 = list(Lk[i])[:k-2]; L2 = list(Lk[j])[:k-2]
          L1.sort(); L2.sort()
          if L1==L2: #if first k-2 elements are equal
          retList.append(Lk[i] | Lk[j]) #set union
          return retList

          def apriori(dataSet, minSupport = 0.5):
          C1 = createC1(dataSet)
          D = list(map(set, dataSet))
          L1, supportData = scanD(D, C1, minSupport)

          L = [L1]
          k = 2
          while (len(L[k-2]) > 0):
          Ck = aprioriGen(L[k-2], k)
          Lk, supK = scanD(D, Ck, minSupport)#scan DB to get Lk
          supportData.update(supK)
          L.append(Lk)
          k += 1
          return L, supportData

          L,suppData = apriori(dataSet,0.2)

          print(L)


          Output:
          [[frozenset({5}), frozenset({2}), frozenset({4}), frozenset({3}), frozenset({1})], [frozenset({1, 2}), frozenset({1, 5}), frozenset({2, 3}), frozenset({3, 5}), frozenset({2, 5}), frozenset({1, 3}), frozenset({1, 4}), frozenset({3, 4})], [frozenset({1, 3, 5}), frozenset({1, 2, 3}), frozenset({1, 2, 5}), frozenset({2, 3, 5}), frozenset({1, 3, 4})], [frozenset({1, 2, 3, 5})], ]



          Thanks,
          Rajeswari Ponnuru






          share|improve this answer












          I think you are following the below link, Output set depends on the minSupport what we pass.



          http://adataanalyst.com/machine-learning/apriori-algorithm-python-3-0/



          If we reduce the minSupport value to 0.2, we get all sets.



          Below is the complete code



          # -*- coding: utf-8 -*-
          """
          Created on Mon Dec 31 16:57:26 2018

          @author: rponnurx
          """

          from numpy import *

          def loadDataSet():
          return [[1, 3, 4], [2, 3, 5], [1, 2, 3, 5], [2, 5]]

          def createC1(dataSet):
          C1 =
          for transaction in dataSet:
          for item in transaction:
          if not [item] in C1:
          C1.append([item])

          C1.sort()
          return list(map(frozenset, C1))#use frozen set so we
          #can use it as a key in a dict

          def scanD(D, Ck, minSupport):
          ssCnt = {}
          for tid in D:
          for can in Ck:
          if can.issubset(tid):
          if not can in ssCnt: ssCnt[can]=1
          else: ssCnt[can] += 1
          numItems = float(len(D))
          retList =
          supportData = {}
          for key in ssCnt:
          support = ssCnt[key]/numItems
          if support >= minSupport:
          retList.insert(0,key)
          supportData[key] = support
          return retList, supportData

          dataSet = loadDataSet()
          print(dataSet)

          C1 = createC1(dataSet)

          print(C1)

          #D is a dataset in the setform.

          D = list(map(set,dataSet))
          print(D)

          L1,suppDat0 = scanD(D,C1,0.5)
          print(L1)

          def aprioriGen(Lk, k): #creates Ck
          retList =
          print("Lk")
          print(Lk)
          lenLk = len(Lk)
          for i in range(lenLk):
          for j in range(i+1, lenLk):
          L1 = list(Lk[i])[:k-2]; L2 = list(Lk[j])[:k-2]
          L1.sort(); L2.sort()
          if L1==L2: #if first k-2 elements are equal
          retList.append(Lk[i] | Lk[j]) #set union
          return retList

          def apriori(dataSet, minSupport = 0.5):
          C1 = createC1(dataSet)
          D = list(map(set, dataSet))
          L1, supportData = scanD(D, C1, minSupport)

          L = [L1]
          k = 2
          while (len(L[k-2]) > 0):
          Ck = aprioriGen(L[k-2], k)
          Lk, supK = scanD(D, Ck, minSupport)#scan DB to get Lk
          supportData.update(supK)
          L.append(Lk)
          k += 1
          return L, supportData

          L,suppData = apriori(dataSet,0.2)

          print(L)


          Output:
          [[frozenset({5}), frozenset({2}), frozenset({4}), frozenset({3}), frozenset({1})], [frozenset({1, 2}), frozenset({1, 5}), frozenset({2, 3}), frozenset({3, 5}), frozenset({2, 5}), frozenset({1, 3}), frozenset({1, 4}), frozenset({3, 4})], [frozenset({1, 3, 5}), frozenset({1, 2, 3}), frozenset({1, 2, 5}), frozenset({2, 3, 5}), frozenset({1, 3, 4})], [frozenset({1, 2, 3, 5})], ]



          Thanks,
          Rajeswari Ponnuru







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Dec 31 '18 at 11:42









          Rajeswari Ponnuru _ IntelRajeswari Ponnuru _ Intel

          1563




          1563












          • @ Thanks for answering. Still I am not getting when we combine data for example from two element set to three element set we don't check for confidence yet, so we have to find all three elements sets Isn't it. For example {1,3} and {3,5} are two elements sets which are to be combined to form {1,3,5} and then we check for confidence level before we decidie to use it for 4 element set or not. Isn't it?
            – venkysmarty
            2 days ago




















          • @ Thanks for answering. Still I am not getting when we combine data for example from two element set to three element set we don't check for confidence yet, so we have to find all three elements sets Isn't it. For example {1,3} and {3,5} are two elements sets which are to be combined to form {1,3,5} and then we check for confidence level before we decidie to use it for 4 element set or not. Isn't it?
            – venkysmarty
            2 days ago


















          @ Thanks for answering. Still I am not getting when we combine data for example from two element set to three element set we don't check for confidence yet, so we have to find all three elements sets Isn't it. For example {1,3} and {3,5} are two elements sets which are to be combined to form {1,3,5} and then we check for confidence level before we decidie to use it for 4 element set or not. Isn't it?
          – venkysmarty
          2 days ago






          @ Thanks for answering. Still I am not getting when we combine data for example from two element set to three element set we don't check for confidence yet, so we have to find all three elements sets Isn't it. For example {1,3} and {3,5} are two elements sets which are to be combined to form {1,3,5} and then we check for confidence level before we decidie to use it for 4 element set or not. Isn't it?
          – venkysmarty
          2 days ago




















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53956461%2fcreating-itemsets-in-apriori-algorithm%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Monofisismo

          Angular Downloading a file using contenturl with Basic Authentication

          Olmecas