diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 7225c16..70ae8f9 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -6,7 +6,7 @@ jobs: test: strategy: matrix: - python-version: ['3.8', '3.9', '3.10', '3.11'] + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] experimental: [false] fail-fast: false runs-on: ubuntu-latest diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 029a610..9ad590c 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -6,7 +6,7 @@ jobs: test: strategy: matrix: - python-version: ['3.8', '3.9', '3.10', '3.11'] + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] experimental: [false] fail-fast: false runs-on: macos-latest diff --git a/.github/workflows/windows.yml b/.github/workflows/windows.yml index 58e26ed..eec40a3 100644 --- a/.github/workflows/windows.yml +++ b/.github/workflows/windows.yml @@ -6,7 +6,7 @@ jobs: test: strategy: matrix: - python-version: ['3.8', '3.9', '3.10', '3.11'] + python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] experimental: [false] fail-fast: false runs-on: windows-latest diff --git a/.readthedocs.yml b/.readthedocs.yml index 8a6159e..102966f 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -1,16 +1,19 @@ version: 2 +build: + os: ubuntu-22.04 + tools: + python: "3.11" + sphinx: - configuration: docs/source/conf.py + configuration: docs/source/conf.py formats: all python: - version: 3.8 - install: - - requirements: requirements.txt - - requirements: requirements-nn.txt - - requirements: docs/requirements.txt - - - method: setuptools - path: . + install: + - requirements: requirements.txt + - requirements: requirements-nn.txt + - requirements: docs/requirements.txt + - method: setuptools + path: . diff --git a/CHANGELOG.md b/CHANGELOG.md index 03b3f7d..aa1fe8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,8 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] -### Changed +### Add +- Added wheel package supported for `py3.12` +### Changed - Update `pandas` version to `>=1.5` - Python `3.7` is no longer supported diff --git a/README.md b/README.md index 2b2fc9c..3fb10b8 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ The following showcases some of the most popular features of toad, for more deta - Simple IV calculation for all features · 一键算IV: ```python -toad.quality(data,'target',iv_only=True) +toad.quality(data, 'target', indicators = ['iv']) ``` - Preliminary selection based on criteria · 根据特定条件的初步变量筛选; @@ -118,10 +118,10 @@ 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 -[actions-image]: https://img.shields.io/github/workflow/status/amphibian-dev/toad/Release?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 [docs-url]: https://toad.readthedocs.io/ diff --git a/pyproject.toml b/pyproject.toml index 3827863..b324ad3 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,6 +12,7 @@ classifiers = [ 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', ] dynamic = [ "version", diff --git a/requirements-nn.txt b/requirements-nn.txt index 8c93348..0c6d2cf 100644 --- a/requirements-nn.txt +++ b/requirements-nn.txt @@ -1,5 +1,2 @@ -torch >= 1.8.1; sys_platform != 'darwin' -torchvision >= 0.9.1; sys_platform != 'darwin' - -torch >= 1.8.1; sys_platform == 'darwin' -torchvision >= 0.9.1; sys_platform == 'darwin' +torch >= 1.8.1 +torchvision >= 0.9.1 diff --git a/requirements.txt b/requirements.txt index 9431b5f..78c9c74 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ Cython >= 0.29.15 -numpy >= 1.20 +numpy <= 2.0.0 pandas >= 1.5 scipy joblib >= 0.12 diff --git a/setup.py b/setup.py index 30ae10a..89a04ce 100644 --- a/setup.py +++ b/setup.py @@ -70,6 +70,7 @@ def get_requirements(stage = None): 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', 'Programming Language :: Python :: 3.11', + 'Programming Language :: Python :: 3.12', ], entry_points = { 'console_scripts': [ diff --git a/toad/metrics_test.py b/toad/metrics_test.py index 73e672e..465605f 100644 --- a/toad/metrics_test.py +++ b/toad/metrics_test.py @@ -56,11 +56,11 @@ def test_KS_bucket_with_cum_lift(): def test_F1(): result, split = F1(feature, target, return_split = True) - assert result == 0.6844207723035951 + assert result == pytest.approx(0.6844207723035951, FUZZ_THRESHOLD) def test_F1_split(): result = F1(feature, target, split = 0.5) - assert result == 0.51417004048583 + assert result == pytest.approx(0.51417004048583, FUZZ_THRESHOLD) def test_AUC(): result = AUC(feature, target) diff --git a/toad/selection.py b/toad/selection.py index a59a57a..bade0be 100644 --- a/toad/selection.py +++ b/toad/selection.py @@ -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:] ], diff --git a/toad/stats.py b/toad/stats.py index 1b1a9f4..02a5477 100644 --- a/toad/stats.py +++ b/toad/stats.py @@ -340,6 +340,7 @@ def quality(dataframe, target = 'target', cpu_cores = 0, iv_only = False, indica dataframe (DataFrame): dataframe that will be calculate quality target (str): the target's name in dataframe iv_only (bool): `deprecated`. if only calculate IV + indicators (list): indictors will be calc, it can be customized indictor functions, default is ['iv', 'gini', 'entropy', 'unique'] cpu_cores (int): the maximun number of CPU cores will be used, `0` means all CPUs will be used, `-1` means all CPUs but one will be used.