Swissroll with hole

[1]:
%matplotlib inline
[2]:
# Not really required
import sys
sys.path.insert(0, '../../..')
[3]:
from pyLDLE2 import datasets
from pyLDLE2 import buml_, util_
matplotlib.get_backend() =  module://matplotlib_inline.backend_inline
[4]:
save_dir_root = '../data/pyLDLE2/swissrollwithhole/'
[5]:
X, labelsMat, ddX = datasets.Datasets().swissrollwithhole()
X.shape =  (9946, 3)
[6]:
# The supplied options would override the default options
buml_obj = buml_.BUML(local_opts={'algo':'LDLE'},
                      intermed_opts={'algo':'best', 'eta_min': 10},
                      vis_opts={'c': labelsMat[:,0], 'save_dir': save_dir_root},
                      verbose=True, debug=True)
local_opts['k_nn0'] = 700 is created.
Options provided:
local_opts:
{
    "Atilde_method": "LDLE_1",
    "N": 100,
    "U_method": "k_nn",
    "algo": "LDLE",
    "alpha": 1,
    "debug": true,
    "delta": 0.9,
    "gl_type": "unnorm",
    "k": 28,
    "k_nn": 49,
    "k_nn0": 700,
    "k_tune": 7,
    "lambda1_decay": 0.75,
    "lambda1_init": 8,
    "lambda1_min": 0.001,
    "max_iter": 300,
    "max_sparsity": 0.9,
    "metric": "euclidean",
    "n_proc": 32,
    "p": 0.99,
    "power": 5,
    "pp_n_thresh": 32,
    "radius": 0.5,
    "reg": 0.0,
    "scale_by": "gamma",
    "tau": 50,
    "to_postprocess": true,
    "verbose": true
}
intermed_opts:
{
    "algo": "best",
    "debug": true,
    "eta_max": 25,
    "eta_min": 10,
    "len_S_thresh": 256,
    "local_algo": "LDLE",
    "metric": "euclidean",
    "n_proc": 32,
    "n_times": 4,
    "verbose": true
}
global_opts:
{
    "add_dim": false,
    "align_transform": "rigid",
    "align_w_parent_only": true,
    "alpha": 0.3,
    "beta": {
        "align": null,
        "repel": 1
    },
    "color_tear": true,
    "compute_error": false,
    "debug": true,
    "eps": 1e-08,
    "err_tol": 0.0001,
    "far_off_points_type": "reuse_fixed",
    "init_algo_name": "procrustes",
    "k": 28,
    "max_internal_iter": 100,
    "max_iter": 20,
    "metric": "euclidean",
    "n_proc": 32,
    "n_repel": 0,
    "nu": 3,
    "patience": 5,
    "refine_algo_name": "rgd",
    "repel_by": 0.0,
    "to_tear": true,
    "verbose": true,
    "vis_before_init": false
}
[7]:
buml_obj.fit(X=X)
Computing local views using LDLE
Constructing unnorm graph Laplacian + its eigendecomposition.
Done.
##############################
Time elapsed from last time log: 4.7 seconds
Total time elapsed: 4.7 seconds
##############################
Computing Atilde: Inner Prod of Grad of EigFuncs.
FEM for Atilde.
Atilde: 0 points processed...
Atilde: 2486 points processed...
Atilde: 4972 points processed...
Atilde: 7458 points processed...
Atilde: 9944 points processed...
Atilde: all points processed...
Done.
##############################
Time elapsed from last time log: 1.0 seconds
Total time elapsed: 5.8 seconds
##############################
Computing LDLE.
local_param: all 9946 points processed...
max distortion is 386838.677817
Done.
##############################
Time elapsed from last time log: 1.9 seconds
Total time elapsed: 7.8 seconds
##############################
Posprocessing local parameterizations.
#Param replaced: 9348, max distortion: 10.780787
#Param replaced: 3019, max distortion: 8.960817
#Param replaced: 416, max distortion: 8.950412
#Param replaced: 43, max distortion: 8.950412
#Param replaced: 8, max distortion: 8.950412
#Param replaced: 1, max distortion: 8.950412
#Param replaced: 0, max distortion: 8.950412
Max local distortion after postprocessing: 8.950412001879997
Done.
##############################
Time elapsed from last time log: 6.4 seconds
Total time elapsed: 14.2 seconds
##############################
Max local distortion = 8.950412001879997
Constructing intermediate views.
eta = 2.
#non-empty views with sz < 2 = 9946
#nodes in views with sz < 2 = 9946
Costs computed when eta = 2.
##############################
Time elapsed from last time log: 9.4 seconds
Total time elapsed: 10.1 seconds
##############################
ctr=7627, total_len_S=49190, avg_len_S=6.449
Remaining #nodes in views with sz < 2 = 0
Done with eta = 2.
##############################
Time elapsed from last time log: 148.0 seconds
Total time elapsed: 158.1 seconds
##############################
eta = 3.
#non-empty views with sz < 3 = 554
#nodes in views with sz < 3 = 1108
Costs computed when eta = 3.
##############################
Time elapsed from last time log: 1.8 seconds
Total time elapsed: 159.9 seconds
##############################
ctr=1000, total_len_S=18387, avg_len_S=18.387
Remaining #nodes in views with sz < 3 = 0
Done with eta = 3.
##############################
Time elapsed from last time log: 9.4 seconds
Total time elapsed: 169.3 seconds
##############################
eta = 4.
#non-empty views with sz < 4 = 399
#nodes in views with sz < 4 = 1197
Costs computed when eta = 4.
##############################
Time elapsed from last time log: 1.8 seconds
Total time elapsed: 171.0 seconds
##############################
ctr=1094, total_len_S=29210, avg_len_S=26.700
Remaining #nodes in views with sz < 4 = 0
Done with eta = 4.
##############################
Time elapsed from last time log: 15.5 seconds
Total time elapsed: 186.6 seconds
##############################
eta = 5.
#non-empty views with sz < 5 = 281
#nodes in views with sz < 5 = 1124
Costs computed when eta = 5.
##############################
Time elapsed from last time log: 1.8 seconds
Total time elapsed: 188.4 seconds
##############################
ctr=1038, total_len_S=34223, avg_len_S=32.970
Remaining #nodes in views with sz < 5 = 0
Done with eta = 5.
##############################
Time elapsed from last time log: 17.1 seconds
Total time elapsed: 205.5 seconds
##############################
eta = 6.
#non-empty views with sz < 6 = 219
#nodes in views with sz < 6 = 1095
Costs computed when eta = 6.
##############################
Time elapsed from last time log: 1.6 seconds
Total time elapsed: 207.1 seconds
##############################
ctr=993, total_len_S=37447, avg_len_S=37.711
Remaining #nodes in views with sz < 6 = 0
Done with eta = 6.
##############################
Time elapsed from last time log: 16.9 seconds
Total time elapsed: 224.0 seconds
##############################
eta = 7.
#non-empty views with sz < 7 = 153
#nodes in views with sz < 7 = 918
Costs computed when eta = 7.
##############################
Time elapsed from last time log: 1.6 seconds
Total time elapsed: 225.7 seconds
##############################
ctr=888, total_len_S=37808, avg_len_S=42.577
Remaining #nodes in views with sz < 7 = 0
Done with eta = 7.
##############################
Time elapsed from last time log: 16.6 seconds
Total time elapsed: 242.3 seconds
##############################
eta = 8.
#non-empty views with sz < 8 = 111
#nodes in views with sz < 8 = 777
Costs computed when eta = 8.
##############################
Time elapsed from last time log: 1.6 seconds
Total time elapsed: 243.8 seconds
##############################
ctr=746, total_len_S=35155, avg_len_S=47.125
Remaining #nodes in views with sz < 8 = 0
Done with eta = 8.
##############################
Time elapsed from last time log: 15.4 seconds
Total time elapsed: 259.2 seconds
##############################
eta = 9.
#non-empty views with sz < 9 = 87
#nodes in views with sz < 9 = 696
Costs computed when eta = 9.
##############################
Time elapsed from last time log: 1.6 seconds
Total time elapsed: 260.8 seconds
##############################
ctr=655, total_len_S=34545, avg_len_S=52.740
Remaining #nodes in views with sz < 9 = 0
Done with eta = 9.
##############################
Time elapsed from last time log: 16.6 seconds
Total time elapsed: 277.4 seconds
##############################
eta = 10.
#non-empty views with sz < 10 = 70
#nodes in views with sz < 10 = 630
Costs computed when eta = 10.
##############################
Time elapsed from last time log: 1.7 seconds
Total time elapsed: 279.1 seconds
##############################
ctr=619, total_len_S=35094, avg_len_S=56.695
Remaining #nodes in views with sz < 10 = 0
Done with eta = 10.
##############################
Time elapsed from last time log: 16.8 seconds
Total time elapsed: 295.8 seconds
##############################
Pruning and cleaning up.
Done.
##############################
Time elapsed from last time log: 0.7 seconds
Total time elapsed: 296.5 seconds
##############################
After clustering, max distortion is 12.641841
Using rigid transforms for alignment.
Computing laterations scores for overlaps b/w intermed views
Done
##############################
Time elapsed from last time log: 2.1 seconds
Total time elapsed: 2.1 seconds
##############################
Computing a lateration.
Seq of intermediate views and their predecessors computed.
No. of connected components = 1
Done.
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 2.1 seconds
##############################
Computing initial embedding using: procrustes algorithm
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 2.1 seconds
##############################
Initial alignment of 153 views completed
Initial alignment of 306 views completed
Initial alignment of 459 views completed
Initial alignment of 612 views completed
Embedding initialized.
##############################
Time elapsed from last time log: 0.5 seconds
Total time elapsed: 2.6 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_swissrollwithhole_7_1.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 0
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 6.9 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9946 + 614 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 5.5 seconds
Total time elapsed: 12.3 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_swissrollwithhole_7_3.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 1
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 14.9 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9946 + 614 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 5.6 seconds
Total time elapsed: 20.5 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_swissrollwithhole_7_5.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 2
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 23.3 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9946 + 614 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 5.0 seconds
Total time elapsed: 28.4 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_swissrollwithhole_7_7.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 3
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 31.8 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9946 + 614 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 5.3 seconds
Total time elapsed: 37.1 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_swissrollwithhole_7_9.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 4
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 39.3 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9946 + 614 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 7.3 seconds
Total time elapsed: 46.6 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_swissrollwithhole_7_11.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 5
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 49.1 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9946 + 614 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 6.2 seconds
Total time elapsed: 55.3 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_swissrollwithhole_7_13.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 6
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 57.9 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9946 + 614 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 5.8 seconds
Total time elapsed: 63.7 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_swissrollwithhole_7_15.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 7
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 65.8 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9946 + 614 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 5.1 seconds
Total time elapsed: 70.8 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_swissrollwithhole_7_17.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 8
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 73.1 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9946 + 614 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 5.9 seconds
Total time elapsed: 79.0 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_swissrollwithhole_7_19.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 9
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 81.0 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9946 + 614 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 6.2 seconds
Total time elapsed: 87.2 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_swissrollwithhole_7_21.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 10
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 89.7 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9946 + 614 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 5.9 seconds
Total time elapsed: 95.6 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_swissrollwithhole_7_23.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 11
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 97.3 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9946 + 614 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 5.1 seconds
Total time elapsed: 102.4 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_swissrollwithhole_7_25.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 12
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 104.9 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9946 + 614 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 5.7 seconds
Total time elapsed: 110.6 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_swissrollwithhole_7_27.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 13
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 112.2 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9946 + 614 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 6.1 seconds
Total time elapsed: 118.3 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_swissrollwithhole_7_29.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 14
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 119.7 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9946 + 614 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 5.6 seconds
Total time elapsed: 125.3 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_swissrollwithhole_7_31.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 15
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 127.4 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9946 + 614 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 5.0 seconds
Total time elapsed: 132.4 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_swissrollwithhole_7_33.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 16
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 134.0 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9946 + 614 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 7.6 seconds
Total time elapsed: 141.6 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_swissrollwithhole_7_35.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 17
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 143.0 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9946 + 614 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 5.9 seconds
Total time elapsed: 148.9 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_swissrollwithhole_7_37.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 18
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 150.3 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9946 + 614 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 5.1 seconds
Total time elapsed: 155.4 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_swissrollwithhole_7_39.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 19
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 156.7 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9946 + 614 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 6.8 seconds
Total time elapsed: 163.5 seconds
##############################
Computing error.
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9946 + 614 multiplied with B
Computing svd
Done
Alignment error: 1.839808
##############################
Time elapsed from last time log: 2.3 seconds
Total time elapsed: 165.8 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_swissrollwithhole_7_41.png
[7]:
array([[ 0.28341468, -0.84381896],
       [ 0.28119997, -0.83181118],
       [ 0.28609526, -0.82933836],
       ...,
       [-0.28543265,  0.82432256],
       [-0.28088419,  0.82764191],
       [-0.2782752 ,  0.83311992]])
[8]:
buml_obj.GlobalViews.vis_embedding(buml_obj.GlobalViews.y_final, buml_obj.vis, buml_obj.vis_opts,
                                   buml_obj.GlobalViews.color_of_pts_on_tear_final,
                                   title='Final global embedding', )
../../_images/ldle_nbks_manifolds_with_boundary_swissrollwithhole_8_0.png
[9]:
util_.save(save_dir_root, 'ldle.dat', [X, labelsMat, buml_obj])