Skip to content
This repository has been archived by the owner on Jun 28, 2022. It is now read-only.
/ goptuna-bayesopt Public archive

Goptuna sampler for Gaussian Process based bayesian optimization using d4l3k/go-bayesopt.

License

Notifications You must be signed in to change notification settings

c-bata/goptuna-bayesopt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

goptuna-bayesopt

Goptuna sampler for Gaussian Process based bayesian optimization using d4l3k/go-bayesopt. This integration supports SuggestUniform API only.

package main

import (
	"log"
	"math"

	"github.com/c-bata/goptuna"
	bayesopt "github.com/c-bata/goptuna-bayesopt"
)

func objective(trial goptuna.Trial) (float64, error) {
	x1, _ := trial.SuggestUniform("x1", -10, 10)
	x2, _ := trial.SuggestUniform("x2", -10, 10)
	return math.Pow(x1-2, 2) + math.Pow(x2+5, 2), nil
}

func main() {
	relativeSampler := bayesopt.NewSampler()
	study, err := goptuna.CreateStudy(
		"goptuna-example",
		goptuna.StudyOptionRelativeSampler(relativeSampler),
	)
	if err != nil {
		log.Fatal("failed to create study:", err)
	}

	if err = study.Optimize(objective, 50); err != nil {
		log.Fatal("failed to optimize:", err)
	}

	v, _ := study.GetBestValue()
	params, _ := study.GetBestParams()
	log.Printf("Best evaluation=%f (x1=%f, x2=%f)",
		v, params["x1"].(float64), params["x2"].(float64))
}

License

This software is licensed under the MIT license, see LICENSE for more information.

About

Goptuna sampler for Gaussian Process based bayesian optimization using d4l3k/go-bayesopt.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages