module datasets.artificial

Short summary

module pymlbenchmark.datasets.artificial

Artificial datasets.

source on GitHub

Functions

function

truncated documentation

random_binary_classification

Returns data for a binary classification problem (linear) with N observations and dim features.

random_regression

Returns data for a binary classification problem (linear) with N observations and dim features.

Documentation

Artificial datasets.

source on GitHub

pymlbenchmark.datasets.artificial.rand(d0, d1, ..., dn)

Random values in a given shape.

Note

This is a convenience function for users porting code from Matlab, and wraps random_sample. That function takes a tuple to specify the size of the output, which is consistent with other NumPy functions like numpy.zeros and numpy.ones.

Create an array of the given shape and populate it with random samples from a uniform distribution over [0, 1).

d0, d1, …, dnint, optional

The dimensions of the returned array, must be non-negative. If no argument is given a single Python float is returned.

outndarray, shape (d0, d1, ..., dn)

Random values.

random

>>> np.random.rand(3,2)
array([[ 0.14022471,  0.96360618],  #random
       [ 0.37601032,  0.25528411],  #random
       [ 0.49313049,  0.94909878]]) #random
pymlbenchmark.datasets.artificial.randn(d0, d1, ..., dn)

Return a sample (or samples) from the “standard normal” distribution.

Note

This is a convenience function for users porting code from Matlab, and wraps standard_normal. That function takes a tuple to specify the size of the output, which is consistent with other NumPy functions like numpy.zeros and numpy.ones.

Note

New code should use the standard_normal method of a default_rng() instance instead; please see the Quick Start.

If positive int_like arguments are provided, randn generates an array of shape (d0, d1, ..., dn), filled with random floats sampled from a univariate “normal” (Gaussian) distribution of mean 0 and variance 1. A single float randomly sampled from the distribution is returned if no argument is provided.

d0, d1, …, dnint, optional

The dimensions of the returned array, must be non-negative. If no argument is given a single Python float is returned.

Zndarray or float

A (d0, d1, ..., dn)-shaped array of floating-point samples from the standard normal distribution, or a single such float if no parameters were supplied.

standard_normal : Similar, but takes a tuple as its argument. normal : Also accepts mu and sigma arguments. Generator.standard_normal: which should be used for new code.

For random samples from N(\mu, \sigma^2), use:

sigma * np.random.randn(...) + mu

>>> np.random.randn()
2.1923875335537315  # random

Two-by-four array of samples from N(3, 6.25):

>>> 3 + 2.5 * np.random.randn(2, 4)
array([[-4.49401501,  4.00950034, -1.81814867,  7.29718677],   # random
       [ 0.39924804,  4.68456316,  4.99394529,  4.84057254]])  # random
pymlbenchmark.datasets.artificial.random_binary_classification(N, dim)

Returns data for a binary classification problem (linear) with N observations and dim features.

Parameters:
  • N – number of observations

  • dim – number of features

Returns:

X, y

<<<

from pymlbenchmark.datasets import random_binary_classification
X, y = random_binary_classification(3, 6)
print(y)
print(X)

>>>

    [0 0 0]
    [[0.714 0.406 0.4   0.791 0.435 0.499]
     [0.312 0.833 0.876 0.09  0.009 0.109]
     [0.352 0.104 0.097 0.061 0.758 0.53 ]]

source on GitHub

pymlbenchmark.datasets.artificial.random_regression(N, dim)

Returns data for a binary classification problem (linear) with N observations and dim features.

Parameters:
  • N – number of observations

  • dim – number of features

Returns:

X, y

<<<

from pymlbenchmark.datasets import random_regression
X, y = random_regression(3, 6)
print(y)
print(X)

>>>

    [2.314 3.594 3.257]
    [[0.927 0.648 0.422 0.119 0.369 0.977]
     [0.265 0.923 0.779 0.037 0.686 0.454]
     [0.011 0.449 0.578 0.724 0.356 0.533]]

source on GitHub