Comments (4)
Got it, thank you for helping
from efficient-apriori.
Hello @nirvitarka . Thank you for raising the issue.
You should change the filename. The min_support
argument is set a too high, and so is min_confidence
. This is data set dependent, and there is a trade-off between speed and output.
The following works for me:
from efficient_apriori import apriori
def data_generator(filename):
def data_gen():
with open(filename) as file:
for line in file:
yield tuple(k.strip() for k in line.split(','))
return data_gen
transactions = data_generator('store_data.csv')
itemsets, rules = apriori(transactions,
min_support=0.05,
min_confidence=0.01,
verbosity=2)
for rule in sorted(rules, key=lambda rule: rule.lift):
print(rule)
Please note that the data generator approach is not needed when data fits into memory.
The following approach is better, since it loads data into memory once.
from efficient_apriori import apriori
# Read data into memory from the file
transactions = []
with open('store_data.csv') as file:
for line in file:
transactions.append(set(tuple(k.strip() for k in line.split(','))))
# Run the Apriori algorithm, print output with `verbosity`
itemsets, rules = apriori(transactions,
min_support=0.05,
min_confidence=0.01,
verbosity=2)
for rule in sorted(rules, key=lambda rule: rule.lift):
print(rule)
If hope this helps. Let me know if it works for you.
from efficient-apriori.
Thank you for prompt response.
I changed the filename as I used a subset of that data in "data.csv".
Changing min_support & min_confidence helped, it worked on a smaller subset of data.
However still not working on the original "store_data.csv". It says "Rule generation terminated." and ends.
It is getting some itemsets for length 1 & 2 & no itemsets of length 3.
Am I understanding it right that it should display results for length 1 & 2 itemsets?
from efficient-apriori.
That depends on whether you filter the rules or not, print(rules)
will show all rules with no filtering. Depending on the data and the values for min_support
and min_confidence
, you might or might not have any rules of length 3 at all.
from efficient-apriori.
Related Issues (20)
- Input dataset format HOT 4
- Misprint in instructional comment HOT 2
- Clarifications on rules direction meaning HOT 3
- Why not add Rule Power Factor (RPF) as one more property to Rule? HOT 1
- Is there any way to export the rules with data to Excel? HOT 4
- ModuleNotFoundError: No module named 'dataclasses' HOT 2
- run time HOT 7
- Seeing #30, tuning confidence and min support for max itemsets? HOT 3
- lhs and rhs mixed up in the comments? HOT 1
- KeyError while generating rules HOT 6
- the min_support value HOT 1
- H_1 is not reduced, unnecessary rule candidate generation/checking HOT 3
- Using iterator or generator to provide transactions HOT 2
- A doubt HOT 2
- GPL-3.0 license classifier? HOT 2
- Reducing H_1 update broken HOT 3
- weighted Association rule mining HOT 1
- sort step not needed after combinations for join_step HOT 2
- Code for count_all HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from efficient-apriori.