Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fpmax #553

Merged
merged 14 commits into from
Jun 23, 2019
Merged

Fpmax #553

merged 14 commits into from
Jun 23, 2019

Conversation

harenbergsd
Copy link
Contributor

@harenbergsd harenbergsd commented Jun 18, 2019

Description

Added FPMax algorithm to frequent pattern mining. FPMax find maximal itemsets.

Related issues or pull requests

Related to #509

Pull Request Checklist

  • Added a note about the modification or contribution to the ./docs/sources/CHANGELOG.md file (if applicable)
  • Added appropriate unit test functions in the ./mlxtend/*/tests directories (if applicable)
  • Modify documentation in the corresponding Jupyter Notebook under mlxtend/docs/sources/ (if applicable)
  • Ran PYTHONPATH='.' pytest ./mlxtend -sv and make sure that all unit tests pass (for small modifications, it might be sufficient to only run the specific test file, e.g., PYTHONPATH='.' pytest ./mlxtend/classifier/tests/test_stacking_cv_classifier.py -sv)
  • Checked for style issues by running flake8 ./mlxtend

@coveralls
Copy link

coveralls commented Jun 19, 2019

Coverage Status

Coverage increased (+0.06%) to 92.104% when pulling 85816aa on harenbergsd:fpmax into b20e57c on rasbt:master.

s = ('The allowed values for a DataFrame'
' are True, False, 0, 1. Found value %s' % (val))
raise ValueError(s)
idxs = np.where((df.values != 1) & (df.values != 0))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know if that captures True and False values as well by chance?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, in python, 1 == True (==1.0)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha, right, seems like my basic Python skill are getting a tad rusty

@rasbt
Copy link
Owner

rasbt commented Jun 19, 2019

Again, thanks so much for this very nice PR!

I can take care of the documentation part.

@harenbergsd
Copy link
Contributor Author

Ok, cool, thanks!

@harenbergsd
Copy link
Contributor Author

BTW, one design decision to discuss regarding max_len. It's not quite so clear what to do with max_len for this problem, where you are enumerating maximal itemsets. There are two options:

  1. Given the set of all maximal itemsets, return those that are less than max_len
  2. Given the set of all itemsets less than max_len, return those that are maximal

The latter is including max_len in the maximality constraint.

For example, if {a,b,c,d} and {c,d,e} are maximal itemsets. If you user gives a max_len of 3 the options would return:

  1. {c,d,e}
  2. {a,b,c}, {a,b,d}, {a,c,d}, {b,c,d}, {c,d,e}

I chose to go with the former, option (1), because with option (2) you can return itemsets that are not maximal wrt to the complete database. In other words, option (1) gives you subset of the complete set of solutions.

The other way would be fairly easy to implement as well, so if you think it's better, we can do it.

@rasbt
Copy link
Owner

rasbt commented Jun 19, 2019

Good point. I think there would be edge cases where someone would prefer one over the other. However, when I think of maximal itemsets, intuitively, I would think about it wrt the complete database as in scenario 1. I'd say we should go with 1, like you also suggest.

@rasbt
Copy link
Owner

rasbt commented Jun 21, 2019

Regarding what's currently implemented ... looking at the code (

if max_len is None or len(largest_set) <= max_len:
), it looks like it's option 1, correct?

@harenbergsd
Copy link
Contributor Author

Yep, option 1.

@rasbt
Copy link
Owner

rasbt commented Jun 23, 2019

Once the unit tests pass, I think this should be good to merge. Thanks a lot once again. Looks like quite some effort went into the code, and I particularly like the engineering best-practices regarding refactoring and encapsulation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants