mlair.data_handler.input_bootstraps
¶
Collections of bootstrap methods and classes.
How to use¶
test
Module Contents¶
Classes¶
Main class to perform bootstrap operations. |
Attributes¶
-
mlair.data_handler.input_bootstraps.
__date__
= 2020-02-07¶
-
class
mlair.data_handler.input_bootstraps.
BootstrapIterator
(data: Bootstraps, method, return_reshaped=False)¶ Bases:
collections.Iterator
-
_position
:int¶
-
abstract
__next__
(self)¶ Return next element or stop iteration.
-
abstract classmethod
create_collection
(cls, data, dim)¶
-
_reshape
(self, d)¶
-
_to_numpy
(self, d)¶
-
apply_bootstrap_method
(self, data: numpy.ndarray) → Union[numpy.ndarray, List[numpy.ndarray]]¶ Apply predefined bootstrap method from given data.
- Parameters
data – data to apply bootstrap method on
- Returns
processed data as numpy array
-
-
class
mlair.data_handler.input_bootstraps.
BootstrapIteratorSingleInput
(*args, **kwargs)¶ Bases:
BootstrapIterator
-
_position
:int¶
-
__next__
(self)¶ Return next element or stop iteration.
-
classmethod
create_collection
(cls, data, dim)¶
-
-
class
mlair.data_handler.input_bootstraps.
BootstrapIteratorVariable
(*args, **kwargs)¶ Bases:
BootstrapIterator
-
__next__
(self)¶ Return next element or stop iteration.
-
classmethod
create_collection
(cls, data, dim)¶
-
-
class
mlair.data_handler.input_bootstraps.
BootstrapIteratorBranch
(*args, **kwargs)¶ Bases:
BootstrapIterator
-
__next__
(self)¶ Return next element or stop iteration.
-
classmethod
create_collection
(cls, data, dim)¶
-
-
class
mlair.data_handler.input_bootstraps.
Bootstraps
(data: mlair.data_handler.abstract_data_handler.AbstractDataHandler, number_of_bootstraps: int = 10, bootstrap_dimension: str = 'variables', bootstrap_type='singleinput', bootstrap_method='shuffle')¶ Bases:
collections.Iterable
Main class to perform bootstrap operations.
This class requires a data handler following the definition of the AbstractDataHandler, the number of bootstraps to create and the dimension along this bootstrapping is performed (default dimension is variables).
When iterating on this class, it returns the bootstrapped X, Y and a tuple with (position of variable in X, name of this variable). The tuple is interesting if X consists on mutliple input streams X_i (e.g. two or more stations) because it shows which variable of which input X_i has been bootstrapped. All bootstrap combinations can be retrieved by calling the .bootstraps() method. Further more, by calling the .get_orig_prediction() this class imitates according to the set number of bootstraps the original prediction.
As bootstrap method, this class can currently make use of the ShuffleBoostraps class that uses drawing with replacement to destroy the variables information by keeping its statistical properties. Use bootstrap=”shuffle” to call this method. Another method is the zero mean bootstrapping triggered by bootstrap=”zero_mean” and performed by the MeanBootstraps class. This method destroy the variable’s information by a mode collapse to constant value of zero. In case, the variable is normalized with a zero mean, this is equivalent to a mode collapse to the variable’s mean value. Statistics in general are not conserved in this case, but the mean value of course. A custom mean value for bootstrapping is currently not supported.
-
__iter__
(self)¶
-
__len__
(self)¶
-
bootstraps
(self)¶
-
get_orig_prediction
(self, path: str, file_name: str, prediction_name: str = 'CNN') → numpy.ndarray¶ Repeat predictions from given file(_name) in path by the number of boots.
- Parameters
path – path to file
file_name – file name
prediction_name – name of the prediction to select from loaded file (default CNN)
- Returns
repeated predictions
-