-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from yu9824/dev
Fix #6.
- Loading branch information
Showing
8 changed files
with
91 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Regrences | ||
# - https://enu23456.hatenablog.com/entry/2022/11/24/195744 | ||
name: Python Package using Conda | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build-linux: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] | ||
max-parallel: 5 | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Setup Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Add conda to system path | ||
run: | | ||
# $CONDA is an environment variable pointing to the root of the miniconda directory | ||
echo $CONDA/bin >> $GITHUB_PATH | ||
- name: Install dependencies | ||
run: | | ||
conda env update --file requirements.txt --name base | ||
conda install pip pandas | ||
pip install -e . --user --no-deps | ||
- name: Test with pytest | ||
run: | | ||
conda install pytest | ||
pytest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from sklearn.datasets import load_diabetes | ||
from sklearn.ensemble import RandomForestRegressor | ||
from sklearn.model_selection import cross_validate | ||
import pytest | ||
|
||
from kennard_stone import train_test_split, KFold | ||
|
||
|
||
@pytest.fixture | ||
def prepare_data(): | ||
diabetes = load_diabetes(as_frame=True) | ||
X = diabetes.data | ||
y = diabetes.target | ||
return (X, y) | ||
|
||
|
||
def test_train_test_split(prepare_data): | ||
X, y = prepare_data | ||
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2) | ||
assert X_train.index[0] == y_train.index[0] == 224 | ||
assert X_train.index[-1] == y_train.index[-1] == 123 | ||
assert X_test.index[0] == y_test.index[0] == 68 | ||
assert X_test.index[-1] == y_test.index[-1] == 203 | ||
|
||
|
||
def test_KFold(prepare_data): | ||
X, y = prepare_data | ||
estimator = RandomForestRegressor(random_state=334, n_jobs=-1) | ||
kf = KFold(n_splits=5, shuffle=True) | ||
cross_validate( | ||
estimator, | ||
X, | ||
y, | ||
scoring="neg_mean_squared_error", | ||
n_jobs=-1, | ||
cv=kf, | ||
return_train_score=True, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
from sklearn.datasets import load_diabetes | ||
|
||
from kennard_stone import kennard_stone | ||
from kennard_stone import _deprecated | ||
|
||
|
||
def test_new_old_match(): | ||
diabetes = load_diabetes(as_frame=True) | ||
X = diabetes.data | ||
|
||
ks_old = _deprecated._KennardStone() | ||
ks_new = kennard_stone._KennardStone(n_groups=1) | ||
|
||
assert ks_old._get_indexes(X) == ks_new.get_indexes(X)[0] |