spkit.data.moons

spkit.data.moons(N=[100, 100], s=0.1, d='random', angle='random', return_para=False, **kwargs)

Generate a 2-class dataset from two “moon” distributions

Sample a dataset from two “moon” distributions

Parameters:
N: list or two int, default =[100,100]
  • vector that fix the number of samples from each class

  • example N = [100,100], 100 samples for each class

s: scalar, default=0.1
  • standard deviation of the gaussian noise.

d: scalar, str, default=’random’
  • 1x2 translation vector between the two classes.

  • With d = 0 the classes are placed on a circle.

angle: scalar , default=’random’
  • rotation angle of the moons (radians)

    New in version 0.0.9.7: Added to return parameters

return_para: bool, default=False
  • if True, return the parameters

Returns:
X: 2d-array
  • data matrix with a sample for each row

  • shape (n, 2)

    Changed in version 0.0.9.7: shape is changed to (n, 2)

y: 1d-array
  • vector with the labels

    Changed in version 0.0.9.7: shape is changed to (n, )

(s, d, angle): parameters
  • if return_para=True

Examples

#sp.data.moons
import numpy as np
import matplotlib.pyplot as plt
import spkit as sp
np.random.seed(7)
X, y =  sp.data.moons(N =[100, 100],s=0.2,d='random', angle='random')
np.random.seed(None)
plt.figure()
plt.plot(X[y==0,0],X[y==0,1],'o')
plt.plot(X[y==1,0],X[y==1,1],'o')
plt.xlabel('x1')
plt.ylabel('x2')
plt.title('Moons Data')
plt.show()
../../_images/spkit-data-moons-1.png