Composite UMAP
Combining multiple 'views' of the same dataset into a single projection.
As a simple example, we can split the Fashion MNIST dataset in two: one with the top half of the images and the other with the bottom half.
using UMAP
using Distances
using MLDatasets
using CairoMakie
n_points = 10_000;
fmnist_x = FashionMNIST.traintensor(Float64, 1:n_points);
First, run on full images for baseline.
full_res = @time UMAP.fit(reshape(fmnist_x, :, n_points), 2);
fmnist_x_top = reshape(fmnist_x[1:14, :, :], :, n_points);
fmnist_x_bot = reshape(fmnist_x[15:28, :, :], :, n_points);
fmnist_y = FashionMNIST.trainlabels(1:n_points);
Run UMAP on the top and bottom halves separately.
top_res = @time UMAP.fit(fmnist_x_top, 2);
bot_res = @time UMAP.fit(fmnist_x_bot, 2);
Pass both top and bottom halves as separate views using the advanced API.
The configuration for each view is the same as when run separately.
knn_params = (v1=UMAP.DescentNeighbors(15, Euclidean()),
v2=UMAP.DescentNeighbors(15, Euclidean()));
src_params = (v1=UMAP.SourceViewParams(1., 1, 1.),
v2=UMAP.SourceViewParams(1., 1, 1.));
gbl_params = UMAP.SourceGlobalParams(0.5);
memb_params = UMAP.MembershipFnParams(.1, 1.);
tgt_params = UMAP.TargetParams(UMAP._EuclideanManifold{2}(), SqEuclidean(), UMAP.SpectralInitialization(), memb_params);
opt_params = UMAP.OptimizationParams(300, 1., 1., 5);
comp_res = @time UMAP.fit((v1=fmnist_x_top, v2=fmnist_x_bot), knn_params, src_params, gbl_params, tgt_params, opt_params);