Skip to content

Instantly share code, notes, and snippets.

View hvy's full-sized avatar
🏃‍♂️
Focusing

Hiroyuki Vincent Yamazaki hvy

🏃‍♂️
Focusing
View GitHub Profile
@hvy
hvy / binh_and_korn_problem.py
Last active February 27, 2022 06:22
Kurobako multi-objective (MO) sample
from kurobako import problem
class BinhAndKornProblemFactory(problem.ProblemFactory):
def specification(self):
params = [
problem.Var("x", problem.ContinuousRange(0, 5)),
problem.Var("y", problem.ContinuousRange(0, 3)),
]
return problem.ProblemSpec(
import matplotlib.pyplot as plt
import numpy as np
from scipy.stats import norm
from scipy.special import erfcinv
import optuna
def objective(trial):
# Suggest from U(0, 1) with Optuna.
@hvy
hvy / optuna_storage_benchmark.py
Last active January 15, 2021 07:12
Optuna storage benchmark script.
import argparse
import math
import time
import sqlalchemy
import optuna
class Profile:
@hvy
hvy / hpi_evaluatior_comparison_lightgbm.py
Last active September 8, 2020 06:32
Optuna HPI comparisons
import lightgbm as lgb
import numpy as np
import pandas as pd
import sklearn.datasets
from sklearn.datasets import fetch_openml
import sklearn.metrics
from sklearn.model_selection import train_test_split
import optuna
import optuna
def objective(trial):
x = trial.suggest_int("x", 0, 2)
y = trial.suggest_float("y", -1.0, 1.0)
z = trial.suggest_float("z", 0.0, 1.5)
return x ** 2 + y ** 3 - z ** 4
study = optuna.create_study(sampler=optuna.samplers.RandomSampler())
study.optimize(objective, n_trials=100)
@hvy
hvy / Dockerfile
Created July 5, 2020 05:47
Linking user compiled SQLite from Python to reproduce "too many variables" error in Optuna.
FROM optuna/optuna:py3.7-dev
RUN apt-get update
# Compile sqlite with a low SQLITE_MAX_VARIABLE_NUMBER.
RUN mkdir sqlite3_tmp
WORKDIR sqlite3_tmp
RUN wget https://www.sqlite.org/src/tarball/sqlite.tar.gz
RUN tar zxf sqlite.tar.gz
ENV CFLAGS -DSQLITE_ENABLE_FTS3 \
import os
import optuna
from optuna import visualization
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import torch.utils.data
from torchvision import datasets
@hvy
hvy / fanova_comparison.py
Created April 7, 2020 12:40
Plots importances evaluated by fANOVA (AutoML.org) and Fanova (sklearn based implementation).
"""
Plots importances evaluated by fANOVA (AutoML.org) and Fanova (sklearn based implementation).
1. Loads data from csv containing parameter configuration-objective value pairs.
2. Loads search space definitions from csv.
3. Evaluates all single and pairwise importances between parameters.
4. Repeats evaluation N times (with different random seeds).
5. Plots the average over N evaluations.
"""
import argparse
from collections import OrderedDict
import time
from matplotlib import pyplot as plt
import optuna
from optuna import samplers
from optuna.storages import RDBStorage
from optuna.storages import RedisStorage
@hvy
hvy / logging_tqdm_multiprocessing.py
Created January 30, 2020 01:33
Experimental `joblib.register_parallel_backend` to render progress bar.
import logging
import threading
import time
import joblib
import tqdm
class TqdmLoggingHandler(logging.StreamHandler):
def emit(self, record):