sklearn.utils.sparsefuncs
.incr_mean_variance_axis¶

sklearn.utils.sparsefuncs.
incr_mean_variance_axis
(X, axis, last_mean, last_var, last_n)[source]¶ Compute incremental mean and variance along an axix on a CSR or CSC matrix.
last_mean, last_var are the statistics computed at the last step by this function. Both must be initilized to 0arrays of the proper size, i.e. the number of features in X. last_n is the number of samples encountered until now.
Parameters: X : CSR or CSC sparse matrix, shape (n_samples, n_features)
Input data.
axis : int (either 0 or 1)
Axis along which the axis should be computed.
last_mean : float array with shape (n_features,)
Array of featurewise means to update with the new data X.
last_var : float array with shape (n_features,)
Array of featurewise var to update with the new data X.
last_n : int
Number of samples seen so far, excluded X.
Returns: means : float array with shape (n_features,)
Updated featurewise means.
variances : float array with shape (n_features,)
Updated featurewise variances.
n : int
Updated number of seen samples.