docstr: Calculate error bars from scikit-learn RandomForest estimators
  Source:
  https://github.com/scikit-learn-contrib/forest-confidence-interval
  
  Args:
      X_train: (np.ndarray), training subsample of feature matrix, (n_train_sample, n_features)
      X_test: (np.ndarray), test subsample of feature matrix, (n_train_sample, n_features)
      inbag: (ndarray, optional),
              The inbag matrix that fit the data. If set to `None` (default) it
              will be inferred from the forest. However, this only works for trees
              for which bootstrapping was set to `True`. That is, if sampling was
              done with replacement. Otherwise, users need to provide their own
              inbag matrix.
      calibrate: (boolean, optional)
              Whether to apply calibration to mitigate Monte Carlo noise.
              Some variance estimates may be negative due to Monte Carlo effects if
              the number of trees in the forest is too small. To use calibration,
              Default: True
      memory_constrained: (boolean, optional)
              Whether or not there is a restriction on memory. If False, it is
              assumed that a ndarray of shape (n_train_sample,n_test_sample) fits
              in main memory. Setting to True can actually provide a speedup if
              memory_limit is tuned to the optimal range.
      memory_limit: (int, optional)
              An upper bound for how much memory the intermediate matrices will take
              up in Megabytes. This must be provided if memory_constrained=True.
  
  Returns:
      (np.ndarray), An array with the unbiased sampling variance for a RandomForest object.
docstr_tok: ["Calculate","error","bars","from","scikit-learn","RandomForest","estimators","Source",":","https",":","\/\/github.com\/scikit-learn-contrib\/forest-confidence-interval","Args",":","X_train",":","(","np.ndarray",")",",","training","subsample","of","feature","matrix",",","(","n_train_sample",",","n_features",")","X_test",":","(","np.ndarray",")",",","test","subsample","of","feature","matrix",",","(","n_train_sample",",","n_features",")","inbag",":","(","ndarray",",","optional",")",",","The","inbag","matrix","that","fit","the","data",".","If","set","to","`","None","`","(","default",")","it","will","be","inferred","from","the","forest",".","However",",","this","only","works","for","trees","for","which","bootstrapping","was","set","to","`","True","`",".","That","is",",","if","sampling","was","done","with","replacement",".","Otherwise",",","users","need","to","provide","their","own","inbag","matrix",".","calibrate",":","(","boolean",",","optional",")","Whether","to","apply","calibration","to","mitigate","Monte","Carlo","noise",".","Some","variance","estimates","may","be","negative","due","to","Monte","Carlo","effects","if","the","number","of","trees","in","the","forest","is","too","small",".","To","use","calibration",",","Default",":","True","memory_constrained",":","(","boolean",",","optional",")","Whether","or","not","there","is","a","restriction","on","memory",".","If","False",",","it","is","assumed","that","a","ndarray","of","shape","(","n_train_sample",",","n_test_sample",")","fits","in","main","memory",".","Setting","to","True","can","actually","provide","a","speedup","if","memory_limit","is","tuned","to","the","optimal","range",".","memory_limit",":","(","int",",","optional",")","An","upper","bound","for","how","much","memory","the","intermediate","matrices","will","take","up","in","Megabytes",".","This","must","be","provided","if","memory_constrained=True",".","Returns",":","(","np.ndarray",")",",","An","array","with","the","unbiased","sampling","variance","for","a","RandomForest","object","."]
code: def calculate_error(
      self,
      X_train: np.ndarray,
      X_test: np.ndarray,
      inbag: np.ndarray = None,
      calibrate: bool = True,
      memory_constrained: bool = False,
      memory_limit: int = None,
  ) -> np.ndarray:
      """
      Calculate error bars from scikit-learn RandomForest estimators
      Source:
      https://github.com/scikit-learn-contrib/forest-confidence-interval
  
      Args:
          X_train: (np.ndarray), training subsample of feature matrix, (n_train_sample, n_features)
          X_test: (np.ndarray), test subsample of feature matrix, (n_train_sample, n_features)
          inbag: (ndarray, optional),
                  The inbag matrix that fit the data. If set to `None` (default) it
                  will be inferred from the forest. However, this only works for trees
                  for which bootstrapping was set to `True`. That is, if sampling was
                  done with replacement. Otherwise, users need to provide their own
                  inbag matrix.
          calibrate: (boolean, optional)
                  Whether to apply calibration to mitigate Monte Carlo noise.
                  Some variance estimates may be negative due to Monte Carlo effects if
                  the number of trees in the forest is too small. To use calibration,
                  Default: True
          memory_constrained: (boolean, optional)
                  Whether or not there is a restriction on memory. If False, it is
                  assumed that a ndarray of shape (n_train_sample,n_test_sample) fits
                  in main memory. Setting to True can actually provide a speedup if
                  memory_limit is tuned to the optimal range.
          memory_limit: (int, optional)
                  An upper bound for how much memory the intermediate matrices will take
                  up in Megabytes. This must be provided if memory_constrained=True.
  
      Returns:
          (np.ndarray), An array with the unbiased sampling variance for a RandomForest object.
      """
  
      var = fci.random_forest_error(
          self,
          X_train,
          X_test,
          inbag=inbag,
          calibrate=calibrate,
          memory_constrained=memory_constrained,
          memory_limit=memory_limit,
      )
      return var
  
imports: from typing import Union
  import numpy
  import forestci
  from joblib import Parallel, delayed
  from warnings import catch_warnings, simplefilter, warn
  from sklearn.exceptions import DataConversionWarning
  from sklearn.utils.validation import check_random_state, _check_sample_weight
  from sklearn.utils.multiclass import type_of_target
  from sklearn import __version__
  from sklearn.ensemble._forest import DOUBLE, DTYPE, MAX_INT
  from sklearn.ensemble._forest import ForestRegressor
  from sklearn.ensemble._forest import compute_sample_weight, issparse
  from sklearn.ensemble._forest import _generate_sample_indices, _get_n_samples_bootstrap
  from .causaltree import CausalTreeRegressor
label_desc: Use image node_id 5 for calling the CausalRandomForestRegressor obj's underlying member method code with example usage: obj.calculate_error(X_train, X_test, inbag, calibrate, memory_constrained, memory_limit) and returns: var