Exemplo n.º 1
0
def runScript():
    [X, Y] = sm.generateDataMatrices(conn);
    kerrors = [];
    for k in range(1, 11):
        toterror = float('Inf');
        for n in range(Nk):
            Mus = kmeans(X, k);
            avdist = calculateAverageDistance(X, Mus) / float(Nk);
            if avdist < toterror:
                toterror = avdist;
        kerrors.append(toterror);
    print kerrors;
Exemplo n.º 2
0
def runScript():
    [X, Y] = sm.generateDataMatrices(conn);
    X = zeroOutMeans(X);
    X = unitStd(X);
    Cov = generateCovMatrix(X);
    [U,S,V] = np.linalg.svd(Cov);
    print Cov;
    with open('data.csv', 'w') as csvfile:
        writer = csv.writer(csvfile);
        [writer.writerow(r) for r in X];
    file = open('dataLabels.csv', 'w');
    for elem in Y:
        file.write("%s\n" % elem);