def csc_median_axis_0(X):
 if (not isinstance(X, sp.csc_matrix)):
  raise TypeError(('Expected matrix of CSC format, got %s' % X.format))
 indptr = X.indptr
 (n_samples, n_features) = X.shape
 median = np.zeros(n_features)
 for (f_ind, (start, end)) in enumerate(zip(indptr[:(-1)], indptr[1:])):
  data = np.copy(X.data[start:end])
  nz = (n_samples - data.size)
  median[f_ind] = _get_median(data, nz)
 return median

def csc_median_axis_0 ( X ) : if ( not isinstance ( X , sp . csc_matrix ) ) : raise TypeError ( ( 'Expected matrix of CSC format, got %s' % X . format ) ) indptr = X . indptr ( n_samples , n_features ) = X . shape median = np . zeros ( n_features ) for ( f_ind , ( start , end ) ) in enumerate ( zip ( indptr [ : ( - 1 ) ] , indptr [ 1 : ] ) ) : data = np . copy ( X . data [ start : end ] ) nz = ( n_samples - data . size ) median [ f_ind ] = _get_median ( data , nz ) return median
find the median across axis 0 of a csc matrix .