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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ Format: [Keep a Changelog](https://keepachangelog.com/en/1.1.0/); versioning: [S

## [Unreleased]

### Fixed
- `features.feature_importance` (MDA): feature shuffling mutated a column view
in place, which raises `ValueError: array is read-only` under pandas
copy-on-write (default since pandas 3.0). Now shuffles a copy and assigns back.

## [1.0.9]

### Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,12 @@ def compute(self, x: pd.DataFrame, y: pd.Series, **kwargs: Any) -> pd.DataFrame:
rng = np.random.default_rng(self.random_state + i)
for feature in x.columns:
x_test_shuffled = x_test.copy(deep=True)
rng.shuffle(x_test_shuffled[feature].values) # <-- USE SEEDED SHUFFLE
# Shuffle a copy and assign back: with pandas copy-on-write
# (default since pandas 3.0), column .values is a read-only
# view and in-place shuffling raises ValueError.
shuffled_values = x_test_shuffled[feature].to_numpy(copy=True)
rng.shuffle(shuffled_values) # seeded shuffle
x_test_shuffled[feature] = shuffled_values

shuffled_proba = fitted_classifier.predict_proba(x_test_shuffled)

Expand Down
Loading