def plot_canonical_roll(X, GT):
  # manifold space
  fig = pyplot.figure(figsize=(8,5))
  scatterplot(GT, c=GT[:,0], edgecolor='k', s=20, marker='o', fig=fig)
  ax = pyplot.gca()
  pyplot.setp(ax.get_xticklabels(), visible=False)
  pyplot.setp(ax.get_yticklabels(), visible=False)
  ax.set_xlabel('$\\theta$', labelpad=15, size=20)
  ax.set_ylabel('$r$', labelpad=20, rotation=0, size=20)
  ax.set_xlim((-0.02, 1.02))
  ax.set_ylim((-0.02, 1.02))
  savefig('swiss_roll_flat.png')
  # input space
  pyplot.figure()
  scatterplot(X, c=GT[:,0], edgecolor='k', s=20, marker='o')
  ax = pyplot.gca()
  pyplot.setp(ax.get_xticklabels(), visible=False)
  pyplot.setp(ax.get_yticklabels(), visible=False)
  pyplot.setp(ax.get_zticklabels(), visible=False)
  ax.set_xlabel('$x$', labelpad=15, size=20)
  ax.set_ylabel('$z$', labelpad=20, rotation=0, size=20)
  ax.set_zlabel('$y$', labelpad=20, rotation=0, size=20)
  ax.view_init(elev=6, azim=265)
  ax.autoscale_view(True, True, True)
  savefig('swiss_roll.png')
Exemplo n.º 2
0
def plot_roll(W, X, colors, embed_dim, image_name):
    fig, (ax1, ax2) = pyplot.subplots(ncols=2)

    show_neighbor_graph(X[:, (0, 2)],
                        W,
                        ax=ax1,
                        vertex_colors=colors,
                        vertex_edgecolor='k',
                        edge_style='k-')

    # show the embedding
    D = pairwise_distances(X, metric='euclidean')
    D[~W.astype(bool)] = 0
    embed = isomap(D, embed_dim)
    scatterplot(embed, ax=ax2, c=colors, marker='o', edgecolor='k')
    for ax in (ax1, ax2):
        ax.tick_params(which='both',
                       bottom='off',
                       top='off',
                       left='off',
                       right='off',
                       labelbottom='off',
                       labelleft='off')
    fig.tight_layout()
    savefig(image_name)
Exemplo n.º 3
0
def plot_canonical_roll(X, GT):
    # manifold space
    fig = pyplot.figure(figsize=(8, 5))
    scatterplot(GT, c=GT[:, 0], edgecolor='k', s=20, marker='o', fig=fig)
    ax = pyplot.gca()
    pyplot.setp(ax.get_xticklabels(), visible=False)
    pyplot.setp(ax.get_yticklabels(), visible=False)
    ax.set_xlabel('$\\theta$', labelpad=15, size=20)
    ax.set_ylabel('$r$', labelpad=20, rotation=0, size=20)
    ax.set_xlim((-0.02, 1.02))
    ax.set_ylim((-0.02, 1.02))
    savefig('swiss_roll_flat.png')
    # input space
    pyplot.figure()
    scatterplot(X, c=GT[:, 0], edgecolor='k', s=20, marker='o')
    ax = pyplot.gca()
    pyplot.setp(ax.get_xticklabels(), visible=False)
    pyplot.setp(ax.get_yticklabels(), visible=False)
    pyplot.setp(ax.get_zticklabels(), visible=False)
    ax.set_xlabel('$x$', labelpad=15, size=20)
    ax.set_ylabel('$z$', labelpad=20, rotation=0, size=20)
    ax.set_zlabel('$y$', labelpad=20, rotation=0, size=20)
    ax.view_init(elev=6, azim=265)
    ax.autoscale_view(True, True, True)
    savefig('swiss_roll.png')
def plot_roll(W, X, colors, embed_dim, image_name):
  fig, (ax1,ax2) = pyplot.subplots(ncols=2)

  show_neighbor_graph(X[:,(0,2)], W, ax=ax1, vertex_colors=colors,
                      vertex_edgecolor='k', edge_style='k-')

  # show the embedding
  D = pairwise_distances(X, metric='euclidean')
  D[~W.astype(bool)] = 0
  embed = isomap(D, embed_dim)
  scatterplot(embed, ax=ax2, c=colors, marker='o', edgecolor='k')
  for ax in (ax1,ax2):
    ax.tick_params(which='both', bottom='off', top='off', left='off',
                   right='off', labelbottom='off', labelleft='off')
  fig.tight_layout()
  savefig(image_name)
def show_skeleton_issue():
  t = np.linspace(0,4,25)[:,None]
  X = np.hstack((np.cos(t), np.random.uniform(-1,1,t.shape), np.sin(t)))
  GT = np.hstack((t, X[:,1:2]))
  W = neighbor_graph(X, k=1, symmetrize=False)
  W = grow_trees(X, W, 2)
  labels = join_CCs_simple(X, W)
  # switch up the CC order for better contrast between groups
  order = np.arange(labels.max()+1)
  np.random.shuffle(order)
  labels = order[labels]
  show_neighbor_graph(GT, W, vertex_style=None, edge_style='k-')
  ax = pyplot.gca()
  for l,marker in zip(np.unique(labels), "osD^v><"):
    scatterplot(GT[labels==l], marker, ax=ax, edgecolor='k', c='white')
  ax.tick_params(which='both', bottom='off', top='off', left='off',
                 right='off', labelbottom='off', labelleft='off')
  savefig('skeleton.png')
Exemplo n.º 6
0
def show_skeleton_issue():
    t = np.linspace(0, 4, 25)[:, None]
    X = np.hstack((np.cos(t), np.random.uniform(-1, 1, t.shape), np.sin(t)))
    GT = np.hstack((t, X[:, 1:2]))
    W = neighbor_graph(X, k=1, symmetrize=False)
    W = grow_trees(X, W, 2)
    labels = join_CCs_simple(X, W)
    # switch up the CC order for better contrast between groups
    order = np.arange(labels.max() + 1)
    np.random.shuffle(order)
    labels = order[labels]
    show_neighbor_graph(GT, W, vertex_style=None, edge_style='k-')
    ax = pyplot.gca()
    for l, marker in zip(np.unique(labels), "osD^v><"):
        scatterplot(GT[labels == l], marker, ax=ax, edgecolor='k', c='white')
    ax.tick_params(which='both',
                   bottom='off',
                   top='off',
                   left='off',
                   right='off',
                   labelbottom='off',
                   labelleft='off')
    savefig('skeleton.png')