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

Function _generate_hypercube

sklearn/datasets/_samples_generator.py:30–43  ·  view source on GitHub ↗

Returns distinct binary samples of length dimensions.

(samples, dimensions, rng)

Source from the content-addressed store, hash-verified

28
29
30def _generate_hypercube(samples, dimensions, rng):
31 """Returns distinct binary samples of length dimensions."""
32 if dimensions > 30:
33 return np.hstack(
34 [
35 rng.randint(2, size=(samples, dimensions - 30)),
36 _generate_hypercube(samples, 30, rng),
37 ]
38 )
39 out = sample_without_replacement(2**dimensions, samples, random_state=rng).astype(
40 dtype=">u4", copy=False
41 )
42 out = np.unpackbits(out.view(">u1")).reshape((-1, 32))[:, -dimensions:]
43 return out
44
45
46@validate_params(

Callers 1

make_classificationFunction · 0.85

Calls 1

hstackMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…