2

When I import mlxtend.frequent_patterns, the function fpgrowth and fpmax are not there. However, they are there if I use Jupyter Notebook in Anaconda Navigator.

Anyone know why Colab will not import?

import pandas as pd

from mlxtend.preprocessing import TransactionEncoder
from mlxtend.frequent_patterns import apriori, fpmax, fpgrowth

ImportError
Traceback (most recent call last)
in ()
2
3 from mlxtend.preprocessing import TransactionEncoder
----> 4 from mlxtend.frequent_patterns import apriori, fpmax, fpgrowth
5
6

ImportError: cannot import name 'fpmax' from 'mlxtend.frequent_patterns' (/usr/local/lib/python3.7/dist-packages/mlxtend/frequent_patterns/init.py)

Filburt
  • 17,626
  • 12
  • 64
  • 115
Pete
  • 21
  • 3

2 Answers2

0

I had the same issue just now. The first solution suggested was to pip the package using this in a code cell:

! pip install mlxtend

However, while that helped with me using apriori, it did not help with fpgrowth. Then, after about three hours, I found a solution. Again, in a code cell, run this:

%pip install mlxtend --upgrade

I'm not sure what the % does that the ! does not.

miken32
  • 42,008
  • 16
  • 111
  • 154
0

Colab by default installs some older version of the library.

Try with this specific version. Run the following command: !pip install mlxtend==0.17.0

starball
  • 20,030
  • 7
  • 43
  • 238