def dummy_sparse(groups):
 from scipy import sparse
 indptr = np.arange((len(groups) + 1))
 data = np.ones(len(groups), dtype=np.int8)
 indi = sparse.csr_matrix((data, g, indptr))
 return indi

def dummy_sparse ( groups ) : from scipy import sparse indptr = np . arange ( ( len ( groups ) + 1 ) ) data = np . ones ( len ( groups ) , dtype = np . int8 ) indi = sparse . csr_matrix ( ( data , g , indptr ) ) return indi
create a sparse indicator from a group array with integer labels parameters groups: ndarray .