-
Notifications
You must be signed in to change notification settings - Fork 177
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 #266 from nabenabe0928/code-fix/organize-dir-struc…
…ture Organize the directory structure
- Loading branch information
Showing
14 changed files
with
133 additions
and
19 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
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,42 @@ | ||
name: basic_and_faq_usages | ||
|
||
on: | ||
schedule: | ||
- cron: '0 15 * * *' | ||
pull_request: | ||
paths: | ||
- 'basic_and_faq_usages/**' | ||
- '.github/workflows/basic_and_faq_usages.yml' | ||
|
||
jobs: | ||
examples: | ||
if: (github.event_name == 'schedule' && github.repository == 'optuna/optuna-examples') || (github.event_name != 'schedule') | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: setup-python${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install (Python) | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install --progress-bar off -U setuptools | ||
pip install git+https://github.com/optuna/optuna.git | ||
python -c 'import optuna' | ||
pip install -r basic_and_faq_usages/requirements.txt | ||
- name: Run examples | ||
run: | | ||
python basic_and_faq_usages/max_trials_callback.py | ||
python basic_and_faq_usages/enqueue_trial.py | ||
python basic_and_faq_usages/quadratic_simple.py | ||
python basic_and_faq_usages/simple_pruning.py | ||
python basic_and_faq_usages/quadratic_simple_constraint.py | ||
python basic_and_faq_usages/quadratic_simple_multi_objective.py | ||
env: | ||
OMP_NUM_THREADS: 1 |
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,36 @@ | ||
name: base | ||
|
||
on: | ||
schedule: | ||
- cron: '0 15 * * *' | ||
pull_request: | ||
paths: | ||
- 'rapids/**' | ||
- '.github/workflows/rapids.yml' | ||
|
||
jobs: | ||
examples: | ||
if: (github.event_name == 'schedule' && github.repository == 'optuna/optuna-examples') || (github.event_name != 'schedule') | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12'] | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: setup-python${{ matrix.python-version }} | ||
uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install (Python) | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install --progress-bar off -U setuptools | ||
pip install git+https://github.com/optuna/optuna.git | ||
python -c 'import optuna' | ||
- name: Run examples | ||
run: | | ||
python -m py_compile rapids/rapids_simple.py # due to difficulty in importing, compile only | ||
env: | ||
OMP_NUM_THREADS: 1 |
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
""" | ||
Optuna example that optimizes simple quadratic functions. | ||
In this example, we optimize two objective values. | ||
Unlike single-objective optimization, an optimization gives a trade-off between two objectives. | ||
As a result, we get the best trade-offs between two objectives, a.k.a Pareto solutions. | ||
""" | ||
|
||
import optuna | ||
|
||
|
||
# Define two objective functions. | ||
# We would like to minimize f1 and maximize f2. | ||
def objective(trial): | ||
x = trial.suggest_float("x", -100, 100) | ||
y = trial.suggest_categorical("y", [-1, 0, 1]) | ||
f1 = x**2 + y | ||
f2 = -((x - 2) ** 2 + y) | ||
return f1, f2 | ||
|
||
|
||
if __name__ == "__main__": | ||
# We minimize the first objective value and maximize the second objective value. | ||
study = optuna.create_study(directions=["minimize", "maximize"]) | ||
study.optimize(objective, n_trials=500, timeout=1) | ||
|
||
print("Number of finished trials: ", len(study.trials)) | ||
|
||
for i, best_trial in enumerate(study.best_trials): | ||
print("The {}-th Pareto solution was found at Trial#{}.".format(i, best_trial.number)) | ||
print(" Params: {}".format(best_trial.params)) | ||
f1, f2 = best_trial.values | ||
print(" Values: f1={}, f2={}".format(f1, f2)) |
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,3 @@ | ||
optuna | ||
scikit-learn>=0.19.0 | ||
pandas |
File renamed without changes.
File renamed without changes.
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,4 @@ | ||
optuna | ||
scikit-learn>=0.19.0 | ||
cudf | ||
cuml |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
jupyter # used in quickstart.ipynb | ||
pandas # used in max_trials_callback.py | ||
plotly # used in quickstart.ipynb | ||
scikit-learn # used in enqueue_trial.py and quickstart.ipynb | ||
# Used in quickstart.ipynb | ||
jupyter | ||
plotly | ||
scikit-learn |