def createinstance(params): params = dict(params) filter0 = params.pop('filter0', True) useFixedThreshold = params.pop('useFixedThreshold', True) if useFixedThreshold: threshold = params.pop('fixedThresh', 50) else: threshold = params.pop('percThresh', 5) / 100 return RemoveSparse(threshold, filter0)
def test_sparse(self): true_out = self.data[:, 1] self.data.X = csr_matrix(self.data.X) true_out.X = csr_matrix(true_out.X) out = RemoveSparse(0.5)(self.data).X np.testing.assert_array_equal(out, true_out)
def test_dense(self): true_out = self.data[:, 1] true_out.X = true_out.X.reshape(-1, 1) out = RemoveSparse(0.5)(self.data) np.testing.assert_array_equal(out, true_out)
def createinstance(params): params = dict(params) threshold = params.pop('sparse_thresh', 5) return RemoveSparse(threshold=threshold / 100)