neuraxle.metaopt.data.vanilla¶
Module-level documentation for neuraxle.metaopt.data.vanilla. Here is an inheritance diagram, including dependencies to other base modules of Neuraxle:

Neuraxle’s Base Hyperparameter Repository Classes¶
Data objects and related repositories used by AutoML.
Classes are splitted like this for the AutoML: - Projects - Clients - Rounds (runs) - Trials - TrialSplits - MetricResults
Functions
|
|
|
|
|
|
|
|
|
Classes
|
|
|
|
|
Mixin class for |
|
|
Hyperparams repository that saves hyperparams, and scores for every AutoML trial. |
|
|
In memory hyperparams repository that can print information about trials. |
|
|
|
MetricResult object used by AutoML algorithm classes. |
|
|
|
|
|
|
|
A location in the metadata tree. |
|
This class is a data structure most often used under |
|
TrialSplit object used by AutoML algorithm classes. |
|
Hyperparams repository that saves data AutoML-related info. |
-
class
neuraxle.metaopt.data.vanilla.
ScopedLocation
(project_name: str = None, client_name: str = None, round_number: int = None, trial_number: int = None, split_number: int = None, metric_name: str = None)[source]¶ Bases:
neuraxle.base.BaseService
A location in the metadata tree.
-
project_name
= None¶
-
client_name
= None¶
-
round_number
= None¶
-
trial_number
= None¶
-
split_number
= None¶
-
metric_name
= None¶
-
copy
() → neuraxle.metaopt.data.vanilla.ScopedLocation[source]¶ Returns a copy of the
ScopedLocation
.
-
with_dc
(dc: neuraxle.metaopt.data.vanilla.BaseDataclass) → neuraxle.metaopt.data.vanilla.ScopedLocation[source]¶ Returns a new
ScopedLocation
with the providedBaseDataclass
(dc) type’s id added.
-
with_id
(_id: Union[str, int]) → neuraxle.metaopt.data.vanilla.ScopedLocation[source]¶ Returns a longer
ScopedLocation
with the provided id added at the end.
-
at_dc
(dc: neuraxle.metaopt.data.vanilla.BaseDataclass) → neuraxle.metaopt.data.vanilla.ScopedLocation[source]¶ Returns a trimmed
ScopedLocation
with the providedBaseDataclass
(dc) type’s id as the ScopedLocation’s deepest attribute.
-
static
default_full
() → neuraxle.metaopt.data.vanilla.ScopedLocation[source]¶ Returns a
ScopedLocation
with all attributes set to the default non-null value instead of None.
-
static
default
(round_number: Optional[int] = None, trial_number: Optional[int] = None, split_number: Optional[int] = None, metric_name: Optional[str] = None) → neuraxle.metaopt.data.vanilla.ScopedLocation[source]¶ Returns the default
ScopedLocation
. That is:
-
peek
() → Union[str, int][source]¶ Pop without removing the last element: return the last non-None element.
-
pop
() → Union[str, int][source]¶ Returns the last not None scoped location attribute and remove it from self.
-
popped
() → neuraxle.metaopt.data.vanilla.ScopedLocation[source]¶ Returns a new
ScopedLocation
with the last not None scoped location attribute removed.
-
as_list
(stringify: bool = False) → List[Union[int, str]][source]¶ Returns a list of the scoped location attributes. Item that has a value of None are not included in the list.
- Parameters
stringify (
bool
) – If True, the scoped location attributes are converted to strings.- Returns
list of not none scoped location attributes
-
new_dataclass_from_id
()[source]¶ Creates a new
BaseDataclass
of the right type with just the provided ID filled.
-
__init__
(project_name: str = None, client_name: str = None, round_number: int = None, trial_number: int = None, split_number: int = None, metric_name: str = None) → None¶
-
_abc_impl
= <_abc_data object>¶
-
-
class
neuraxle.metaopt.data.vanilla.
BaseDataclass
(*args, **kwds)[source]¶ Bases:
typing.Generic
,abc.ABC
-
_id_attr_name
¶
-
_sublocation_attr_name
¶
-
set_sublocation
(sublocation: Union[List[SubDataclassT], OrderedDict[str, SubDataclassT]]) → BaseDataclass[source]¶
-
set_sublocation_keys
(keys: List[Union[int, str]]) → neuraxle.metaopt.data.vanilla.BaseDataclass[source]¶ Use this to set a shallow sublocation only from their keys.
-
store
(dc: SubDataclassT) → Union[str, int][source]¶ Add a subdataclass to the sublocation, at its proper ID.
-
shallow
() → neuraxle.metaopt.data.vanilla.BaseDataclass[source]¶ Replaces the sublocation items with None when the sublocation is a BaseDataclass type.
-
empty
() → neuraxle.metaopt.data.vanilla.BaseDataclass[source]¶ Do empty the sublocation when the sublocation is a BaseDataclass type.
-
__init__
() → None¶
-
_abc_impl
= <_abc_data object>¶
-
-
class
neuraxle.metaopt.data.vanilla.
DataclassHasOrderedDictMixin
[source]¶ Bases:
object
-
set_sublocation_keys
(keys: List[Union[int, str]]) → neuraxle.metaopt.data.vanilla.BaseDataclass[source]¶
-
__init__
() → None¶
-
-
class
neuraxle.metaopt.data.vanilla.
DataclassHasListMixin
[source]¶ Bases:
object
-
set_sublocation_keys
(keys: List[Union[int, str]]) → neuraxle.metaopt.data.vanilla.BaseDataclass[source]¶
-
__init__
() → None¶
-
-
class
neuraxle.metaopt.data.vanilla.
BaseTrialDataclassMixin
(hyperparams: neuraxle.hyperparams.space.HyperparameterSamples = <factory>, status: neuraxle.base.TrialStatus = <TrialStatus.PLANNED: 'PLANNED'>, created_time: datetime.datetime = <factory>, start_time: datetime.datetime = <factory>, end_time: datetime.datetime = None)[source]¶ Bases:
object
Mixin class for
TrialMetadata
andTrialSplitMetadata
that also must inherit fromBaseMetadata
.-
end_time
= None¶
-
end
(status: neuraxle.base.TrialStatus) → neuraxle.metaopt.data.vanilla.BaseTrialDataclassMixin[source]¶
-
__init__
(hyperparams: neuraxle.hyperparams.space.HyperparameterSamples = <factory>, status: neuraxle.base.TrialStatus = <TrialStatus.PLANNED: 'PLANNED'>, created_time: datetime.datetime = <factory>, start_time: datetime.datetime = <factory>, end_time: datetime.datetime = None) → None¶
-
-
class
neuraxle.metaopt.data.vanilla.
RootDataclass
(*args, **kwds)[source]¶ Bases:
neuraxle.metaopt.data.vanilla.DataclassHasOrderedDictMixin
,neuraxle.metaopt.data.vanilla.BaseDataclass
-
_id_attr_name
¶
-
_sublocation_attr_name
¶
-
__init__
(projects: OrderedDict[str, ProjectDataclass] = <factory>) → None¶
-
_abc_impl
= <_abc_data object>¶
-
-
class
neuraxle.metaopt.data.vanilla.
ProjectDataclass
(*args, **kwds)[source]¶ Bases:
neuraxle.metaopt.data.vanilla.DataclassHasOrderedDictMixin
,neuraxle.metaopt.data.vanilla.BaseDataclass
-
project_name
= 'default_project'¶
-
__init__
(project_name: str = 'default_project', clients: OrderedDict[str, ClientDataclass] = <factory>) → None¶
-
_abc_impl
= <_abc_data object>¶
-
-
class
neuraxle.metaopt.data.vanilla.
ClientDataclass
(*args, **kwds)[source]¶ Bases:
neuraxle.metaopt.data.vanilla.DataclassHasListMixin
,neuraxle.metaopt.data.vanilla.BaseDataclass
-
client_name
= 'default_client'¶
-
__init__
(client_name: str = 'default_client', rounds: List[RoundDataclass] = <factory>) → None¶
-
_abc_impl
= <_abc_data object>¶
-
-
class
neuraxle.metaopt.data.vanilla.
RoundDataclass
(*args, **kwds)[source]¶ Bases:
neuraxle.metaopt.data.vanilla.DataclassHasListMixin
,neuraxle.metaopt.data.vanilla.BaseDataclass
-
round_number
= 0¶
-
main_metric_name
= None¶
-
__init__
(round_number: int = 0, trials: List[TrialDataclass] = <factory>, main_metric_name: str = None) → None¶
-
_abc_impl
= <_abc_data object>¶
-
-
class
neuraxle.metaopt.data.vanilla.
TrialDataclass
(hyperparams: neuraxle.hyperparams.space.HyperparameterSamples = <factory>, status: neuraxle.base.TrialStatus = <TrialStatus.PLANNED: 'PLANNED'>, created_time: datetime.datetime = <factory>, start_time: datetime.datetime = <factory>, end_time: datetime.datetime = None, trial_number: int = 0, validation_splits: List[TrialSplitDataclass] = <factory>, retrained_split: TrialSplitDataclass = None)[source]¶ Bases:
neuraxle.metaopt.data.vanilla.DataclassHasListMixin
,neuraxle.metaopt.data.vanilla.BaseTrialDataclassMixin
,neuraxle.metaopt.data.vanilla.BaseDataclass
This class is a data structure most often used under
AutoML
to store information about a trial. This information is itself managed by theHyperparameterRepository
class and theTrial
class within the AutoML.-
trial_number
= 0¶
-
retrained_split
= None¶
-
set_sublocation_keys
(keys: List[Union[int, str]]) → neuraxle.metaopt.data.vanilla.BaseDataclass[source]¶ Use this to set a shallow sublocation only from their keys.
-
shallow
() → neuraxle.metaopt.data.vanilla.BaseDataclass[source]¶ Replaces the sublocation items with None when the sublocation is a BaseDataclass type.
-
__init__
(hyperparams: neuraxle.hyperparams.space.HyperparameterSamples = <factory>, status: neuraxle.base.TrialStatus = <TrialStatus.PLANNED: 'PLANNED'>, created_time: datetime.datetime = <factory>, start_time: datetime.datetime = <factory>, end_time: datetime.datetime = None, trial_number: int = 0, validation_splits: List[TrialSplitDataclass] = <factory>, retrained_split: TrialSplitDataclass = None) → None¶
-
_abc_impl
= <_abc_data object>¶
-
-
class
neuraxle.metaopt.data.vanilla.
TrialSplitDataclass
(hyperparams: neuraxle.hyperparams.space.HyperparameterSamples = <factory>, status: neuraxle.base.TrialStatus = <TrialStatus.PLANNED: 'PLANNED'>, created_time: datetime.datetime = <factory>, start_time: datetime.datetime = <factory>, end_time: datetime.datetime = None, split_number: int = 0, metric_results: OrderedDict[str, MetricResultsDataclass] = <factory>)[source]¶ Bases:
neuraxle.metaopt.data.vanilla.DataclassHasOrderedDictMixin
,neuraxle.metaopt.data.vanilla.BaseTrialDataclassMixin
,neuraxle.metaopt.data.vanilla.BaseDataclass
TrialSplit object used by AutoML algorithm classes.
-
split_number
= 0¶
-
__init__
(hyperparams: neuraxle.hyperparams.space.HyperparameterSamples = <factory>, status: neuraxle.base.TrialStatus = <TrialStatus.PLANNED: 'PLANNED'>, created_time: datetime.datetime = <factory>, start_time: datetime.datetime = <factory>, end_time: datetime.datetime = None, split_number: int = 0, metric_results: OrderedDict[str, MetricResultsDataclass] = <factory>) → None¶
-
_abc_impl
= <_abc_data object>¶
-
-
class
neuraxle.metaopt.data.vanilla.
MetricResultsDataclass
(metric_name: str = 'main', validation_values: List[float] = <factory>, train_values: List[float] = <factory>, higher_score_is_better: bool = True)[source]¶ Bases:
neuraxle.metaopt.data.vanilla.DataclassHasListMixin
,neuraxle.metaopt.data.vanilla.BaseDataclass
MetricResult object used by AutoML algorithm classes.
-
metric_name
= 'main'¶
-
higher_score_is_better
= True¶
-
shallow
() → neuraxle.metaopt.data.vanilla.BaseDataclass[source]¶ Replaces the sublocation items with None when the sublocation is a BaseDataclass type.
-
empty
() → neuraxle.metaopt.data.vanilla.BaseDataclass[source]¶ Do empty the sublocation when the sublocation is a BaseDataclass type.
-
__init__
(metric_name: str = 'main', validation_values: List[float] = <factory>, train_values: List[float] = <factory>, higher_score_is_better: bool = True) → None¶
-
_abc_impl
= <_abc_data object>¶
-
-
neuraxle.metaopt.data.vanilla.
as_named_odict
(obj: Union[neuraxle.metaopt.data.vanilla.BaseDataclass, List[neuraxle.metaopt.data.vanilla.BaseDataclass]]) → OrderedDict[ScopedLocationAttrStr, BaseDataclass][source]¶
-
class
neuraxle.metaopt.data.vanilla.
MetadataJSONEncoder
(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]¶ Bases:
json.encoder.JSONEncoder
-
default
(o)[source]¶ Implement this method in a subclass such that it returns a serializable object for
o
, or calls the base implementation (to raise aTypeError
).For example, to support arbitrary iterators, you could implement default like this:
def default(self, o): try: iterable = iter(o) except TypeError: pass else: return list(iterable) # Let the base class default method raise the TypeError return JSONEncoder.default(self, o)
-
-
neuraxle.metaopt.data.vanilla.
to_json
(obj: neuraxle.metaopt.data.vanilla.BaseDataclass) → str[source]¶
-
neuraxle.metaopt.data.vanilla.
from_json
(_json: str) → neuraxle.metaopt.data.vanilla.BaseDataclass[source]¶
-
class
neuraxle.metaopt.data.vanilla.
HyperparamsRepository
[source]¶ Bases:
neuraxle.metaopt.observable._ObservableRepo
,neuraxle.base.BaseService
Hyperparams repository that saves hyperparams, and scores for every AutoML trial. Cache folder can be changed to do different round numbers.
For more information, read this article by Martin Fowler on DDD Aggregates.
See also
AutoML
,Trainer
,-
load
(scope: neuraxle.metaopt.data.vanilla.ScopedLocation, deep=False) → SubDataclassT[source]¶ Get metadata from scope.
The fetched metadata will be the one that is the last item that is not a None in the provided scope.
- Parameters
scope (
ScopedLocation
) – scope to get metadata from.- Returns
metadata from scope.
-
save
(_dataclass: SubDataclassT, scope: neuraxle.metaopt.data.vanilla.ScopedLocation, deep=False) → neuraxle.metaopt.data.vanilla.HyperparamsRepository[source]¶ Save metadata to scope.
- Parameters
metadata – metadata to save.
scope (
ScopedLocation
) – scope to save metadata to.deep (
bool
) – if True, save metadata’s sublocations recursively.
-
add_logging_handler
(logger: neuraxle.logging.logging.NeuraxleLogger, scope: neuraxle.metaopt.data.vanilla.ScopedLocation) → neuraxle.metaopt.data.vanilla.HyperparamsRepository[source]¶ Add logging handler to repository’s provided scope. Handler must be set manually for each scope below this scope.
- Parameters
logger (
NeuraxleLogger
) – logger to add handler to.scope (
ScopedLocation
) – scope to add handler to.
- Returns
self.
-
get_log_from_logging_handler
(logger: neuraxle.logging.logging.NeuraxleLogger, scope: neuraxle.metaopt.data.vanilla.ScopedLocation) → str[source]¶ Get log from repository’s provided scope and handler that was set with
add_logging_handler()
.- Return type
str
- Parameters
scope (
ScopedLocation
) – scope to get log from.- Returns
log from scope.
-
_abc_impl
= <_abc_data object>¶
-
-
class
neuraxle.metaopt.data.vanilla.
_InMemoryRepositoryLoggerHandlerMixin
[source]¶ Bases:
object
Mixin to add a in-memory logging handler to a repository.
-
class
neuraxle.metaopt.data.vanilla.
VanillaHyperparamsRepository
(cache_folder: str)[source]¶ Bases:
neuraxle.metaopt.data.vanilla._InMemoryRepositoryLoggerHandlerMixin
,neuraxle.metaopt.data.vanilla.HyperparamsRepository
Hyperparams repository that saves data AutoML-related info.
-
__init__
(cache_folder: str)[source]¶ - Parameters
cache_folder (
str
) – folder to store trials.hyperparams_repo_class – class to use to save hyperparams.
hyperparams_repo_kwargs – kwargs to pass to hyperparams_repo_class.
-
static
from_root
(root: neuraxle.metaopt.data.vanilla.RootDataclass, cache_folder: str) → neuraxle.metaopt.data.vanilla.VanillaHyperparamsRepository[source]¶
-
load
(scope: neuraxle.metaopt.data.vanilla.ScopedLocation, deep=False) → SubDataclassT[source]¶ Get metadata from scope.
The fetched metadata will be the one that is the last item that is not a None in the provided scope.
- Parameters
scope (
ScopedLocation
) – scope to get metadata from.- Returns
metadata from scope.
-
save
(_dataclass: SubDataclassT, scope: neuraxle.metaopt.data.vanilla.ScopedLocation, deep=False) → neuraxle.metaopt.data.vanilla.VanillaHyperparamsRepository[source]¶ Save metadata to scope.
- Parameters
metadata – metadata to save.
scope (
ScopedLocation
) – scope to save metadata to.deep (
bool
) – if True, save metadata’s sublocations recursively.
-
_abc_impl
= <_abc_data object>¶
-
-
class
neuraxle.metaopt.data.vanilla.
InMemoryHyperparamsRepository
(*kargs, **kwargs)[source]¶ Bases:
neuraxle.logging.warnings.RaiseDeprecatedClass
,neuraxle.metaopt.data.vanilla._InMemoryRepositoryLoggerHandlerMixin
,neuraxle.metaopt.data.vanilla.HyperparamsRepository
In memory hyperparams repository that can print information about trials. Useful for debugging.
-
_abc_impl
= <_abc_data object>¶
-
-
class
neuraxle.metaopt.data.vanilla.
BaseHyperparameterOptimizer
[source]¶ Bases:
abc.ABC
-
find_next_best_hyperparams
(round_scope) → neuraxle.hyperparams.space.HyperparameterSamples[source]¶ Find the next best hyperparams using previous trials, that is the whole
neuraxle.metaopt.data.aggregate.Round
.- Return type
- Parameters
round – a
neuraxle.metaopt.data.aggregate.Round
- Returns
next hyperparameter samples to train on
-
_abc_impl
= <_abc_data object>¶
-
-
class
neuraxle.metaopt.data.vanilla.
HyperparameterSamplerStub
(preconfigured_hp_samples: neuraxle.hyperparams.space.HyperparameterSamples)[source]¶ Bases:
neuraxle.metaopt.data.vanilla.BaseHyperparameterOptimizer
-
__init__
(preconfigured_hp_samples: neuraxle.hyperparams.space.HyperparameterSamples)[source]¶ Initialize self. See help(type(self)) for accurate signature.
-
find_next_best_hyperparams
(round_scope) → neuraxle.hyperparams.space.HyperparameterSamples[source]¶ Find the next best hyperparams using previous trials, that is the whole
neuraxle.metaopt.data.aggregate.Round
.- Return type
- Parameters
round – a
neuraxle.metaopt.data.aggregate.Round
- Returns
next hyperparameter samples to train on
-
_abc_impl
= <_abc_data object>¶
-
-
class
neuraxle.metaopt.data.vanilla.
AutoMLContext
(root: str = None, flow: neuraxle.base.Flow = None, execution_phase: neuraxle.base.ExecutionPhase = <ExecutionPhase.UNSPECIFIED: None>, execution_mode: neuraxle.base.ExecutionMode = <ExecutionMode.FIT_OR_FIT_TRANSFORM_OR_TRANSFORM: 'fit_or_fit_transform_or_transform'>, stripped_saver: neuraxle.base.BaseSaver = None, parents: List[BaseStep] = None, services: Dict[Union[str, Type[BaseServiceT]], BaseServiceT] = None)[source]¶ Bases:
neuraxle.base.ExecutionContext
-
logger
¶
-
logger_at_scoped_loc
¶
-
add_scoped_logger_file_handler
() → neuraxle.logging.logging.NeuraxleLogger[source]¶ Add a file handler to the logger at the current scoped location to capture logs at this scope and below this scope.
-
free_scoped_logger_file_handler
()[source]¶ Remove file handlers from logger to free file lock (especially on Windows).
-
static
from_context
(context: neuraxle.base.ExecutionContext = None, repo: neuraxle.metaopt.data.vanilla.HyperparamsRepository = None, loc: neuraxle.metaopt.data.vanilla.ScopedLocation = None) → neuraxle.metaopt.data.vanilla.AutoMLContext[source]¶ Create a new AutoMLContext from an ExecutionContext.
- Parameters
context (
ExecutionContext
) – ExecutionContext
-
lock
¶
-
loc
¶
-
repo
¶
-
push_attr
(subdataclass: SubDataclassT) → neuraxle.metaopt.data.vanilla.AutoMLContext[source]¶ Push a new attribute into the ScopedLocation.
- Parameters
name – attribute name
value – attribute value
- Returns
an AutoMLContext copy with the new loc attribute.
-
pop_attr
() → neuraxle.metaopt.data.vanilla.AutoMLContext[source]¶ Pop an attribute from the ScopedLocation.
- Returns
an AutoMLContext copy with the new popped loc attribute.
-
with_loc
(loc: neuraxle.metaopt.data.vanilla.ScopedLocation) → neuraxle.metaopt.data.vanilla.AutoMLContext[source]¶ Replace the ScopedLocation by the one provided.
- Parameters
loc (
ScopedLocation
) – ScopedLocation- Returns
an AutoMLContext copy with the new loc attribute.
-
load_dc
(deep=True) → neuraxle.metaopt.data.vanilla.BaseDataclass[source]¶ Load the current dc from the repo.
-
load_agg
(deep=True) → neuraxle.metaopt.data.aggregates.BaseAggregate[source]¶ Load the current agg from the repo.
-
_abc_impl
= <_abc_data object>¶
-