google / vizier

Python-based research interface for blackbox and hyperparameter optimization, based on the internal Google Vizier Service.

Home Page:https://oss-vizier.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to get Gaussian Process?

Rizhiy opened this issue · comments

I have installed, the extra version (pip install google-vizier[extra]), but get the error: Exception calling application: Algorithm GAUSSIAN_PROCESS_BANDIT is not registered.

Using example code, only with algorithm changed:

from scipy.optimize import rosen
from vizier.service import clients
from vizier.service import pyvizier as vz
from vizier.service import vizier_service

problem = vz.ProblemStatement()
problem.search_space.root.add_float_param("x", -5, 5)
problem.search_space.root.add_float_param("y", -5, 5)
problem.metric_information.append(
    vz.MetricInformation(name="maximize_metric", goal=vz.ObjectiveMetricGoal.MINIMIZE)
)


def evaluate(x: float, y: float) -> float:
    return rosen([x, y])


study_config = vz.StudyConfig.from_problem(problem)
study_config.algorithm = vz.Algorithm.GAUSSIAN_PROCESS_BANDIT

service = vizier_service.DefaultVizierService()

clients.environment_variables.service_endpoint = service.endpoint  # Server address.
study_client = clients.Study.from_study_config(study_config, owner="owner", study_id="example_study_id")

suggestions = study_client.suggest(count=5)
for suggestion in suggestions:
    x = suggestion.parameters["x"]
    y = suggestion.parameters["y"]
    print("Suggested Parameters (x,y):", x, y)
    final_measurement = vz.Measurement({"maximize_metric": evaluate(x, y)})
    suggestion.complete(final_measurement)

for optimal_trial in study_client.optimal_trials():
    optimal_trial = optimal_trial.materialize()
    print(
        "Optimal Trial Suggestion and Objective:", optimal_trial.parameters, optimal_trial.final_measurement
    )

Hi @Rizhiy, thanks for your interest. Sorry about the confusion, currently we're still in the middle of open-sourcing the GAUSSIAN_PROCESS_BANDIT algorithm, and it's not available right now. We expect it to be out within a month or so.

Thanks!

  • Richard

Hi @Rizhiy, we're happy to announce that GAUSSIAN_PROCESS_BANDIT is now available in 0.1.0!