Giter Site home page Giter Site logo

Code for count_all about efficient-apriori HOT 5 CLOSED

tommyod avatar tommyod commented on June 19, 2024
Code for count_all

from efficient-apriori.

Comments (5)

tommyod avatar tommyod commented on June 19, 2024 1

This is a mathematical question @Andhu7. I don't see how what you describe above is an intersection of two rules.

I hope the following code can get you started.

from efficient_apriori import apriori
transactions = [('eggs', 'bacon', 'soup'),
                ('eggs', 'bacon', 'apple'),
                ('soup', 'bacon', 'banana')]
itemsets, rules = apriori(transactions, min_support=0.5,  min_confidence=1)
print(rules)  # [{eggs} -> {bacon}, {soup} -> {bacon}]

from functools import reduce
def intersection(rule1, rule2):
   # Here you must define what you believe an intersection is.
   # I have taken the union of the RHS and LHS of both rules,
   # since it complies with your example. It's obviously not an intersection.
   return reduce(set.union, (set(k) for k in (rule1.lhs, rule1.rhs, rule2.lhs, rule2.rhs)))

new_rule = intersection(rules[0], rules[1])

# Simply loop over the transactions and count
count = 0
for trans in transactions:
   if new_rule.issubset(set(trans)):
      count += 1

print(count) # Should print 1.

I'm going to close this issue. The purpose of Issues as they relate to this repository is to report bugs or suggest improvements to the software. The purpose of Issues is not to get help with general Python and mathematics, even if they relate to itemsets and the apriori algorithm.

from efficient-apriori.

tommyod avatar tommyod commented on June 19, 2024

Where is the code of count_all?

from efficient-apriori.

Andhu7 avatar Andhu7 commented on June 19, 2024

Sry count_full which is used to count the union of the lhs and rhs in the dataset.

from efficient-apriori.

tommyod avatar tommyod commented on June 19, 2024

count_full the total number of times the union of the left hand side and right hand side appear in the data set.

If you want a more detailed explanation, you're gonna have to ask a more detailed question. I don't fully understand what you're asking for here.

from efficient-apriori.

Andhu7 avatar Andhu7 commented on June 19, 2024

Can u hlp me with this..
how to find intersection of two rules?
if rule1 is {a, b} -> {c} and rule2 is {a} -> {c, d}

{a, b} -> {c} intersection {a} -> {c, d} means
the count of every time {a, b,c,d} appear together in a transaction...

Any idea how to get this???

from efficient-apriori.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.