MCPcopy Index your code
hub / github.com/mne-tools/mne-python / _make_data

Function _make_data

mne/decoding/tests/test_base.py:58–96  ·  view source on GitHub ↗

Generate some testing data. Parameters ---------- n_samples : int The number of samples. n_features : int The number of features. n_targets : int The number of targets. Returns ------- X : ndarray, shape (n_samples, n_features) The me

(n_samples=1000, n_features=5, n_targets=3)

Source from the content-addressed store, hash-verified

56
57
58def _make_data(n_samples=1000, n_features=5, n_targets=3):
59 """Generate some testing data.
60
61 Parameters
62 ----------
63 n_samples : int
64 The number of samples.
65 n_features : int
66 The number of features.
67 n_targets : int
68 The number of targets.
69
70 Returns
71 -------
72 X : ndarray, shape (n_samples, n_features)
73 The measured data.
74 Y : ndarray, shape (n_samples, n_targets)
75 The latent variables generating the data.
76 A : ndarray, shape (n_features, n_targets)
77 The forward model, mapping the latent variables (=Y) to the measured
78 data (=X).
79 """
80 # Define Y latent factors
81 np.random.seed(0)
82 cov_Y = np.eye(n_targets) * 10 + np.random.rand(n_targets, n_targets)
83 cov_Y = (cov_Y + cov_Y.T) / 2.0
84 mean_Y = np.random.rand(n_targets)
85 Y = np.random.multivariate_normal(mean_Y, cov_Y, size=n_samples)
86
87 # The Forward model
88 A = np.random.randn(n_features, n_targets)
89
90 X = Y.dot(A.T)
91 X += np.random.randn(n_samples, n_features) # add noise
92 X += np.random.rand(n_features) # Put an offset
93 if n_targets == 1:
94 Y = Y[:, 0]
95
96 return X, Y, A
97
98
99def test_get_coef():

Callers 4

test_get_coefFunction · 0.70
test_get_coef_multiclassFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected