# make_classification

### cuml.datasets.make_classification(n_samples=100, n_features=20, n_informative=2, n_redundant=2, n_repeated=0, n_classes=2, n_clusters_per_class=2, weights=None, flip_y=0.01, class_sep=1.0, hypercube=True, shift=0.0, scale=1.0, shuffle=True, random_state=None, order='F', dtype='float32', \_centroids=None, \_informative_covariance=None, \_redundant_covariance=None, \_repeated_indices=None)[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/datasets/classification.py#L35)

Generate a random n-class classification problem.
This initially creates clusters of points normally distributed (std=1)
about vertices of an `n_informative`-dimensional hypercube with sides of
length `2*class_sep` and assigns an equal number of clusters to each
class. It introduces interdependence between these features and adds
various types of further noise to the data.
Without shuffling, `X` horizontally stacks features in the following
order: the primary `n_informative` features, followed by `n_redundant`
linear combinations of the informative features, followed by `n_repeated`
duplicates, drawn randomly with replacement from the informative and
redundant features. The remaining features are filled with random noise.
Thus, without shuffling, all useful features are contained in the columns
`X[:, :n_informative + n_redundant + n_repeated]`.

* **Parameters:**
  **n_samples**
  : The number of samples.

  **n_features**
  : The total number of features. These comprise `n_informative`
    informative features, `n_redundant` redundant features,
    `n_repeated` duplicated features and
    `n_features-n_informative-n_redundant-n_repeated` useless features
    drawn at random.

  **n_informative**
  : The number of informative features. Each class is composed of a number
    of gaussian clusters each located around the vertices of a hypercube
    in a subspace of dimension `n_informative`. For each cluster,
    informative features are drawn independently from  N(0, 1) and then
    randomly linearly combined within each cluster in order to add
    covariance. The clusters are then placed on the vertices of the
    hypercube.

  **n_redundant**
  : The number of redundant features. These features are generated as
    random linear combinations of the informative features.

  **n_repeated**
  : The number of duplicated features, drawn randomly from the informative
    and the redundant features.

  **n_classes**
  : The number of classes (or labels) of the classification problem.

  **n_clusters_per_class**
  : The number of clusters per class.

  **weights**
  : The proportions of samples assigned to each class. If None, then
    classes are balanced. Note that if `len(weights) == n_classes - 1`,
    then the last class weight is automatically inferred.
    More than `n_samples` samples may be returned if the sum of
    `weights` exceeds 1.

  **flip_y**
  : The fraction of samples whose class is assigned randomly. Larger
    values introduce noise in the labels and make the classification
    task harder.

  **class_sep**
  : The factor multiplying the hypercube size.  Larger values spread
    out the clusters/classes and make the classification task easier.

  **hypercube**
  : If True, the clusters are put on the vertices of a hypercube. If
    False, the clusters are put on the vertices of a random polytope.

  **shift**
  : Shift features by the specified value. If None, then features
    are shifted by a random value drawn in [-class_sep, class_sep].

  **scale**
  : Multiply features by the specified value. If None, then features
    are scaled by a random value drawn in [1, 100]. Note that scaling
    happens after shifting.

  **shuffle**
  : Shuffle the samples and the features.

  **random_state**
  : Determines random number generation for dataset creation. Pass an int
    for reproducible output across multiple function calls.
    See [Glossary](https://scikit-learn.org/stable/glossary.html#term-random_state).

  **order: str, optional (default=’F’)**
  : The order of the generated samples

  **dtype**
  : Dtype of the generated samples

  **\_centroids: array of centroids of shape (n_clusters, n_informative)**

  **\_informative_covariance: array for covariance between informative features**
  : of shape (n_clusters, n_informative, n_informative)

  **\_redundant_covariance: array for covariance between redundant features**
  : of shape (n_informative, n_redundant)

  **\_repeated_indices: array of indices for the repeated features**
  : of shape (n_repeated, )
* **Returns:**
  **X**
  : The generated samples.

  **y**
  : The integer labels for class membership of each sample.

### Notes

The algorithm is adapted from Guyon [[1]](#raf8a76d479e9-1) and was designed to generate
the “Madelon” dataset. How we optimized for GPUs:

> 1. Firstly, we generate X from a standard univariate instead of zeros.
>    This saves memory as we don’t need to generate univariates each
>    time for each feature class (informative, repeated, etc.) while
>    also providing the added speedup of generating a big matrix
>    on GPU
> 2. We generate `order=F` construction. We exploit the
>    fact that X is a generated from a univariate normal, and
>    covariance is introduced with matrix multiplications. Which means,
>    we can generate X as a 1D array and just reshape it to the
>    desired order, which only updates the metadata and eliminates
>    copies
> 3. Lastly, we also shuffle by construction. Centroid indices are
>    permuted for each sample, and then we construct the data for
>    each centroid. This shuffle works for both `order=C` and
>    `order=F` and eliminates any need for secondary copies

### References

### Examples

```python
>>> from cuml.datasets.classification import make_classification

>>> X, y = make_classification(n_samples=10, n_features=4,
...                            n_informative=2, n_classes=2,
...                            random_state=10)

>>> print(X)
[[-1.7974224   0.24425316  0.39062843 -0.38293394]
[ 0.6358963   1.4161923   0.06970507 -0.16085647]
[-0.22802866 -1.1827322   0.3525861   0.276615  ]
[ 1.7308872   0.43080002  0.05048406  0.29837844]
[-1.9465544   0.5704457  -0.8997551  -0.27898186]
[ 1.0575483  -0.9171263   0.09529338  0.01173469]
[ 0.7917619  -1.0638094  -0.17599393 -0.06420116]
[-0.6686142  -0.13951421 -0.6074711   0.21645583]
[-0.88968956 -0.914443    0.1302423   0.02924336]
[-0.8817671  -0.84549576  0.1845096   0.02556021]]

>>> print(y)
[1 0 1 1 1 1 1 1 1 0]
```

<!-- !! processed by numpydoc !! -->
