Coder Social home page Coder Social logo

hyperparameter-optimization's People

Contributors

willkoehrsen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

hyperparameter-optimization's Issues

issues with nested data structure in `space`

Hi,
I am following your implementation of hyper-parameter optimization of GBR (in my case). I am getting error when I define a space with nested data structure.

space = {
    'boosting_type': hp.choice('boosting_type', 
                                            [{'boosting_type': 'gbdt', 'subsample': hp.uniform('gbdt_subsample', 0.5, 1)}, 
                                             {'boosting_type': 'dart', 'subsample': hp.uniform('dart_subsample', 0.5, 1)},
                                             {'boosting_type': 'goss', 'subsample': 1.0}]),
    'num_leaves': hp.quniform('num_leaves', 30, 150, 1),
    'learning_rate': hp.loguniform('learning_rate', np.log(0.01), np.log(0.2)),
    'subsample_for_bin': hp.quniform('subsample_for_bin', 20000, 300000, 20000),
    'min_child_samples': hp.quniform('min_child_samples', 20, 500, 5),
    'reg_alpha': hp.uniform('reg_alpha', 0.0, 1.0),
    'reg_lambda': hp.uniform('reg_lambda', 0.0, 1.0),
    'colsample_bytree': hp.uniform('colsample_by_tree', 0.6, 1.0),
    'objective': ['regression']
}

When I run

best = fmin(fn=objective, space= space, algo=tpe_algorithm, max_evals=MAX_EVAL, trials=bayes_trials, rstate=np.random.RandomState(50))

I am getting the following error: (I am pasting only the final error comments rather than the entire Trace which is rather long).

----> 5 best = fmin(fn=objective, space= space, algo=tpe_algorithm, max_evals=MAX_EVAL, trials=bayes_trials, rstate=np.random.RandomState(50))
...
...
TypeError: Unknown type of parameter:boosting_type, got:dict

Any advice will be of value to me.

Thanks

params dict

Hello!

Thank you for the great guide and such a cool tool.
I am a little confused about how to create the params dictionary. I.e. do I just initialize the param values once by calling sample() e.g. in the example below i have called the sample() function within the namespace of the objective function. I assume then that fmin() will deal with subsequent assignments for each param... or am I thinking about this wrong?

Code:

def objective(params = sample(space)):
    """Objective function for AE Hyperparameter Optimization"""
    
    # Keep track of evals
    global ITERATION
    
    ITERATION += 1
    
    #generate parameters
    
    # Make sure parameters that need to be integers are integers
    for parameter_name in ['batch_size']:
        params[parameter_name] = int(params[parameter_name])
    
    start = timer()
    
    # run AE with pre-defined k-fold reps
    out, autoencoder, encoder, decoder =  functionalModel(data=train_ctr.X, batch_size=params['batch_size'], epochs=100, dr=params['dropout'], reg=params['regularization'], lr=params['learning_rate'], optimizer='rmsprop')
    run_time = timer() - start
    
    # Extract the best score (MSE)
    best_score = best_loss = out.history['loss'][-1]
    
    # Loss must be minimized
    loss = best_score

    # Write to the csv file ('a' means append)
    of_connection = open(out_file, 'a')
    writer = csv.writer(of_connection)
    writer.writerow([loss, params, ITERATION, run_time])
    
    # Dictionary with information for evaluation
    return {'loss': loss, 'params': params, 'iteration': ITERATION,
            'train_time': run_time, 'status': STATUS_OK}

#run fmin
from hyperopt import fmin
# Global variable
global  ITERATION

#initialize iteration to 0
ITERATION = 0
#max number of runs of algorithm
MAX_EVALS = 5

# Run optimization
best = fmin(fn = objective, space = space, algo = tpe.suggest, 
            max_evals = MAX_EVALS, trials = bayes_trials, rstate = np.random.RandomState(50))

I ask this before running, as I anticipate long run times, and your response may come back before my own troubleshooting.

Thanks!

Random control

Hi!
I wonder if I can get the same result when I use this library several times(object function,bounds are same)? Because the reproducibility is import for paper.

Best vs mean CV score

Thank you for this helpful notebook. Can you explain why you return the best cv scores in the objective function? Isn't that an overly optimistic (upward bias) measure of performance?
I believe the results of the n_fold cross validations should be averaged and returned as the score/loss. Am I missing something?

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.