class_docstr: Based on sklearn.decomposition.IncrementalPCA from scikit-learn 0.23.1
  
  Incremental principal components analysis (IPCA).
  Linear dimensionality reduction using Singular Value Decomposition of
  the data, keeping only the most significant singular vectors to
  project the data to a lower dimensional space. The input data is
  centered but not scaled for each feature before applying the SVD.
  Depending on the size of the input data, this algorithm can be much
  more memory efficient than a PCA, and allows sparse input.
  This algorithm has constant memory complexity, on the order of
  :py:`batch_size * n_features`, enabling use of np.memmap files without
  loading the entire file into memory. For sparse matrices, the input
  is converted to dense in batches (in order to be able to subtract the
  mean) which avoids storing the entire dense matrix at any one time.
  The computational overhead of each SVD is
  :py:`O(batch_size * n_features ** 2)`, but only 2 * batch_size samples
  remain in memory at a time. There will be :py:`n_samples / batch_size`
  SVD computations to get the principal components, versus 1 large SVD
  of complexity :py:`O(n_samples * n_features ** 2)` for PCA.
  
  Parameters
  ----------
  
  handle : cuml.Handle
      Specifies the cuml.handle that holds internal CUDA state for
      computations in this model. Most importantly, this specifies the CUDA
      stream that will be used for the model's computations, so users can
      run different models concurrently in different streams by creating
      handles in several streams.
      If it is None, a new one is created.
  n_components : int or None, (default=None)
      Number of components to keep. If `n_components` is ``None``,
      then `n_components` is set to :py:`min(n_samples, n_features)`.
  whiten : bool, optional
      If True, de-correlates the components. This is done by dividing them by
      the corresponding singular values then multiplying by sqrt(n_samples).
      Whitening allows each component to have unit variance and removes
      multi-collinearity. It might be beneficial for downstream
      tasks like LinearRegression where correlated features cause problems.
  copy : bool, (default=True)
      If False, X will be overwritten. :py:`copy=False` can be used to
      save memory but is unsafe for general use.
  batch_size : int or None, (default=None)
      The number of samples to use for each batch. Only used when calling
      `fit`. If `batch_size` is ``None``, then `batch_size`
      is inferred from the data and set to :py:`5 * n_features`, to provide a
      balance between approximation accuracy and memory consumption.
  verbose : int or boolean, default=False
      Sets logging level. It must be one of `cuml.common.logger.level_*`.
      See :ref:`verbosity-levels` for more info.
  output_type : {'input', 'array', 'dataframe', 'series', 'df_obj',         'numba', 'cupy', 'numpy', 'cudf', 'pandas'}, default=None
      Return results and set estimator attributes to the indicated output
      type. If None, the output type set at the module level
      (`cuml.global_settings.output_type`) will be used. See
      :ref:`output-data-type-configuration` for more info.
  
  Attributes
  ----------
  
  components_ : array, shape (n_components, n_features)
      Components with maximum variance.
  explained_variance_ : array, shape (n_components,)
      Variance explained by each of the selected components.
  explained_variance_ratio_ : array, shape (n_components,)
      Percentage of variance explained by each of the selected components.
      If all components are stored, the sum of explained variances is equal
      to 1.0.
  singular_values_ : array, shape (n_components,)
      The singular values corresponding to each of the selected components.
      The singular values are equal to the 2-norms of the `n_components`
      variables in the lower-dimensional space.
  mean_ : array, shape (n_features,)
      Per-feature empirical mean, aggregate over calls to `partial_fit`.
  var_ : array, shape (n_features,)
      Per-feature empirical variance, aggregate over calls to
      `partial_fit`.
  noise_variance_ : float
      The estimated noise covariance following the Probabilistic PCA model
      from [4]_.
  n_components_ : int
      The estimated number of components. Relevant when
      `n_components=None`.
  n_samples_seen_ : int
      The number of samples processed by the estimator. Will be reset on
      new calls to fit, but increments across `partial_fit` calls.
  batch_size_ : int
      Inferred batch size from `batch_size`.
  
  Notes
  -----
  
  Implements the incremental PCA model from [1]_. This model is an extension
  of the Sequential Karhunen-Loeve Transform from [2]_. We have specifically
  abstained from an optimization used by authors of both papers, a QR
  decomposition used in specific situations to reduce the algorithmic
  complexity of the SVD. The source for this technique is [3]_. This
  technique has been omitted because it is advantageous only when decomposing
  a matrix with :py:`n_samples >= 5/3 * n_features` where `n_samples` and
  `n_features` are the matrix rows and columns, respectively. In addition,
  it hurts the readability of the implemented algorithm. This would be a good
  opportunity for future optimization, if it is deemed necessary.
  
  References
  ----------
  .. [1] `D. Ross, J. Lim, R. Lin, M. Yang. Incremental Learning for Robust
      Visual Tracking, International Journal of Computer Vision, Volume 77,
      Issue 1-3, pp. 125-141, May 2008.
      <https://www.cs.toronto.edu/~dross/ivt/RossLimLinYang_ijcv.pdf>`_
  
  .. [2] `A. Levy and M. Lindenbaum, Sequential Karhunen-Loeve Basis
      Extraction and its Application to Images, IEEE Transactions on Image
      Processing, Volume 9, Number 8, pp. 1371-1374, August 2000.
      <https://www.cs.technion.ac.il/~mic/doc/skl-ip.pdf>`_
  
  .. [3] G. Golub and C. Van Loan. Matrix Computations, Third Edition,
      Chapter 5, Section 5.4.4, pp. 252-253.
  
  .. [4] `C. Bishop, 1999. "Pattern Recognition and Machine Learning",
      Section 12.2.1, pp. 574
      <http://www.miketipping.com/papers/met-mppca.pdf>`_
  
  Examples
  --------
  
  .. code-block:: python
  
      >>> from cuml.decomposition import IncrementalPCA
      >>> import cupy as cp
      >>> import cupyx
      >>>
      >>> X = cupyx.scipy.sparse.random(1000, 4, format='csr',
      ...                               density=0.07, random_state=5)
      >>> ipca = IncrementalPCA(n_components=2, batch_size=200)
      >>> ipca.fit(X)
      IncrementalPCA()
      >>>
      >>> # Components:
      >>> ipca.components_ # doctest: +SKIP
      array([[ 0.23698335, -0.06073393,  0.04310868,  0.9686547 ],
             [ 0.27040346, -0.57185116,  0.76248786, -0.13594291]])
      >>>
      >>> # Singular Values:
      >>> ipca.singular_values_ # doctest: +SKIP
      array([5.06637586, 4.59406975])
      >>>
      >>> # Explained Variance:
      >>> ipca.explained_variance_ # doctest: +SKIP
      array([0.02569386, 0.0211266 ])
      >>>
      >>> # Explained Variance Ratio:
      >>> ipca.explained_variance_ratio_ # doctest: +SKIP
      array([0.30424536, 0.25016372])
      >>>
      >>> # Mean:
      >>> ipca.mean_ # doctest: +SKIP
      array([0.02693948, 0.0326928 , 0.03818463, 0.03861492])
      >>>
      >>> # Noise Variance:
      >>> ipca.noise_variance_.item() # doctest: +SKIP
      0.0037122774558343763
class_docstr_tok: ["Based","on","sklearn.decomposition.IncrementalPCA","from","scikit-learn","0.23.1","Incremental","principal","components","analysis","(","IPCA",")",".","Linear","dimensionality","reduction","using","Singular","Value","Decomposition","of","the","data",",","keeping","only","the","most","significant","singular","vectors","to","project","the","data","to","a","lower","dimensional","space",".","The","input","data","is","centered","but","not","scaled","for","each","feature","before","applying","the","SVD",".","Depending","on","the","size","of","the","input","data",",","this","algorithm","can","be","much","more","memory","efficient","than","a","PCA",",","and","allows","sparse","input",".","This","algorithm","has","constant","memory","complexity",",","on","the","order","of",":","py",":","`","batch_size","*","n_features","`",",","enabling","use","of","np.memmap","files","without","loading","the","entire","file","into","memory",".","For","sparse","matrices",",","the","input","is","converted","to","dense","in","batches","(","in","order","to","be","able","to","subtract","the","mean",")","which","avoids","storing","the","entire","dense","matrix","at","any","one","time",".","The","computational","overhead","of","each","SVD","is",":","py",":","`","O","(","batch_size","*","n_features","*","*","2",")","`",",","but","only","2","*","batch_size","samples","remain","in","memory","at","a","time",".","There","will","be",":","py",":","`","n_samples","\/","batch_size","`","SVD","computations","to","get","the","principal","components",",","versus","1","large","SVD","of","complexity",":","py",":","`","O","(","n_samples","*","n_features","*","*","2",")","`","for","PCA",".","Parameters","--","--","--","--","--","handle",":","cuml.Handle","Specifies","the","cuml.handle","that","holds","internal","CUDA","state","for","computations","in","this","model",".","Most","importantly",",","this","specifies","the","CUDA","stream","that","will","be","used","for","the","model","'s","computations",",","so","users","can","run","different","models","concurrently","in","different","streams","by","creating","handles","in","several","streams",".","If","it","is","None",",","a","new","one","is","created",".","n_components",":","int","or","None",",","(","default=None",")","Number","of","components","to","keep",".","If","`","n_components","`","is","``","None","``",",","then","`","n_components","`","is","set","to",":","py",":","`","min","(","n_samples",",","n_features",")","`",".","whiten",":","bool",",","optional","If","True",",","de-correlates","the","components",".","This","is","done","by","dividing","them","by","the","corresponding","singular","values","then","multiplying","by","sqrt","(","n_samples",")",".","Whitening","allows","each","component","to","have","unit","variance","and","removes","multi-collinearity",".","It","might","be","beneficial","for","downstream","tasks","like","LinearRegression","where","correlated","features","cause","problems",".","copy",":","bool",",","(","default=True",")","If","False",",","X","will","be","overwritten",".",":","py",":","`","copy=False","`","can","be","used","to","save","memory","but","is","unsafe","for","general","use",".","batch_size",":","int","or","None",",","(","default=None",")","The","number","of","samples","to","use","for","each","batch",".","Only","used","when","calling","`","fit","`",".","If","`","batch_size","`","is","``","None","``",",","then","`","batch_size","`","is","inferred","from","the","data","and","set","to",":","py",":","`","5","*","n_features","`",",","to","provide","a","balance","between","approximation","accuracy","and","memory","consumption",".","verbose",":","int","or","boolean",",","default=False","Sets","logging","level",".","It","must","be","one","of","`","cuml.common.logger.level_","*","`",".","See",":","ref",":","`","verbosity-levels","`","for","more","info",".","output_type",":","{","'input","'",",","'array","'",",","'dataframe","'",",","'series","'",",","'df_obj","'",",","'numba","'",",","'cupy","'",",","'numpy","'",",","'cudf","'",",","'pandas","'","}",",","default=None","Return","results","and","set","estimator","attributes","to","the","indicated","output","type",".","If","None",",","the","output","type","set","at","the","module","level","(","`","cuml.global_settings.output_type","`",")","will","be","used",".","See",":","ref",":","`","output-data-type-configuration","`","for","more","info",".","Attributes","--","--","--","--","--","components_",":","array",",","shape","(","n_components",",","n_features",")","Components","with","maximum","variance",".","explained_variance_",":","array",",","shape","(","n_components",",",")","Variance","explained","by","each","of","the","selected","components",".","explained_variance_ratio_",":","array",",","shape","(","n_components",",",")","Percentage","of","variance","explained","by","each","of","the","selected","components",".","If","all","components","are","stored",",","the","sum","of","explained","variances","is","equal","to","1.0.","singular_values_",":","array",",","shape","(","n_components",",",")","The","singular","values","corresponding","to","each","of","the","selected","components",".","The","singular","values","are","equal","to","the","2-norms","of","the","`","n_components","`","variables","in","the","lower-dimensional","space",".","mean_",":","array",",","shape","(","n_features",",",")","Per-feature","empirical","mean",",","aggregate","over","calls","to","`","partial_fit","`",".","var_",":","array",",","shape","(","n_features",",",")","Per-feature","empirical","variance",",","aggregate","over","calls","to","`","partial_fit","`",".","noise_variance_",":","float","The","estimated","noise","covariance","following","the","Probabilistic","PCA","model","from","[","4","]","_.","n_components_",":","int","The","estimated","number","of","components",".","Relevant","when","`","n_components=None","`",".","n_samples_seen_",":","int","The","number","of","samples","processed","by","the","estimator",".","Will","be","reset","on","new","calls","to","fit",",","but","increments","across","`","partial_fit","`","calls",".","batch_size_",":","int","Inferred","batch","size","from","`","batch_size","`",".","Notes","--","--","-","Implements","the","incremental","PCA","model","from","[","1","]","_",".","This","model","is","an","extension","of","the","Sequential","Karhunen-Loeve","Transform","from","[","2","]","_",".","We","have","specifically","abstained","from","an","optimization","used","by","authors","of","both","papers",",","a","QR","decomposition","used","in","specific","situations","to","reduce","the","algorithmic","complexity","of","the","SVD",".","The","source","for","this","technique","is","[","3","]","_",".","This","technique","has","been","omitted","because","it","is","advantageous","only","when","decomposing","a","matrix","with",":","py",":","`","n_samples",">","=","5\/3","*","n_features","`","where","`","n_samples","`","and","`","n_features","`","are","the","matrix","rows","and","columns",",","respectively",".","In","addition",",","it","hurts","the","readability","of","the","implemented","algorithm",".","This","would","be","a","good","opportunity","for","future","optimization",",","if","it","is","deemed","necessary",".","References","--","--","--","--","--","..","[","1","]","`","D.","Ross",",","J.","Lim",",","R.","Lin",",","M.","Yang",".","Incremental","Learning","for","Robust","Visual","Tracking",",","International","Journal","of","Computer","Vision",",","Volume","77",",","Issue","1-3",",","pp",".","125-141",",","May","2008",".","<","https",":","\/\/www.cs.toronto.edu\/~dross\/ivt\/RossLimLinYang_ijcv.pdf",">","`","_","..","[","2","]","`","A",".","Levy","and","M.","Lindenbaum",",","Sequential","Karhunen-Loeve","Basis","Extraction","and","its","Application","to","Images",",","IEEE","Transactions","on","Image","Processing",",","Volume","9",",","Number","8",",","pp",".","1371-1374",",","August","2000",".","<","https",":","\/\/www.cs.technion.ac.il\/~mic\/doc\/skl-ip.pdf",">","`","_","..","[","3","]","G.","Golub","and","C.","Van","Loan",".","Matrix","Computations",",","Third","Edition",",","Chapter","5",",","Section","5.4.4",",","pp",".","252-253",".","..","[","4","]","`","C.","Bishop",",","1999",".","``","Pattern","Recognition","and","Machine","Learning","''",",","Section","12.2.1",",","pp",".","574","<","http",":","\/\/www.miketipping.com\/papers\/met-mppca.pdf",">","`","_","Examples","--","--","--","--","..","code-block",":",":","python",">",">",">","from","cuml.decomposition","import","IncrementalPCA",">",">",">","import","cupy","as","cp",">",">",">","import","cupyx",">",">",">",">",">",">","X","=","cupyx.scipy.sparse.random","(","1000",",","4",",","format='csr","'",",","...","density=0.07",",","random_state=5",")",">",">",">","ipca","=","IncrementalPCA","(","n_components=2",",","batch_size=200",")",">",">",">","ipca.fit","(","X",")","IncrementalPCA","(",")",">",">",">",">",">",">","#","Components",":",">",">",">","ipca.components_","#","doctest",":","+SKIP","array","(","[","[","0.23698335",",","-0.06073393",",","0.04310868",",","0.9686547","]",",","[","0.27040346",",","-0.57185116",",","0.76248786",",","-0.13594291","]","]",")",">",">",">",">",">",">","#","Singular","Values",":",">",">",">","ipca.singular_values_","#","doctest",":","+SKIP","array","(","[","5.06637586",",","4.59406975","]",")",">",">",">",">",">",">","#","Explained","Variance",":",">",">",">","ipca.explained_variance_","#","doctest",":","+SKIP","array","(","[","0.02569386",",","0.0211266","]",")",">",">",">",">",">",">","#","Explained","Variance","Ratio",":",">",">",">","ipca.explained_variance_ratio_","#","doctest",":","+SKIP","array","(","[","0.30424536",",","0.25016372","]",")",">",">",">",">",">",">","#","Mean",":",">",">",">","ipca.mean_","#","doctest",":","+SKIP","array","(","[","0.02693948",",","0.0326928",",","0.03818463",",","0.03861492","]",")",">",">",">",">",">",">","#","Noise","Variance",":",">",">",">","ipca.noise_variance_.item","(",")","#","doctest",":","+SKIP","0.0037122774558343763"]
docstr: Apply dimensionality reduction to X.
  
  X is projected on the first principal components previously extracted
  from a training set, using minibatches of size batch_size if X is
  sparse.
  
  Parameters
  ----------
  
  X : array-like or sparse matrix, shape (n_samples, n_features)
      New data, where n_samples is the number of samples
      and n_features is the number of features.
  
  convert_dtype : bool, optional (default = False)
      When set to True, the transform method will automatically
      convert the input to the data type which was used to train the
      model. This will increase memory used for the method.
  
  Returns
  -------
  
  X_new : array-like, shape (n_samples, n_components)
docstr_tok: ["Apply","dimensionality","reduction","to","X.","X","is","projected","on","the","first","principal","components","previously","extracted","from","a","training","set",",","using","minibatches","of","size","batch_size","if","X","is","sparse",".","Parameters","--","--","--","--","--","X",":","array-like","or","sparse","matrix",",","shape","(","n_samples",",","n_features",")","New","data",",","where","n_samples","is","the","number","of","samples","and","n_features","is","the","number","of","features",".","convert_dtype",":","bool",",","optional","(","default","=","False",")","When","set","to","True",",","the","transform","method","will","automatically","convert","the","input","to","the","data","type","which","was","used","to","train","the","model",".","This","will","increase","memory","used","for","the","method",".","Returns","--","--","--","-","X_new",":","array-like",",","shape","(","n_samples",",","n_components",")"]
code: def transform(self, X, convert_dtype=False) -> CumlArray:
      """
      Apply dimensionality reduction to X.
  
      X is projected on the first principal components previously extracted
      from a training set, using minibatches of size batch_size if X is
      sparse.
  
      Parameters
      ----------
  
      X : array-like or sparse matrix, shape (n_samples, n_features)
          New data, where n_samples is the number of samples
          and n_features is the number of features.
  
      convert_dtype : bool, optional (default = False)
          When set to True, the transform method will automatically
          convert the input to the data type which was used to train the
          model. This will increase memory used for the method.
  
      Returns
      -------
  
      X_new : array-like, shape (n_samples, n_components)
  
      """
  
      if scipy.sparse.issparse(X) or cupyx.scipy.sparse.issparse(X):
          X = _validate_sparse_input(X)
  
          n_samples = X.shape[0]
          output = []
          for batch in _gen_batches(
              n_samples,
              self.batch_size_,
              min_batch_size=self.n_components or 0,
          ):
              output.append(super().transform(X[batch]))
          output, _, _, _ = input_to_cuml_array(
              cp.vstack(output), order="K"
          )
  
          return output
      else:
          return super().transform(X)
  
imports: from cuml.decomposition import PCA
  from cuml.internals.array import CumlArray
  import cuml.internals
  from cuml.internals.input_utils import input_to_cupy_array
  from cuml.common import input_to_cuml_array
  from cuml import Base
  from cuml.internals.safe_imports import cpu_only_import
  import numbers
  from cuml.internals.safe_imports import gpu_only_import
label_desc: Use image node_id 4 for calling the IncrementalPCA obj's underlying member method code with example usage: obj.transform(X, convert_dtype) and returns: output, super