Skip to content

Commit

Permalink
Merge pull request #184 from HideakiImamura/fix-mypy-errors-due-to-nu…
Browse files Browse the repository at this point in the history
…mpy-2.2.0

Fix mypy errors due to numpy 2.2.0
  • Loading branch information
nabenabe0928 authored Dec 16, 2024
2 parents b92c134 + 6e42848 commit 4b12939
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/checks_template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ on:
jobs:
checks:
runs-on: ubuntu-latest
if: ${{ !inputs.deprecated }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand All @@ -34,7 +35,6 @@ jobs:
pip install --progress-bar off -U .[test]
- name: Install Integration Dependencies
if: ${{ !inputs.deprecated }}
run: |
pip install --progress-bar off .[${{ inputs.integration_name }}]
Expand Down Expand Up @@ -79,6 +79,7 @@ jobs:
strategy:
matrix:
python-version: ${{ fromJSON(inputs.python_matrix) }}
if: ${{ !inputs.deprecated }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
Expand All @@ -94,7 +95,6 @@ jobs:
pip install --progress-bar off .[test]
- name: Install Integration Dependencies
if: ${{ !inputs.deprecated }}
run: |
pip install --progress-bar off .[${{ inputs.integration_name }}]
Expand Down
2 changes: 1 addition & 1 deletion optuna_integration/_lightgbm_tuner/optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ def sample_train_set(self) -> None:

def tune_feature_fraction(self, n_trials: int = 7) -> None:
param_name = "feature_fraction"
param_values = np.linspace(0.4, 1.0, n_trials).tolist()
param_values = [0.4 + 0.6 * i / (n_trials - 1) for i in range(n_trials)]

sampler = optuna.samplers.GridSampler({param_name: param_values}, seed=self._optuna_seed)
self._tune_params([param_name], len(param_values), sampler, "feature_fraction")
Expand Down
8 changes: 5 additions & 3 deletions optuna_integration/sklearn/sklearn.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def __call__(self, trial: Trial) -> float:
self._store_scores(trial, scores)

test_scores = scores["test_score"]
scores_list = test_scores if isinstance(test_scores, list) else test_scores.tolist()
scores_list = test_scores if isinstance(test_scores, list) else [v for v in test_scores]
try:
report_cross_validation_scores(trial, scores_list)
except ValueError as e:
Expand Down Expand Up @@ -303,10 +303,12 @@ def _cross_validate_with_pruning(

for step in range(self.max_iter):
for i, (train, test) in enumerate(self.cv.split(self.X, self.y, groups=self.groups)):
out = self._partial_fit_and_score(estimators[i], train, test, partial_fit_params)
_out = self._partial_fit_and_score(estimators[i], train, test, partial_fit_params)
out = np.asarray(_out, dtype=np.float64)

if self.return_train_score:
scores["train_score"][i] = out.pop(0)
scores["train_score"][i] = out[0]
out = out[1:]

scores["test_score"][i] = out[0]
scores["fit_time"][i] += out[1]
Expand Down

0 comments on commit 4b12939

Please sign in to comment.