Пример #1
0
    """
    import matplotlib.pyplot as plot
    plot.figure(random.randint(0, 10000000))
    plot.scatter(data[0], data[1], 20, 'b', 'o')
    plot.title(filename.split('.')[0])
    for line in lines:
        plot.plot([line[0], line[2]], [line[1], line[3]], '-')
    plot.savefig(filename)


def T(a):
    return a.reshape(len(a), 1)


x = load('pcaData.txt')

U, s, x_rot = pca.pca(x)
scatter('raw-scatterplot.png', x, [((0, 0) + tuple(r)) for r in U.T])

scatter('x-rot.png', x_rot)

k = 1
U, s, xHat = pca.pca(x, k)
scatter('xHat.png', np.vstack([xHat, xHat]))

xPCAwhite = pca.pca_whiten(x)
scatter('xPCAwhite.png', xPCAwhite)

xZCAwhite = pca.zca_whiten(x)
scatter('xZCAwhite.png', xZCAwhite)
Пример #2
0
    x_hat = np.dot(U[:, :k], small_x_rot)
    display_network.display_network('99-reduced.png', x_hat)

    # first index greater than 90%
    k = np.min(np.where(pov >= 0.90))
    print 'k:', k
    U, s, small_x_rot = pca.pca(patches, k=k)
    x_hat = np.dot(U[:, :k], small_x_rot)
    display_network.display_network('90-reduced.png', x_hat)

    # first index greater than 50%
    k = np.min(np.where(pov >= 0.50))
    print 'k:', k
    U, s, small_x_rot = pca.pca(patches, k=k)
    x_hat = np.dot(U[:, :k], small_x_rot)
    display_network.display_network('50-reduced.png', x_hat)

    epsilon = 0.1
    x_pca_white = pca.pca_whiten(patches, epsilon=epsilon)
    c = pca.covariance(x_pca_white)
    display_network.array_to_file('pca_white_covariance.png', c)

    epsilon = 0.0
    x_pca_white = pca.pca_whiten(patches, epsilon=epsilon)
    c = pca.covariance(x_pca_white)
    display_network.array_to_file('pca_white_noreg_covariance.png', c)

    for epsilon in [1, 0.1, 0.01]:
        x_zca_white = pca.zca_whiten(patches, epsilon=epsilon)
        display_network.display_network('zca_%s.png' % epsilon, x_zca_white)
Пример #3
0
    k = np.min(np.where(pov >= 0.90))
    print 'k:', k
    U, s, small_x_rot = pca.pca(patches, k=k)
    x_hat = np.dot(U[:,:k], small_x_rot)
    display_network.display_network('90-reduced.png', x_hat)

    # first index greater than 50%
    k = np.min(np.where(pov >= 0.50))
    print 'k:', k
    U, s, small_x_rot = pca.pca(patches, k=k)
    x_hat = np.dot(U[:,:k], small_x_rot)
    display_network.display_network('50-reduced.png', x_hat)


    epsilon = 0.1
    x_pca_white = pca.pca_whiten(patches, epsilon=epsilon)
    c = pca.covariance(x_pca_white)
    display_network.array_to_file('pca_white_covariance.png', c)


    epsilon = 0.0
    x_pca_white = pca.pca_whiten(patches, epsilon=epsilon)
    c = pca.covariance(x_pca_white)
    display_network.array_to_file('pca_white_noreg_covariance.png', c)


    for epsilon in [1, 0.1, 0.01]:
        x_zca_white = pca.zca_whiten(patches, epsilon=epsilon)
        display_network.display_network('zca_%s.png' % epsilon, x_zca_white)

Пример #4
0
    """
    import matplotlib.pyplot as plot
    plot.figure(random.randint(0, 10000000))
    plot.scatter(data[0], data[1], 20, 'b', 'o')
    plot.title(filename.split('.')[0])
    for line in lines:
        plot.plot([line[0], line[2]], [line[1], line[3]], '-')
    plot.savefig(filename)

def T(a):
    return a.reshape(len(a), 1)

x = load('pcaData.txt')


U, s, x_rot = pca.pca(x)
scatter('raw-scatterplot.png', x, [((0,0)+tuple(r)) for r in U.T])

scatter('x-rot.png', x_rot)

k = 1
U, s, xHat = pca.pca(x, k)
scatter('xHat.png', np.vstack([xHat, xHat]))

xPCAwhite = pca.pca_whiten(x)
scatter('xPCAwhite.png', xPCAwhite)

xZCAwhite = pca.zca_whiten(x)
scatter('xZCAwhite.png', xZCAwhite)