spkit.data.spiral

spkit.data.spiral(N=[100, 100], s=0.5, wrappings='random', m='random', return_para=False, **kwargs)

Generate a 2-class dataset of spirals

Generating 2-classes of spirals

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.5
  • standard deviation of the gaussian noise.

wrappings: scalar, str, default=’random’
  • number of wrappings of each spiral.

m: scalar, str, default=’random’
  • multiplier m of x * sin(m * x) for the second spiral.

    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, wrappings, m): parameters
  • if return_para=True

Examples

#sp.data.spiral
import numpy as np
import matplotlib.pyplot as plt
import spkit as sp
X, y =  sp.data.spiral(N =[100, 100],s=0.1,wrappings=2,m=3)
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('Spiral Data')
plt.show()
../../_images/spkit-data-spiral-1.png