algorithms/k-means/utilities.py
def generate_random_gaussian_data(nb_objs, nb_attrs, k):
    """
    Generate k cluster of points following a gaussian repartition.
    :param nb_objs: total number of points to generate
    :param nb_attrs:
    :param k: The number of groups to create.
    :return:
    """
    data = []

    centers = generate_random_data(k, nb_attrs)

    centers = np.array(centers)
    centers = centers[:, 1:]

    for i in range(nb_objs):
        center = centers[random.randint(0, len(centers) - 1)]
        line = [i + 1] + list(map(lambda x: random.gauss(x, 0.05), center))
        # line = [i+1, random.gauss(center[j],1) for j in range(len(center))]
        data.append(line)
    return data

    Generate k cluster of points following a gaussian repartition.
    :param nb_objs: total number of points to generate
    :param nb_attrs:
    :param k: The number of groups to create.
    :return:
    
Generate k cluster of points following a gaussian repartition.
Generate k cluster of points following a gaussian repartition .
def generate_random_gaussian_data(nb_objs, nb_attrs, k):
    data = []
    centers = generate_random_data(k, nb_attrs)
    centers = np.array(centers)
    centers = centers[:, 1:]
    for i in range(nb_objs):
        center = centers[random.randint(0, len(centers) - 1)]
        line = [i + 1] + list(map(lambda x: random.gauss(x, 0.05), center))
        data.append(line)
    return data
def generate_random_gaussian_data ( nb_objs , nb_attrs , k ) : data = [ ] centers = generate_random_data ( k , nb_attrs ) centers = np . array ( centers ) centers = centers [ : , 1 : ] for i in range ( nb_objs ) : center = centers [ random . randint ( 0 , len ( centers ) - 1 ) ] line = [ i + 1 ] + list ( map ( lambda x : random . gauss ( x , 0.05 ) , center ) ) data . append ( line ) return data
Generate k cluster of points following a gaussian repartition.
Generate k cluster of points following a gaussian repartition .
"""
    Generate k cluster of points following a gaussian repartition.
    :param nb_objs: total number of points to generate
    :param nb_attrs:
    :param k: The number of groups to create.
    :return:
    """ # line = [i+1, random.gauss(center[j],1) for j in range(len(center))]
None
nb_objs
total number of points to generate
total number of points to generate
nb_attrs
None
k
The number of groups to create.
The number of groups to create .