class_docstr: Bagging ensemble of time series classifiers.
  
  Fits ``n_estimators`` clones of a classifier on
  datasets which are instance sub-samples and/or variable sub-samples.
  
  On ``predict_proba``, the mean average of probabilistic predictions is returned.
  For a deterministic classifier, this results in majority vote for ``predict``.
  
  The estimator allows to choose sample sizes fir instances, variables,
  and whether sampling is with or without replacement.
  
  Direct generalization of ``sklearn``'s ``BaggingClassifier``
  to the time series classification task.
  
  Note: if n_features=1, BaggingClassifier turns a univariate classifier into
  a multivariate classifier (as slices seen by ``estimator`` are all univariate).
  
  Parameters
  ----------
  estimator : sktime classifier, descendant of BaseClassifier
      classifier to use in the bagging estimator
  n_estimators : int, default=10
      number of estimators in the sample for bagging
  n_samples : int or float, default=1.0
      The number of instances drawn from ``X`` in ``fit`` to train each clone
      If int, then indicates number of instances precisely
      If float, interpreted as a fraction, and rounded by ``ceil``
  n_features : int or float, default=1.0
      The number of features/variables drawn from ``X`` in ``fit`` to train each clone
      If int, then indicates number of instances precisely
      If float, interpreted as a fraction, and rounded by ``ceil``
      Note: if n_features=1, BaggingClassifier turns a univariate classifier into
      a multivariate classifier (as slices seen by ``estimator`` are all univariate).
  bootstrap : boolean, default=True
      whether samples/instances are drawn with replacement (True) or not (False)
  bootstrap_features : boolean, default=False
      whether features/variables are drawn with replacement (True) or not (False)
  random_state : int, RandomState instance or None, optional (default=None)
      If int, ``random_state`` is the seed used by the random number generator;
      If ``RandomState`` instance, ``random_state`` is the random number generator;
      If None, the random number generator is the ``RandomState`` instance used
      by ``np.random``.
  
  Attributes
  ----------
  estimators_ : list of of sktime classifiers
      clones of classifier in `estimator` fitted in the ensemble
  
  Examples
  --------
  >>> from sktime.classification.ensemble import BaggingClassifier
  >>> from sktime.classification.kernel_based import RocketClassifier
  >>> from sktime.datasets import load_unit_test
  >>> X_train, y_train = load_unit_test(split="train") # doctest: +SKIP
  >>> X_test, y_test = load_unit_test(split="test") # doctest: +SKIP
  >>> clf = BaggingClassifier(
  ...     RocketClassifier(num_kernels=100),
  ...     n_estimators=10,
  ... ) # doctest: +SKIP
  >>> clf.fit(X_train, y_train) # doctest: +SKIP
  BaggingClassifier(...)
  >>> y_pred = clf.predict(X_test) # doctest: +SKIP
class_docstr_tok: ["Bagging","ensemble","of","time","series","classifiers",".","Fits","``","n_estimators","``","clones","of","a","classifier","on","datasets","which","are","instance","sub-samples","and\/or","variable","sub-samples",".","On","``","predict_proba","``",",","the","mean","average","of","probabilistic","predictions","is","returned",".","For","a","deterministic","classifier",",","this","results","in","majority","vote","for","``","predict","``",".","The","estimator","allows","to","choose","sample","sizes","fir","instances",",","variables",",","and","whether","sampling","is","with","or","without","replacement",".","Direct","generalization","of","``","sklearn","``","'s","``","BaggingClassifier","``","to","the","time","series","classification","task",".","Note",":","if","n_features=1",",","BaggingClassifier","turns","a","univariate","classifier","into","a","multivariate","classifier","(","as","slices","seen","by","``","estimator","``","are","all","univariate",")",".","Parameters","--","--","--","--","--","estimator",":","sktime","classifier",",","descendant","of","BaseClassifier","classifier","to","use","in","the","bagging","estimator","n_estimators",":","int",",","default=10","number","of","estimators","in","the","sample","for","bagging","n_samples",":","int","or","float",",","default=1.0","The","number","of","instances","drawn","from","``","X","``","in","``","fit","``","to","train","each","clone","If","int",",","then","indicates","number","of","instances","precisely","If","float",",","interpreted","as","a","fraction",",","and","rounded","by","``","ceil","``","n_features",":","int","or","float",",","default=1.0","The","number","of","features\/variables","drawn","from","``","X","``","in","``","fit","``","to","train","each","clone","If","int",",","then","indicates","number","of","instances","precisely","If","float",",","interpreted","as","a","fraction",",","and","rounded","by","``","ceil","``","Note",":","if","n_features=1",",","BaggingClassifier","turns","a","univariate","classifier","into","a","multivariate","classifier","(","as","slices","seen","by","``","estimator","``","are","all","univariate",")",".","bootstrap",":","boolean",",","default=True","whether","samples\/instances","are","drawn","with","replacement","(","True",")","or","not","(","False",")","bootstrap_features",":","boolean",",","default=False","whether","features\/variables","are","drawn","with","replacement","(","True",")","or","not","(","False",")","random_state",":","int",",","RandomState","instance","or","None",",","optional","(","default=None",")","If","int",",","``","random_state","``","is","the","seed","used","by","the","random","number","generator",";","If","``","RandomState","``","instance",",","``","random_state","``","is","the","random","number","generator",";","If","None",",","the","random","number","generator","is","the","``","RandomState","``","instance","used","by","``","np.random","``",".","Attributes","--","--","--","--","--","estimators_",":","list","of","of","sktime","classifiers","clones","of","classifier","in","`","estimator","`","fitted","in","the","ensemble","Examples","--","--","--","--",">",">",">","from","sktime.classification.ensemble","import","BaggingClassifier",">",">",">","from","sktime.classification.kernel_based","import","RocketClassifier",">",">",">","from","sktime.datasets","import","load_unit_test",">",">",">","X_train",",","y_train","=","load_unit_test","(","split=","''","train","''",")","#","doctest",":","+SKIP",">",">",">","X_test",",","y_test","=","load_unit_test","(","split=","''","test","''",")","#","doctest",":","+SKIP",">",">",">","clf","=","BaggingClassifier","(","...","RocketClassifier","(","num_kernels=100",")",",","...","n_estimators=10",",","...",")","#","doctest",":","+SKIP",">",">",">","clf.fit","(","X_train",",","y_train",")","#","doctest",":","+SKIP","BaggingClassifier","(","...",")",">",">",">","y_pred","=","clf.predict","(","X_test",")","#","doctest",":","+SKIP"]
docstr: Fit time series classifier to training data.
  
  Parameters
  ----------
  X : guaranteed to be of a type in self.get_tag("X_inner_mtype")
      if self.get_tag("X_inner_mtype") = "numpy3D":
          3D np.ndarray of shape = [n_instances, n_dimensions, series_length]
      if self.get_tag("X_inner_mtype") = "nested_univ":
          pd.DataFrame with each column a dimension, each cell a pd.Series
      for list of other mtypes, see datatypes.SCITYPE_REGISTER
      for specifications, see examples/AA_datatypes_and_datasets.ipynb
  y : 1D np.array of int, of shape [n_instances] - class labels for fitting
      indices correspond to instance indices in X
  
  Returns
  -------
  self : Reference to self.
docstr_tok: ["Fit","time","series","classifier","to","training","data",".","Parameters","--","--","--","--","--","X",":","guaranteed","to","be","of","a","type","in","self.get_tag","(","``","X_inner_mtype","''",")","if","self.get_tag","(","``","X_inner_mtype","''",")","=","``","numpy3D","''",":","3D","np.ndarray","of","shape","=","[","n_instances",",","n_dimensions",",","series_length","]","if","self.get_tag","(","``","X_inner_mtype","''",")","=","``","nested_univ","''",":","pd.DataFrame","with","each","column","a","dimension",",","each","cell","a","pd.Series","for","list","of","other","mtypes",",","see","datatypes.SCITYPE_REGISTER","for","specifications",",","see","examples\/AA_datatypes_and_datasets.ipynb","y",":","1D","np.array","of","int",",","of","shape","[","n_instances","]","-","class","labels","for","fitting","indices","correspond","to","instance","indices","in","X","Returns","--","--","--","-","self",":","Reference","to","self","."]
code: def _fit(self, X, y):
      """Fit time series classifier to training data.
  
      Parameters
      ----------
      X : guaranteed to be of a type in self.get_tag("X_inner_mtype")
          if self.get_tag("X_inner_mtype") = "numpy3D":
              3D np.ndarray of shape = [n_instances, n_dimensions, series_length]
          if self.get_tag("X_inner_mtype") = "nested_univ":
              pd.DataFrame with each column a dimension, each cell a pd.Series
          for list of other mtypes, see datatypes.SCITYPE_REGISTER
          for specifications, see examples/AA_datatypes_and_datasets.ipynb
      y : 1D np.array of int, of shape [n_instances] - class labels for fitting
          indices correspond to instance indices in X
  
      Returns
      -------
      self : Reference to self.
      """
      estimator = self.estimator
      n_estimators = self.n_estimators
      n_samples = self.n_samples
      n_features = self.n_features
      bootstrap = self.bootstrap
      bootstrap_ft = self.bootstrap_features
      random_state = self.random_state
      np.random.seed(random_state)
  
      if isinstance(X.index, pd.MultiIndex):
          inst_ix = X.index.droplevel(-1).unique()
      else:
          inst_ix = X.index
      col_ix = X.columns
      n = len(inst_ix)
      m = len(col_ix)
  
      if isinstance(n_samples, float):
          n_samples_ = ceil(n_samples * n)
      else:
          n_samples_ = n_samples
  
      if isinstance(n_features, float):
          n_features_ = ceil(n_features * m)
      else:
          n_features_ = n_features
  
      self.estimators_ = []
      for _i in range(n_estimators):
          esti = estimator.clone()
          row_iloc = pd.RangeIndex(n)
          row_ss = _random_ss_ix(
              row_iloc, size=n_samples_, replace=bootstrap
          )
          inst_ix_i = inst_ix[row_ss]
          col_ix_i = _random_ss_ix(
              col_ix, size=n_features_, replace=bootstrap_ft
          )
          # if we bootstrap, we need to take care to ensure the
          # indices end up unique
          if not isinstance(X.index, pd.MultiIndex):
              Xi = X.loc[inst_ix_i, col_ix_i]
              Xi = Xi.reset_index(drop=True)
          else:
              Xis = [
                  X.loc[[ix], col_ix_i].droplevel(0) for ix in inst_ix_i
              ]
              Xi = pd.concat(Xis, keys=pd.RangeIndex(len(inst_ix_i)))
  
          if bootstrap_ft:
              Xi.columns = pd.RangeIndex(len(col_ix_i))
  
          yi = y[row_ss]
          self.estimators_ += [esti.fit(Xi, yi)]
  
      return self
  
file_path: sktime/sktime/classification/ensemble/_bagging.py
imports: from math import ceil
  import numpy
  import pandas
  from sktime.classification.base import BaseClassifier
label_desc: Use image node_id 2 for calling the BaggingClassifier obj's underlying member method code with example usage: obj._fit(X, y) and returns: self