Utils Module¶
This module serves as a support for other modules. The following helper functions are defined:
- exception scripts.utils.ModelNotFittedError¶
Bases:
ExceptionIt is raised when a method or attribute is requested that requires the model to be trained (such as .predict() or .score())
- scripts.utils.check_consistent_length(*arr)¶
Checks whether the provided set of nd-arrays have the same first dimension.
- Raises
ValueError – If the len of input arrays is incosistent.
- scripts.utils.generate_summary(**kwargs)¶
Generate summary for the given model. The summary is written to the specified
filepath.- Parameters
kwargs (dict-like object) – Dict of parameters neeeded in order for summary to be built.
- scripts.utils.get_data(raw=True, scaled=True, pca=False)¶
Loads transformed dara according to the given specificatiion.
- Parameters
raw (bool) – Do you want to return the raw data.
scaled (bool) – Do you want to return data which were standard scaled - zero mean, unit variance.
pca (bool) – Do you want to return data which were transformed using pca.
- Raises
AssertionError – If the specification of data to be returned does not match the available options.
- scripts.utils.validate_feature_matrix(X)¶
Makes any inserted matrix with less than 3 dimensions into a 2d-feature matrix.
- Parameters
X (
numpy.ndarray) –- Returns
X – 2d array.
- Return type
numpy.ndarray- Raises
AssetionError – If X is 3 dimensional.
- scripts.utils.validate_target_vector(y)¶
Makes sure that the target vector is one dimensional.
- Parameters
y (
numpy.ndarray) – Target vector.- Returns
y – 1d target vector.
- Return type
numpy.ndarray