rasbt / rasbt/mlxtend

apriori.py line 224: ValueError: negative dimensions are not allowed

Open
#613 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

https://github.com/rasbt/mlxtend/blob/115278bac14d7fc278885c0722da03f1c3b91604/mlxtend/frequent_patterns/apriori.py#L224

Processing 24785850 combinations | Sampling itemset size 6
Traceback (most recent call last):
File "***.py", line 116, in
frequent_itemsets = apriori(df, min_support=0.8, use_colnames=True, verbose=1)

File "C:\ProgramData\Anaconda3\lib\site-packages\mlxtend\frequent_patterns\apriori.py", line 219, in apriori
_bools = X[:, combin[:, 0]] == all_ones

File "C:\ProgramData\Anaconda3\lib\site-packages\scipy\sparse_index.py", line 53, in getitem
return self._get_sliceXarray(row, col)

File "C:\ProgramData\Anaconda3\lib\site-packages\scipy\sparse\csc.py", line 222, in _get_sliceXarray
return self._major_index_fancy(col)._minor_slice(row)

File "C:\ProgramData\Anaconda3\lib\site-packages\scipy\sparse\compressed.py", line 693, in _major_index_fancy
res_indices = np.empty(nnz, dtype=idx_dtype)

ValueError: negative dimensions are not allowed

In my apriori.py, variable "combin" is a (4130975, 6) dataframe comprise of indices (dtype = int32).

In compressed.py, numpy cumsum takes the dtype from indices of "combin".

Negative values appeared after the numpy cumsum reached maximum of int32.

Not sure if it is an exception for numpy cumsum or mlxtend apriori.

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

Start with mlxtend/frequent_patterns/apriori.py at the linked line and trace the reported scipy sparse indexing failure back through the int32 combin array and NumPy cumsum behavior. Reproduce the reported apriori call, then determine whether the failure belongs in mlxtend or a dependency; done means the large-combination case no longer raises this error or the limitation is clearly documented with coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
machine-learning
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
28/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.