Skip to content

Commit

Permalink
fixed: backward selection when only one feature left
Browse files Browse the repository at this point in the history
  • Loading branch information
Secbone committed Mar 24, 2024
1 parent 8f32e96 commit f0eb704
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,9 @@ We welcome public feedback and new PRs. We hold a WeChat group for questions and

## Dedicated by **The ESC Team**

[pypi-image]: https://img.shields.io/pypi/v/toad.svg?style=flat-square
[pypi-image]: https://img.shields.io/pypi/v/toad?style=flat-square
[pypi-url]: https://pypi.org/project/toad/
[python-image]: https://img.shields.io/pypi/pyversions/toad.svg?style=flat-square
[python-image]: https://img.shields.io/pypi/pyversions/toad?style=flat-square
[actions-image]: https://img.shields.io/github/actions/workflow/status/amphibian-dev/toad/release.yml?style=flat-square
[actions-url]: https://github.com/amphibian-dev/toad/actions
[downloads-image]: https://img.shields.io/pypi/dm/toad?style=flat-square
Expand Down
4 changes: 4 additions & 0 deletions toad/selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ def stepwise(frame, target = 'target', estimator = 'ols', direction = 'both', cr
test_res = np.empty(l, dtype = object)

if direction == 'backward':
# break when only one single feature left
if l < 2:
break

for i in range(l):
test_res[i] = sm.stats(
df[ remaining[:i] + remaining[i+1:] ],
Expand Down

0 comments on commit f0eb704

Please sign in to comment.