Skip to content

Commit

Permalink
Adding a test for verifying the shape of imputed matrices
Browse files Browse the repository at this point in the history
  • Loading branch information
ankit-maverick committed Nov 6, 2013
1 parent 28997f6 commit 6f8186f
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions sklearn/preprocessing/tests/test_imputation.py
Expand Up @@ -76,6 +76,19 @@ def _check_statistics(X, X_true,
err_msg.format(1, True))


def test_imputation_shape():
"""Verify the shapes of the imputed matrix for different strategies."""
X = np.random.randn(10, 2)
X[::2] = np.nan

for strategy in ['mean', 'median', 'most_frequent']:
imputer = Imputer(strategy=strategy)
X_imputed = imputer.fit_transform(X)
assert(X_imputed.shape == (10, 2))
X_imputed = imputer.fit_transform(sparse.csr_matrix(X))
assert(X_imputed.shape == (10, 2))


def test_imputation_mean_median_only_zero():
"""Test imputation using the mean and median strategies, when
missing_values == 0."""
Expand Down

0 comments on commit 6f8186f

Please sign in to comment.