Code Monkey home page Code Monkey logo

Comments (2)

willytell avatar willytell commented on July 28, 2024 2

Excellent explanation!! thank you!!

Just for the records, for whom could have the same or a similar question, I ran the next simple code:

import sklearn
import math
import optuna
import pandas as pd 

def objective(trial):
    
    x = trial.suggest_int("x", 2, 150)
    y = trial.suggest_int("y", 2, 100)
    
    score1 = x**2 - y**2
    score2 = math.sin(y)
    return score1, score2

sampler = optuna.samplers.NSGAIISampler(population_size=50)
study = optuna.create_study(study_name='studyTest', 
                            directions=["minimize", "minimize"],
                            sampler=sampler)
study.optimize(objective, n_trials=100)

df = study.trials_dataframe() 
df.to_csv("test.csv", sep=';', index=False)`

In "test.csv" there is the information that @toshihikoyanase put in the table above and it is possible to make the relationship between the number of generations and the number of trials, that he has explained. Thank you for the extra bonus, that is the mention about "two optimization processes".

from optuna-examples.

toshihikoyanase avatar toshihikoyanase commented on July 28, 2024 1

Thank you for your question.

By default the population_size=50, but if then I define n_trials=10, then this algorithm is like a random search

You're right. If all trials successfully finish, the relationship between the trials and generations is as follows:

Trials Generation Sampler
[0, 49] 0 NSGAIISampler calls RandomSampler internally.
[50, 99] 1 NSGAIISampler
[100, 149] 2 NSGAIISampler

where is this number specified?

Please use the n_trials argument of Study.optimize. If you want G generations with P individuals in population, then please set n_trials = P * G. Optuna chooses this design in order for users to parallelize the optimization. When users launch two optimization processes then they should set n_trials = P * G / 2.

from optuna-examples.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.