MCPcopy
hub / github.com/scikit-learn/scikit-learn / test_preprocess_data

Function test_preprocess_data

sklearn/linear_model/tests/test_base.py:373–400  ·  view source on GitHub ↗
(global_random_seed)

Source from the content-addressed store, hash-verified

371
372
373def test_preprocess_data(global_random_seed):
374 rng = np.random.RandomState(global_random_seed)
375 n_samples = 200
376 n_features = 2
377 X = rng.rand(n_samples, n_features)
378 y = rng.rand(n_samples)
379 expected_X_mean = np.mean(X, axis=0)
380 expected_y_mean = np.mean(y, axis=0)
381
382 Xt, yt, X_mean, y_mean, X_scale, sqrt_sw = _preprocess_data(
383 X, y, fit_intercept=False
384 )
385 assert_array_almost_equal(X_mean, np.zeros(n_features))
386 assert_array_almost_equal(y_mean, 0)
387 assert_array_almost_equal(X_scale, np.ones(n_features))
388 assert sqrt_sw is None
389 assert_array_almost_equal(Xt, X)
390 assert_array_almost_equal(yt, y)
391
392 Xt, yt, X_mean, y_mean, X_scale, sqrt_sw = _preprocess_data(
393 X, y, fit_intercept=True
394 )
395 assert_array_almost_equal(X_mean, expected_X_mean)
396 assert_array_almost_equal(y_mean, expected_y_mean)
397 assert_array_almost_equal(X_scale, np.ones(n_features))
398 assert sqrt_sw is None
399 assert_array_almost_equal(Xt, X - expected_X_mean)
400 assert_array_almost_equal(yt, y - expected_y_mean)
401
402
403@pytest.mark.parametrize("sparse_container", [None] + CSC_CONTAINERS)

Callers

nothing calls this directly

Calls 1

_preprocess_dataFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…