def generateClassificationData(size, nClasses=3):
 if (nClasses == 3):
  means = [((-1), 0), (2, 4), (3, 1)]
 else:
  means = [((-2), 0), (2, 1), (6, 0)]
 cov = [diag([1, 1]), diag([0.5, 1.2]), diag([1.5, 0.7])]
 dataset = ClassificationDataSet(2, 1, nb_classes=nClasses)
 for _ in range(size):
  for c in range(3):
   input = multivariate_normal(means[c], cov[c])
   dataset.addSample(input, [(c % nClasses)])
 dataset.assignClasses()
 return dataset

def generateClassificationData ( size , nClasses = 3 ) : if ( nClasses == 3 ) : means = [ ( ( - 1 ) , 0 ) , ( 2 , 4 ) , ( 3 , 1 ) ] else : means = [ ( ( - 2 ) , 0 ) , ( 2 , 1 ) , ( 6 , 0 ) ] cov = [ diag ( [ 1 , 1 ] ) , diag ( [ 0.5 , 1.2 ] ) , diag ( [ 1.5 , 0.7 ] ) ] dataset = ClassificationDataSet ( 2 , 1 , nb_classes = nClasses ) for _ in range ( size ) : for c in range ( 3 ) : input = multivariate_normal ( means [ c ] , cov [ c ] ) dataset . addSample ( input , [ ( c % nClasses ) ] ) dataset . assignClasses ( ) return dataset
generate a set of points in 2d belonging to two or three different classes .