Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/python-package-conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.8
- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: 3.9
- name: Add conda to system path
run: |
# $CONDA is an environment variable pointing to the root of the miniconda directory
Expand All @@ -27,7 +27,9 @@ jobs:
conda env update --file environment.yml --name base
- name: Test with pytest
run: |
conda update conda -y -q
conda config --add channels conda-forge
conda update conda -y -q
conda install scikit-learn=1.0.2 pandas=1.3.5 -y -q
conda install tensorflow joblib pytest -y -q
conda install imageio scikit-image -y -q
Expand Down
13 changes: 9 additions & 4 deletions mlxtend/frequent_patterns/tests/test_fpbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ def test_with_dataframe(df):
test_with_dataframe(sdf)

def test_sparsedataframe_notzero_column(self):
dfs = self.df.astype(pd.SparseDtype("int", np.nan))
dfs = self.df.astype(pd.SparseDtype("int", 0))

dfs.columns = [i for i in range(len(dfs.columns))]
self.fpalgo(dfs)

dfs = self.df.astype(pd.SparseDtype("int", np.nan))
dfs = self.df.astype(pd.SparseDtype("int", 0))

dfs.columns = [i + 1 for i in range(len(dfs.columns))]
assert_raises(
Expand Down Expand Up @@ -334,5 +334,10 @@ def compare_dataframes(df1, df2):
rows1 = sorted(zip(itemsets1, df1["support"]))
rows2 = sorted(zip(itemsets2, df2["support"]))

for r1, r2 in zip(rows1, rows2):
assert_array_equal(r1, r2)
for row1, row2 in zip(rows1, rows2):
if row1[0] != row2[0]:
msg = f"Expected different frequent itemsets\nx:{row1[0]}\ny:{row2[0]}"
raise AssertionError(msg)
elif row1[1] != row2[1]:
msg = f"Expected different support\nx:{row1[1]}\ny:{row2[1]}"
raise AssertionError(msg)
23 changes: 5 additions & 18 deletions mlxtend/frequent_patterns/tests/test_hmine.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
FPTestEx1All,
FPTestEx2All,
FPTestEx3All,
compare_dataframes,
)

from mlxtend.frequent_patterns import apriori, fpgrowth, hmine
Expand Down Expand Up @@ -176,23 +177,9 @@ def test_compare_correct(self):
for algo in algorithms.keys():
self.setUp()
res_df = algo(self.df, min_support=0.6)
compare_df(res_df, expect)
compare_dataframes(res_df, expect)
algorithms[algo] = res_df

compare_df(algorithms[hmine], algorithms[fpgrowth])
compare_df(algorithms[hmine], algorithms[apriori])
compare_df(algorithms[fpgrowth], algorithms[apriori])


def compare_df(df1, df2):
itemsets1 = [sorted(list(i)) for i in df1["itemsets"]]
itemsets2 = [sorted(list(i)) for i in df2["itemsets"]]
rows1 = sorted(zip(itemsets1, df1["support"]))
rows2 = sorted(zip(itemsets2, df2["support"]))
for row1, row2 in zip(rows1, rows2):
if row1[0] != row2[0]:
msg = f"Expected different frequent itemsets\nx:{row1[0]}\ny:{row2[0]}"
raise AssertionError(msg)
elif row1[1] != row2[1]:
msg = f"Expected different support\nx:{row1[1]}\ny:{row2[1]}"
raise AssertionError(msg)
compare_dataframes(algorithms[hmine], algorithms[fpgrowth])
compare_dataframes(algorithms[hmine], algorithms[apriori])
compare_dataframes(algorithms[fpgrowth], algorithms[apriori])