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
2 changes: 2 additions & 0 deletions docs/sources/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ The CHANGELOG for the current development version is available at

- Fixes an edge-case bug where decision regions plots didn't have unique colors ([#1157](https://github.com/rasbt/mlxtend/issues/1157) via [mariam851](https://github.com/mariam851))

- Reject `min_support` values outside the documented `(0, 1]` interval in `apriori`, `fpgrowth`, `fpmax`, and `hmine`. The previous check only caught `<= 0`, so passing e.g. `min_support=2` silently returned an empty result ([#864](https://github.com/rasbt/mlxtend/issues/864) via [jbbqqf](https://github.com/jbbqqf))

- Add a `top_k` argument to `ExhaustiveFeatureSelector.get_metric_dict()` so callers can request only the highest-scoring subsets before converting the result to a DataFrame ([#610](https://github.com/rasbt/mlxtend/issues/610) via [jbbqqf](https://github.com/jbbqqf))

- `minmax_scaling` no longer returns silent NaNs for constant columns; constant columns are now collapsed to `min_val`, mirroring the existing contract of `standardize`. ([#1167](https://github.com/rasbt/mlxtend/issues/1167) via [jbbqqf](https://github.com/jbbqqf))
Expand Down
2 changes: 1 addition & 1 deletion mlxtend/frequent_patterns/apriori.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ def _support(_x, _n_rows, _is_sparse):
out = np.sum(_x, axis=0) / _n_rows
return np.array(out).reshape(-1)

if min_support <= 0.0:
if min_support <= 0.0 or min_support > 1.0:
raise ValueError(
"`min_support` must be a positive "
"number within the interval `(0, 1]`. "
Expand Down
2 changes: 1 addition & 1 deletion mlxtend/frequent_patterns/fpgrowth.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def fpgrowth(
"""
fpc.valid_input_check(df, null_values)

if min_support <= 0.0:
if min_support <= 0.0 or min_support > 1.0:
raise ValueError(
"`min_support` must be a positive "
"number within the interval `(0, 1]`. "
Expand Down
2 changes: 1 addition & 1 deletion mlxtend/frequent_patterns/fpmax.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def fpmax(
"""
fpc.valid_input_check(df, null_values)

if min_support <= 0.0:
if min_support <= 0.0 or min_support > 1.0:
raise ValueError(
"`min_support` must be a positive "
"number within the interval `(0, 1]`. "
Expand Down
2 changes: 1 addition & 1 deletion mlxtend/frequent_patterns/hmine.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def hmine(
"""

fpc.valid_input_check(df)
if min_support <= 0.0:
if min_support <= 0.0 or min_support > 1.0:
raise ValueError(
"`min_support` must be a positive "
"number within the interval `(0, 1]`. "
Expand Down
13 changes: 13 additions & 0 deletions mlxtend/frequent_patterns/tests/test_fpbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,19 @@ def test_output3(self):
min_support=0.0,
)

def test_output4_min_support_above_one_issue_864(self):
# Regression test for #864: min_support is a fraction in (0, 1].
# Values > 1 used to pass silently, returning an empty result;
# they now raise the same ValueError as min_support <= 0.
assert_raises(
ValueError,
"`min_support` must be a positive "
"number within the interval `(0, 1]`. Got 2.",
self.fpalgo,
self.df,
min_support=2,
)


def compare_dataframes(df1, df2):
itemsets1 = [sorted(list(i)) for i in df1["itemsets"]]
Expand Down
Loading