hypernets.core package

Submodules

hypernets.core.callbacks module

class hypernets.core.callbacks.Callback[source]

Bases: object

on_build_estimator(hyper_model, space, estimator, trial_no)[source]
on_search_end(hyper_model)[source]
on_search_error(hyper_model)[source]
on_search_start(hyper_model, X, y, X_eval, y_eval, cv, num_folds, max_trials, dataset_id, trial_store, **fit_kwargs)[source]
on_skip_trial(hyper_model, space, trial_no, reason, reward, improved, elapsed)[source]
on_trial_begin(hyper_model, space, trial_no)[source]
on_trial_end(hyper_model, space, trial_no, reward, improved, elapsed)[source]
on_trial_error(hyper_model, space, trial_no)[source]
class hypernets.core.callbacks.EarlyStoppingCallback(max_no_improvement_trials=0, mode='min', min_delta=0, time_limit=None, expected_reward=None)[source]

Bases: hypernets.core.callbacks.Callback

REASON_EXPECTED_REWARD = 'expected_reward'
REASON_TIME_LIMIT = 'time_limit'
REASON_TRIAL_LIMIT = 'max_no_improvement_trials'
on_search_start(hyper_model, X, y, X_eval, y_eval, cv, num_folds, max_trials, dataset_id, trial_store, **fit_kwargs)[source]
on_trial_begin(hyper_model, space, trial_no)[source]
on_trial_end(hyper_model, space, trial_no, reward, improved, elapsed)[source]
exception hypernets.core.callbacks.EarlyStoppingError(*arg)[source]

Bases: RuntimeError

class hypernets.core.callbacks.FileLoggingCallback(searcher, output_dir=None)[source]

Bases: hypernets.core.callbacks.Callback

static mkdirs(dir_path, exist_ok)[source]
on_build_estimator(hyper_model, space, estimator, trial_no)[source]
on_skip_trial(hyper_model, space, trial_no, reason, reward, improved, elapsed)[source]
on_trial_begin(hyper_model, space, trial_no)[source]
on_trial_end(hyper_model, space, trial_no, reward, improved, elapsed)[source]
static open(file_path, mode)[source]
class hypernets.core.callbacks.FileStorageLoggingCallback(searcher, output_dir=None)[source]

Bases: hypernets.core.callbacks.FileLoggingCallback

static mkdirs(dir_path, exist_ok)[source]
static open(file_path, mode)[source]
class hypernets.core.callbacks.NotebookCallback[source]

Bases: hypernets.core.callbacks.Callback

on_search_end(hyper_model)[source]
on_search_start(hyper_model, X, y, X_eval, y_eval, cv, num_folds, max_trials, dataset_id, trial_store, **fit_kwargs)[source]
on_trial_begin(hyper_model, space, trial_no)[source]
on_trial_end(hyper_model, space, trial_no, reward, improved, elapsed)[source]
on_trial_error(hyper_model, space, trial_no)[source]
class hypernets.core.callbacks.ProgressiveCallback[source]

Bases: hypernets.core.callbacks.Callback

on_search_end(hyper_model)[source]
on_search_error(hyper_model)[source]
on_search_start(hyper_model, X, y, X_eval, y_eval, cv, num_folds, max_trials, dataset_id, trial_store, **fit_kwargs)[source]
on_trial_end(hyper_model, space, trial_no, reward, improved, elapsed)[source]
on_trial_error(hyper_model, space, trial_no)[source]
class hypernets.core.callbacks.SummaryCallback[source]

Bases: hypernets.core.callbacks.Callback

on_build_estimator(hyper_model, space, estimator, trial_no)[source]
on_search_start(hyper_model, X, y, X_eval, y_eval, cv, num_folds, max_trials, dataset_id, trial_store, **fit_kwargs)[source]
on_skip_trial(hyper_model, space, trial_no, reason, reward, improved, elapsed)[source]
on_trial_begin(hyper_model, space, trial_no)[source]
on_trial_end(hyper_model, space, trial_no, reward, improved, elapsed)[source]

hypernets.core.config module

hypernets.core.context module

class hypernets.core.context.Context[source]

Bases: object

get(key)[source]
put(key, value)[source]
class hypernets.core.context.DefaultContext[source]

Bases: hypernets.core.context.Context

get(key)[source]
put(key, value)[source]

hypernets.core.dispatcher module

class hypernets.core.dispatcher.Dispatcher[source]

Bases: object

dispatch(hyper_model, X, y, X_val, y_val, X_test, cv, num_folds, max_trials, dataset_id, trial_store, **fit_kwargs)[source]

hypernets.core.meta_learner module

class hypernets.core.meta_learner.MetaLearner(history, dataset_id, trial_store)[source]

Bases: object

extract_features_and_labels(signature)[source]
fit(space_signature)[source]
new_sample(space_sample)[source]
predict(space_sample, default_value=inf)[source]

hypernets.core.mutables module

class hypernets.core.mutables.Mutable(scope, name=None)[source]

Bases: object

attach_to_scope(scope, name=None)[source]
id
type
update()[source]
class hypernets.core.mutables.MutableScope[source]

Bases: object

assign_id(mutable)[source]
current_path
entry(name)[source]
exit()[source]
get_mutable(id)[source]
get_mutable_by_name(name)[source]
register(mutable)[source]
reset()[source]

hypernets.core.objective module

class hypernets.core.objective.Objective(name, direction, need_train_data=False, need_val_data=True, need_test_data=False)[source]

Bases: object

Objective = Indicator metric + Direction

evaluate(trial, estimator, X_train, y_train, X_val, y_val, X_test=None, **kwargs) → float[source]
evaluate_cv(trial, estimator, X_trains, y_trains, X_vals, y_vals, X_test=None, **kwargs) → float[source]

hypernets.core.ops module

class hypernets.core.ops.ConnectLooseEnd(inputs, keep_link=False, space=None, name=None)[source]

Bases: hypernets.core.ops.ConnectionSpace

class hypernets.core.ops.ConnectionSpace(dynamic_fn, keep_link=False, space=None, name=None, **hyperparams)[source]

Bases: hypernets.core.search_space.ModuleSpace

connect_module_or_subgraph(from_module, to_module, support_subgraph=True)[source]
class hypernets.core.ops.HyperInput(space=None, name=None, **hyperparams)[source]

Bases: hypernets.core.search_space.ModuleSpace

class hypernets.core.ops.Identity(space=None, name=None, **hyperparams)[source]

Bases: hypernets.core.search_space.ModuleSpace

class hypernets.core.ops.InputChoice(inputs, num_chosen_most=0, num_chosen_least=1, keep_link=False, space=None, name=None, hp_choice=None)[source]

Bases: hypernets.core.ops.ConnectionSpace

class hypernets.core.ops.ModuleChoice(module_list, keep_link=False, space=None, name=None, hp_or=None)[source]

Bases: hypernets.core.ops.ConnectionSpace

or_fn(m)[source]
class hypernets.core.ops.Optional(module, keep_link=False, space=None, name=None, hp_opt=None)[source]

Bases: hypernets.core.ops.ConnectionSpace

optional_fn(m)[source]
class hypernets.core.ops.Permutation(module_list, keep_link=False, space=None, name=None, hp_seq=None)[source]

Bases: hypernets.core.ops.ConnectionSpace

permutation_fn(m)[source]
class hypernets.core.ops.Reduction(reduction_op, space=None, name=None, **hyperparams)[source]

Bases: hypernets.core.search_space.ModuleSpace

class hypernets.core.ops.Repeat(module_fn, keep_link=False, space=None, name=None, repeat_times=[1])[source]

Bases: hypernets.core.ops.ConnectionSpace

repeat_fn(m)[source]
class hypernets.core.ops.Sequential(module_list, keep_link=False, space=None, name=None)[source]

Bases: hypernets.core.ops.ConnectionSpace

sequential_fn(m)[source]

hypernets.core.pareto module

hypernets.core.pareto.calc_nondominated_set(solutions: numpy.ndarray, dominate_func=None, directions=None)[source]
hypernets.core.pareto.pareto_dominate(x1, x2, directions=None)[source]

dominance in pareto scene, if x1 dominate x2 return True.

hypernets.core.random_state module

hypernets.core.random_state.get_random_state()[source]
hypernets.core.random_state.randint()[source]
hypernets.core.random_state.set_random_state(seed)[source]

hypernets.core.search_space module

class hypernets.core.search_space.Bool(random_state=None, space=None, name=None)[source]

Bases: hypernets.core.search_space.Choice

class hypernets.core.search_space.Cascade(lambda_fn, space=None, name=None, **param_dict)[source]

Bases: hypernets.core.search_space.ParameterSpace

assigned
is_mutable
param_dict
update()[source]
class hypernets.core.search_space.Choice(options, random_state=None, space=None, name=None)[source]

Bases: hypernets.core.search_space.ParameterSpace

config_keys
expansion(sample_num=0)[source]
is_mutable
numeric2value(numeric)[source]
value2numeric(value)[source]
class hypernets.core.search_space.Constant(value, space=None, name=None)[source]

Bases: hypernets.core.search_space.ParameterSpace

config_keys
is_mutable
class hypernets.core.search_space.DefaultSpaceStack[source]

Bases: hypernets.core.search_space.DefaultStack

get_default()[source]

Override that returns a global default if the stack is empty.

reset()[source]
class hypernets.core.search_space.DefaultStack[source]

Bases: _thread._local

get_controller(default)[source]
get_default()[source]
is_cleared()[source]
reset()[source]
class hypernets.core.search_space.Dynamic(lambda_fn, space=None, name=None, **param_dict)[source]

Bases: hypernets.core.search_space.ParameterSpace

is_mutable
param_dict
update()[source]
class hypernets.core.search_space.HyperNode(space=None, name=None)[source]

Bases: hypernets.core.mutables.Mutable

attach_to_space(space=None, name=None)[source]
space
class hypernets.core.search_space.HyperSpace(scope=None, name=None)[source]

Bases: hypernets.core.mutables.Mutable

add_node(node)[source]
all_assigned
as_default()[source]
assign_by_vectors(vectors)[source]
assigned_params_stack
combinations
compile(deepcopy=True)[source]
compile_and_forward(inputs=None, deepcopy=True)[source]
connect(from_module, to_module)[source]
disconnect(from_module, to_module)[source]
disconnect_all(module)[source]
forward(inputs=None)[source]
get_all_params()[source]
get_assigned_param_values(traverse_direction='forward')[source]
get_assigned_params()[source]
get_inputs(module=None, discard_isolated_node=True)[source]
get_outputs(module=None, discard_isolated_node=True)[source]
get_sub_graph_end_modules(module_in_subgraph, direction='forward')[source]
get_sub_graph_inputs(module_in_subgraph)[source]
get_sub_graph_outputs(module_in_subgraph)[source]
get_unassigned_params(traverse_direction='forward')[source]
is_isolated_module(module)[source]
params_iterator
params_summary(only_assignable=True, line_width=60, LR='\n')[source]
push_assigned_param(param)[source]
random_sample()[source]
replace_route(old_module, new_module)[source]
reroute_from(old_module, new_module)[source]
reroute_to(old_module, new_module)[source]
set_inputs(modules)[source]
set_outputs(modules)[source]
signature
traverse(fn, direction='forward', start_modules=[], discard_isolated_node=True)[source]
type
vectors
class hypernets.core.search_space.Int(low, high, step=1, random_state=None, space=None, name=None)[source]

Bases: hypernets.core.search_space.ParameterSpace

config_keys
expansion(sample_num)[source]
numeric2value(numeric)[source]
value2numeric(value)[source]
class hypernets.core.search_space.ModuleSpace(space=None, name=None, **hyperparams)[source]

Bases: hypernets.core.search_space.HyperNode

add_parameters(**hyperparameters)[source]
all_assigned
compile()[source]
compile_and_forward(inputs=None)[source]
connect(module_or_list)[source]
forward(inputs=None)[source]
get_all_params()[source]
get_assignable_params()[source]
hyper_params
is_compiled
is_params_ready
output
param_values
type
update()[source]
class hypernets.core.search_space.MultipleChoice(options, num_chosen_most=0, num_chosen_least=1, random_state=None, space=None, name=None)[source]

Bases: hypernets.core.search_space.ParameterSpace

config_keys
expansion(sample_num)[source]
numeric2value(numeric)[source]
value2numeric(value)[source]
class hypernets.core.search_space.ParameterSpace(space=None, name=None, random_state=None)[source]

Bases: hypernets.core.search_space.HyperNode

assign(value)[source]
assigned
attach(mutable, alias=None)[source]
choice_num
config_keys
detach(mutable)[source]
expansion(sample_num)[source]
is_mutable
label
numeric2value(numeric)[source]
random_sample(assign=True)[source]
same_config(other)[source]
type
value
value2numeric(value)[source]
class hypernets.core.search_space.Real(low, high, q=None, prior='uniform', step=0.01, max_expansion=100, random_state=None, space=None, name=None)[source]

Bases: hypernets.core.search_space.ParameterSpace

config_keys
expansion(sample_num)[source]
numeric2value(numeric)[source]
value2numeric(value)[source]
hypernets.core.search_space.get_default_space()[source]

hypernets.core.searcher module

class hypernets.core.searcher.OptimizeDirection[source]

Bases: enum.Enum

An enumeration.

Maximize = 'max'
Minimize = 'min'
class hypernets.core.searcher.Searcher(space_fn, optimize_direction=<OptimizeDirection.Minimize: 'min'>, use_meta_learner=True, space_sample_validation_fn=None)[source]

Bases: hypernets.core.stateful.Stateful

export()[source]
get_best()[source]
kind()[source]

Type of the Searcher, should be one of soo, moo. This property used to avoid having to import MOOSearcher when detecting Searcher type.

parallelizable
reset()[source]
sample(space_options=None)[source]
set_meta_learner(meta_learner)[source]
summary()[source]
update_result(space, result)[source]

hypernets.core.stateful module

class hypernets.core.stateful.Stateful[source]

Bases: object

get_state_path()[source]
load_state()[source]
save_state()[source]

hypernets.core.trial module

class hypernets.core.trial.DiskTrialStore(home_dir=None)[source]

Bases: hypernets.core.trial.TrialStore

clear_history()[source]
get_all(dataset_id, space_signature)[source]
get_trial_path(dataset_id, space_sample)[source]
load()[source]
persist()[source]
prepare_home_dir(home_dir)[source]
reset()[source]
class hypernets.core.trial.DominateBasedTrialHistory(directions, objective_names)[source]

Bases: hypernets.core.trial.TrialHistory

append(trial)[source]
get_best()[source]
plot_best_trials(index=True, figsize=(5, 5), loc=None, bbox_to_anchor=None, xlim=None, ylim=None)[source]
to_df(include_params=False)[source]
class hypernets.core.trial.Trial(space_sample, trial_no, reward=None, elapsed=None, model_file=None, succeeded=True)[source]

Bases: object

get_model()[source]
to_df(include_params=False)[source]
class hypernets.core.trial.TrialHistory(optimize_direction)[source]

Bases: object

append(trial)[source]
diff(trials)[source]
get_best()[source]
get_space_signatures()[source]
get_top(n=None)[source]
get_trajectories()[source]
get_trial(space_sample)[source]
get_worst()[source]
is_existed(space_sample)[source]
static load_history(space_fn, filepath)[source]
plot_hyperparams(destination='notebook', output='hyperparams.html')[source]

Plot hyperparams in a parallel line chart

Parameters:
  • destination – one of notebook, html
  • output – the html file path

Returns:

save(filepath)[source]
to_df(include_params=False)[source]
class hypernets.core.trial.TrialStore[source]

Bases: object

check_trial(trial)[source]
get(dataset_id, space_sample)[source]
get_all(dataset_id, space_signature)[source]
get_from_cache(dataset_id, space_sample)[source]
load()[source]
persist()[source]
put(dataset_id, trial)[source]
put_to_cache(dataset_id, trial)[source]
reset()[source]
sample2key(space_sample)[source]
hypernets.core.trial.get_default_trial_store()[source]
hypernets.core.trial.set_default_trial_store(trial_store)[source]

Module contents