:py:mod:`mlair.data_handler.input_bootstraps` ============================================= .. py:module:: mlair.data_handler.input_bootstraps .. autoapi-nested-parse:: Collections of bootstrap methods and classes. How to use ---------- test Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: mlair.data_handler.input_bootstraps.BootstrapIterator mlair.data_handler.input_bootstraps.BootstrapIteratorSingleInput mlair.data_handler.input_bootstraps.BootstrapIteratorVariable mlair.data_handler.input_bootstraps.BootstrapIteratorBranch mlair.data_handler.input_bootstraps.ShuffleBootstraps mlair.data_handler.input_bootstraps.MeanBootstraps mlair.data_handler.input_bootstraps.Bootstraps Attributes ~~~~~~~~~~ .. autoapisummary:: mlair.data_handler.input_bootstraps.__author__ mlair.data_handler.input_bootstraps.__date__ .. py:data:: __author__ :annotation: = Felix Kleinert, Lukas Leufen .. py:data:: __date__ :annotation: = 2020-02-07 .. py:class:: BootstrapIterator(data: Bootstraps, method, return_reshaped=False) Bases: :py:obj:`collections.Iterator` .. py:attribute:: _position :annotation: :int .. py:method:: __next__(self) :abstractmethod: Return next element or stop iteration. .. py:method:: create_collection(cls, data, dim) :classmethod: :abstractmethod: .. py:method:: _reshape(self, d) .. py:method:: _to_numpy(self, d) .. py:method:: apply_bootstrap_method(self, data: numpy.ndarray) -> Union[numpy.ndarray, List[numpy.ndarray]] Apply predefined bootstrap method from given data. :param data: data to apply bootstrap method on :return: processed data as numpy array .. py:class:: BootstrapIteratorSingleInput(*args, **kwargs) Bases: :py:obj:`BootstrapIterator` .. py:attribute:: _position :annotation: :int .. py:method:: __next__(self) Return next element or stop iteration. .. py:method:: create_collection(cls, data, dim) :classmethod: .. py:class:: BootstrapIteratorVariable(*args, **kwargs) Bases: :py:obj:`BootstrapIterator` .. py:method:: __next__(self) Return next element or stop iteration. .. py:method:: create_collection(cls, data, dim) :classmethod: .. py:class:: BootstrapIteratorBranch(*args, **kwargs) Bases: :py:obj:`BootstrapIterator` .. py:method:: __next__(self) Return next element or stop iteration. .. py:method:: create_collection(cls, data, dim) :classmethod: .. py:class:: ShuffleBootstraps .. py:method:: apply(data) :staticmethod: .. py:class:: MeanBootstraps(mean) .. py:method:: apply(self, data) .. py:class:: 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: :py:obj:`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. .. py:method:: __iter__(self) .. py:method:: __len__(self) .. py:method:: bootstraps(self) .. py:method:: 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. :param path: path to file :param file_name: file name :param prediction_name: name of the prediction to select from loaded file (default CNN) :return: repeated predictions