rasbt / rasbt/mlxtend

Key error is raised when trying to generate the rules from the itemsets

Open
#696 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
5.2k
Forks
916
Avg merge
17h 31m
Merged PRs (30d)
4

Description

Hi,
thanks a lot for the amazing repository.

I'm using this to generate association rules. Extracting the itemsets of different lengths is not a problem. Also, extracting the itemsets and directly using it to generate rules works. However, after saving the itemsets to a file, generating the rules after reading the saved file generates this error:

KeyError: 'frozenset({'1', 'z', 'f', 'a', "'", ')', 'l', '(', 'o', 'k', 'r', ' ', 'b', '%', 'e', 's', 'm', '}', '{', 'i', 'u', 't'})You are likely getting this error because the DataFrame is missing antecedent and/or consequent information. You can try using the support_only=True option'

I understand that it's because the code can't find the support of one of the antecedents/consequent items but have no idea how to solve it? I've read all the possible solutions in this thread: https://github.com/rasbt/mlxtend/issues/390 but none of them works. Also tried to save the itemsets to a csv file separated by ; rather than , to avoid special characters problem but still have the problem.

I'm using: python 3.7
mlxtend version: 0.17.2

Would appreciate any idea,
Thanks.
Bushra.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with the reported Python 3.7 and mlxtend 0.17.2 workflow, comparing in-memory itemsets with the saved-and-reloaded data passed to association-rule generation. Trace the itemset save/read path and rule-generation entry point; done means reloaded itemsets generate rules without the reported KeyError and the behavior is covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
machine-learning
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.