diff --git a/CHANGELOG.md b/CHANGELOG.md index 2258e26..a415057 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ Format: [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) CONTRIBUTORS.md. Implemented as `scripts/check_credit.sh`, wired into `ci.yml` on `pull_request` events only; failures surface as inline `::error::` annotations on the Files tab. Closes #113. +- Regression coverage ensuring `MovesManagementClassifier.fit` preserves + DataFrame column names in `feature_names_in_`. Closes #54. ### Fixed - `CRMCleaner.transform` no longer silently corrupts complex amounts into wrong finite floats: cells holding actual `complex` values are masked to diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index e6d4555..a3e9df3 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -38,6 +38,9 @@ contribution. Code, docs, tests, and review all count. regression test pinning the `donor_id` error that `RFMTransformer.fit` raises for non-DataFrame input ([#139](https://github.com/PhilanthroPy-Project/PhilanthroPy/pull/139)). +- [@stoppo22](https://github.com/stoppo22): added DataFrame feature-name + coverage for `MovesManagementClassifier.fit` + ([#146](https://github.com/PhilanthroPy-Project/PhilanthroPy/pull/146)). ## Getting listed diff --git a/tests/test_moves.py b/tests/test_moves.py index 6868500..4cbe566 100644 --- a/tests/test_moves.py +++ b/tests/test_moves.py @@ -5,6 +5,7 @@ """ import numpy as np +import pandas as pd import pytest from philanthropy.models import MovesManagementClassifier @@ -55,3 +56,21 @@ def test_action_priority_summary_counts_every_donor(stage_Xy): summary = clf.action_priority(X)["portfolio_summary"] assert sum(summary.values()) == 30 assert set(summary) <= set(_STAGES) + + +def test_fit_with_dataframe_sets_feature_names_in(): + X = pd.DataFrame( + np.random.default_rng(0).random((30, 5)), + columns=["age", "income", "donations", "engagement", "years_active"], + ) + y = np.asarray(_STAGES * 10) + + clf = MovesManagementClassifier(max_iter=10, random_state=0).fit(X, y) + + np.testing.assert_array_equal( + clf.feature_names_in_, + np.array( + ["age", "income", "donations", "engagement", "years_active"], + dtype=object, + ), + ) \ No newline at end of file