Skip to content

Commit

Permalink
fixed: value error in select and drop_corr method
Browse files Browse the repository at this point in the history
  • Loading branch information
Secbone committed Dec 10, 2023
1 parent e500bc3 commit 61b60f5
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added `performance` in `toad.utils` for test code performance
- Added `pickletracer` in `toad.utils` for infer requirements in pickle object

### Fixed
- Fixed `Value Error` in `select` and `drop_corr` method when using `pandas >= 2.0.x`

## [0.1.2] - 2023-04-09

### Add
Expand Down
1 change: 1 addition & 0 deletions toad/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from .detector import detect
from .metrics import KS, KS_bucket, F1
from .stats import quality, IV, VIF, WOE, entropy, entropy_cond, gini, gini_cond
from .transform import Combiner, WOETransformer
from .selection import select
from .scorecard import ScoreCard
from .utils import Progress, performance
Expand Down
2 changes: 1 addition & 1 deletion toad/selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ def drop_corr(frame, target = None, threshold = 0.7, by = 'IV',

f, t = split_target(frame[cols], target)

corr = f.corr().abs()
corr = f.corr(numeric_only = True).abs()

drops = []

Expand Down
9 changes: 8 additions & 1 deletion toad/selection_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,14 @@ def test_drop_var_exclude():

def test_drop_corr():
df = drop_corr(frame, target = 'target')
assert ['D', 'E', 'F', 'target'] == df.columns.tolist()
assert set(['D', 'E', 'F', 'target']) == set(df.columns.tolist())

def test_drop_corr_with_string():
ab = np.array(list('ABCDEFG'))
str_feat = pd.Series(ab[np.random.choice(7, 500)])

df = drop_corr(pd.concat((frame, str_feat.rename('str_f')), axis = 1), target = 'target')
assert set(['D', 'E', 'F', 'target', 'str_f']) == set(df.columns.tolist())

def test_drop_iv():
df = drop_iv(frame, target = 'target', threshold = 0.25)
Expand Down

1 comment on commit 61b60f5

@Secbone
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed #133

Please sign in to comment.