spartans package¶
Top-level package for Spartans.
Submodules¶
spartans.core module¶
-
spartans.core.constant_index(x, axis, mask=None, as_bool=True, threshold=0)[source]¶ Returns the indices of the constant rows/features
- x : sparse matrix
- data matrix
- axis : int
- axis to return indices for
- mask : sparse matrix [bool]
- mask of values to consider as nan
- as_bool : bool
- whether to return a mask of bool indices or vector of numbers
- threshold : numeric
- decided constant by the feature variance, can be larger than 0 for “almost-constant” features
- cond : array_like
- Either an array with number of indices or boolean mask
-
spartans.core.corr(x, y=None, mask=None)[source]¶ Return a correlation vector between matrix x and target column y if given, else a auto-correlation matrix for the features of matrix x
- x : sparse matrix
- Data Matrix
- y : array_like
- target array
- mask : sparse matrix [bool]
- mask of values to consider as nan
- ret
- correlation vector if y in given, also auto-correlation for x
-
spartans.core.cov(x, y=None, mask=None, blocks=1)[source]¶ - x : sparse matrix
- Data Matrix
- y : array_like
- target array
- mask : sparse matrix [bool]
- mask of values to consider as nan
- blocks : int
- amount of blocks of computing (for large matrices)
- ret
- covariance vector if y in given, also auto-covariance for x
-
spartans.core.non_constant_index(x, axis, mask=None, as_bool=True, threshold=0, method='variance')[source]¶ Returns the indices of the non constant (informative) rows/features
- x : sparse matrix
- data matrix
- axis : int
- axis to return indices for
- mask : sparse matrix [bool]
- mask of values to consider as nan
- as_bool : bool
- whether to return a mask of bool indices or vector of numbers
- threshold : numeric
- decided constant by the feature variance, can be larger than 0 for “almost-constant” features
- cond : array_like
- Either an array with number of indices or boolean mask
-
spartans.core.non_zero_index(x, axis, as_bool=True)[source]¶ return the index of all rows/features that are not all zero
- x : sparse matrix
- data matrix
- axis : int
- axis to return indices for
- mask : sparse matrix [bool]
- mask of values to consider as nan
- as_bool : bool
- whether to return a mask of bool indices or vector of numbers
- cond : array_like
- Either an array with number of indices or boolean mask
-
spartans.core.variance(x, axis=None, mask=None, **kwargs)[source]¶ Returns variance by axis or for entire sparse matrix
mask x : sparse.csr_matrix
matrix to compute variance for- axis : int or None
- axis to return variance for, or None if for entire matrix
- kwargs
- passed to np.mean
- var_ : array_like
- array of ndim=1 if axis is given or 0 dim (scalar) if axis is None