示例#1
0
def _draw_plot(lines: [str]):
    for line in lines:
        (label, points) = _parse_plot(line)
        x_axis = [x for [x, _] in points]
        y_axis = [y for [_, y] in points]
        plt.plot(x_axis, y_axis, label=label)

    plt.legend()
    plt.plasma()
    plt.ylabel('Membrane Potential (µV)')
    plt.xlabel('Time (ms)')
    plt.show()
#!/usr/bin/env python3
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np

lib = np.load("pca.npz")
data = lib["data"]
labels = lib["labels"]

data_means = np.mean(data, axis=0)
norm_data = data - data_means
_, _, Vh = np.linalg.svd(norm_data)
pca_data = np.matmul(norm_data, Vh[:3].T)

fig = plt.figure()
ax = Axes3D(fig)

plt.plasma()

ax.scatter(pca_data[:, 0], pca_data[:, 1], pca_data[:, 2], c=labels)
ax.set_xlabel('U1')
ax.set_ylabel('U2')
ax.set_zlabel('U3')
plt.title('PCA of Iris Dataset')

plt.show()
示例#3
0
        e[it] = float(output_exit[it])

#    t_n = [0]*len(t)
    y_max = max(y)
    y_min = min(y)

    y_max += 0.02 * (y_max - y_min)
    y_min -= 0.02 * (y_max - y_min)

    x = np.array(x)
    y = np.array(y)
    t = np.array(t)
    d = np.array(d)
    e = np.array(e)

    cmap = plt.plasma()

    f, ax = plt.subplots()
    ax.set_title("KL-Divergence (%s)" % len(d))
    ax.set_ylabel('Privacy')
    ax.set_xlabel('Priority')
    points = ax.scatter(x, y, c=d, s=10, cmap=cmap)
    f.colorbar(points)
    plt.ylim((y_min, y_max))
    plt.show()

    x1 = x.copy()
    y1 = y.copy()
    d1 = d.copy()
    standard_deviation = np.std(d1)
    print("KL-Divergence")
    for it in range(len(output_exit) - 1):
        e[it] = int(output_exit[it])

    y_max = max(y)
    y_min = min(y)

    y_max += 0.02 * (y_max - y_min)
    y_min -= 0.02 * (y_max - y_min)

    x = np.array(x)
    y = np.array(y)
    t = np.array(t)
    d = np.array(d)
    e = np.array(e)

    cmap = plt.plasma()

    f, ax = plt.subplots()
    ax.set_title("KL-Divergence (%s)" % len(d))
    ax.set_ylabel('density')
    ax.set_xlabel('q_value')
    points = ax.scatter(x, y, c=d, s=10, cmap=cmap)
    f.colorbar(points)
    plt.ylim((y_min, y_max))
    plt.show()

    x1 = x.copy()
    y1 = y.copy()
    d1 = d.copy()
    standard_deviation = np.std(d1)
    print("KL-Divergence: ")
示例#5
0
fig = plt.figure()
ax2 = fig.add_subplot(111, projection='3d')

x1 = df.ix[0:, 'x1']
x2 = df.ix[0:, 'x2']
x3 = df.ix[0:, 'x3']
y = df.ix[0:, 'y']

if sys.argv[1:] == ['winter']:
    p = ax2.scatter(x1, x2, x3, c=y, cmap=plt.winter())
elif sys.argv[1:] == ['cool']:
    p = ax2.scatter(x1, x2, x3, c=y, cmap=plt.cool())
elif sys.argv[1:] == ['viridis']:
    p = ax2.scatter(x1, x2, x3, c=y, cmap=plt.viridis())
elif sys.argv[1:] == ['plasma']:
    p = ax2.scatter(x1, x2, x3, c=y, cmap=plt.plasma())
elif sys.argv[1:] == ['inferno']:
    p = ax2.scatter(x1, x2, x3, c=y, cmap=plt.inferno())
elif sys.argv[1:] == ['jet']:
    p = ax2.scatter(x1, x2, x3, c=y, cmap=plt.jet())
elif sys.argv[1:] == ['gist_ncar']:
    p = ax2.scatter(x1, x2, x3, c=y, cmap=plt.gist_ncar())
elif sys.argv[1:] == ['rainbow']:
    p = ax2.scatter(x1, x2, x3, c=y, cmap=plt.nipy_spectral())
else:
    p = ax2.scatter(x1, x2, x3, c=y, cmap=plt.nipy_spectral())

fig.colorbar(p)

ax2.set_xlabel('X1')
ax2.set_ylabel('X2')