atm.utilities module¶
Functions
|
Inverse of object_to_base_64. |
|
Create directory if it doesn’t exist. |
|
Create an instance of the given class with required kwargs. |
|
Hash a python dictionary to a hexadecimal string. |
|
Hash a nested tuple to hexadecimal |
|
Hash a string to hexadecimal |
|
Load the performance metrics for a particular classifier |
|
Load the Model object for a particular classifier |
|
Generate the base save path for a classifier’s model and metrics files, based on the classifier’s dataset name and hyperparameters. |
|
http://stackoverflow.com/questions/34439/finding-what-methods-an-object-has |
|
Pickle and base64-encode an object. |
|
Converts a list of parameter vectors (with metadata) into a numpy array ready for BTB tuning. |
|
Save a JSON-serialized version of a set of performance metrics for a particular classifier. |
|
Save a serialized version of a Model object for a particular classifier. |
|
Update params with categoricals and constants for the fitting proces. |
-
atm.utilities.
base_64_to_object
(b64str)[source]¶ Inverse of object_to_base_64. Decode base64-encoded string and then unpickle it.
-
atm.utilities.
get_instance
(class_, **kwargs)[source]¶ Create an instance of the given class with required kwargs.
The exact keyword arguments that the given
class_
expects will be taken fromkwargs
and the rest will be ignored.- Parameters
class_ (type) – class to instantiate
**kwargs – keyword arguments
- Returns
instance of specific class with the args that accepts.
-
atm.utilities.
hash_dict
(dictionary, ignored_keys=None)[source]¶ Hash a python dictionary to a hexadecimal string. http://stackoverflow.com/questions/5884066/hashing-a-python-dictionary
-
atm.utilities.
load_metrics
(classifier, metrics_dir)[source]¶ Load the performance metrics for a particular classifier
-
atm.utilities.
load_model
(classifier, models_dir)[source]¶ Load the Model object for a particular classifier
-
atm.utilities.
make_save_path
(dir, classifier, suffix)[source]¶ Generate the base save path for a classifier’s model and metrics files, based on the classifier’s dataset name and hyperparameters.
-
atm.utilities.
obj_has_method
(obj, method)[source]¶ http://stackoverflow.com/questions/34439/finding-what-methods-an-object-has
-
atm.utilities.
params_to_vectors
(params, tunables)[source]¶ Converts a list of parameter vectors (with metadata) into a numpy array ready for BTB tuning.
- Parameters
params – list of hyperparameter vectors. Each vector is a dict mapping the names of parameters to those parameters’ values.
tunables – list of HyperParameter metadata structures describing all the optimizable hyperparameters that should be in each vector. e.g.
= [ (tunables) – (‘degree’, HyperParameter(‘int’, (2, 4))), (‘gamma’, HyperParameter(‘float_exp’, (1e-05, 1e5)))]
- Returns
- np.array of parameter vectors ready to be optimized by a
Gaussian Process (or what have you). vectors.shape = (len(params), len(tunables))
- Return type
vectors
-
atm.utilities.
save_metrics
(classifier, metrics_dir, metrics)[source]¶ Save a JSON-serialized version of a set of performance metrics for a particular classifier. The metrics will be stored at a path generated from the classifier’s attributes.
-
atm.utilities.
save_model
(classifier, models_dir, model)[source]¶ Save a serialized version of a Model object for a particular classifier. The object will be stored at a path generated from the classifier’s attributes.
-
atm.utilities.
update_params
(params, categoricals, constants)[source]¶ Update params with categoricals and constants for the fitting proces.
params: params proposed by the tuner
Examples of the format for SVM sigmoid hyperpartition:
- categoricals = ((‘kernel’, ‘poly’),
(‘probability’, True), (‘_scale’, True))
constants = [(‘cache_size’, 15000)]