<jupyter_start><jupyter_text>First let's load our Fashion MNIST dataset.<jupyter_code>data, labels = fetch_openml('Fashion-MNIST', version=1, return_X_y=True)<jupyter_output><empty_output><jupyter_text>Now lets use UMAP to learn our embedding space.<jupyter_code>mapper = umap.UMAP(random_state=42,verbose=True).fit(data)
umap.plot.points(mapper, labels=labels)
corners = np.array([
    [2.5, -2.5],  # bags
    [-2, 9],  # boots?
    [13, -2.5],  # shirts/tops/dresses
    [10, 12],  # pants
])

test_pts = np.array([
    (corners[0]*(1-x) + corners[1]*x)*(1-y) +
    (corners[2]*(1-x) + corners[3]*x)*y
    for y in np.linspace(0, 1, 10)
    for x in np.linspace(0, 1, 10)
])


inv_transformed_points = trans.inverse_transform(test_pts)
# Set up the grid
fig = plt.figure(figsize=(12,6))
gs = GridSpec(10, 20, fig)
scatter_ax = fig.add_subplot(gs[:, :10])
digit_axes = np.zeros((10, 10), dtype=object)
for i in range(10):
    for j in range(10):
        digit_axes[i, j] = fig.add_subplot(gs[i, 10 + j])

# Use umap.plot to plot to the major axis
# umap.plot.points(mapper, labels=labels, ax=scatter_ax)
scatter_ax.scatter(mapper.embedding_[:, 0], mapper.embedding_[:, 1],
                   c=labels.astype(np.int32), cmap='Spectral', s=0.1)
#scatter_ax.set(xticks=[], yticks=[])

# Plot the locations of the text points
scatter_ax.scatter(test_pts[:, 0], test_pts[:, 1], marker='x', c='k', s=15)

# Plot each of the generated digit images
for i in range(10):
    for j in range(10):
        digit_axes[i, j].imshow(inv_transformed_points[i*10 + j].reshape(28, 28))
        digit_axes[i, j].set(xticks=[], yticks=[])<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17465130382049726, 'fraction_numerical': 0.0430563978168587, 'mean_word_length': 4.4635761589403975, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '377265', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 719, 'n_tokens_neox': 668, 'n_words': 142, 'path': 'examples/Inverse Transform.ipynb', 'repo_name': 'afrancl/UMAP_lab_meeting', 'size': '1649'}