Doubled 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/doubled_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':5},
                      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": 5,
    "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, ddX=ddX)
Doubling manifold.
No. of points on the boundary = 528
/home/dhruv/anaconda3/lib/python3.9/site-packages/sklearn/neighbors/_base.py:234: EfficiencyWarning: Precomputed sparse input was not sorted by row values. Use the function sklearn.neighbors.sort_graph_by_row_values to sort the input by row values, with warn_when_not_sorted=False to remove this warning.
  warnings.warn(
Done.
##############################
Time elapsed from last time log: 47.8 seconds
Total time elapsed: 47.8 seconds
##############################
Computing local views using LDLE
Constructing unnorm graph Laplacian + its eigendecomposition.
Done.
##############################
Time elapsed from last time log: 6.6 seconds
Total time elapsed: 6.6 seconds
##############################
Computing Atilde: Inner Prod of Grad of EigFuncs.
FEM for Atilde.
Atilde: 0 points processed...
Atilde: 4841 points processed...
Atilde: 9682 points processed...
Atilde: 14523 points processed...
Atilde: all points processed...
Done.
##############################
Time elapsed from last time log: 1.2 seconds
Total time elapsed: 7.8 seconds
##############################
Computing LDLE.
local_param: all 19364 points processed...
max distortion is 13458.909916
Done.
##############################
Time elapsed from last time log: 2.3 seconds
Total time elapsed: 10.2 seconds
##############################
Posprocessing local parameterizations.
#Param replaced: 18161, max distortion: 8.372852
#Param replaced: 9107, max distortion: 8.372852
#Param replaced: 3503, max distortion: 8.372852
#Param replaced: 1435, max distortion: 8.372852
#Param replaced: 368, max distortion: 8.372852
#Param replaced: 66, max distortion: 8.372852
#Param replaced: 17, max distortion: 8.372852
#Param replaced: 4, max distortion: 8.372852
#Param replaced: 1, max distortion: 8.372852
#Param replaced: 0, max distortion: 8.372852
Max local distortion after postprocessing: 8.372851838757377
Done.
##############################
Time elapsed from last time log: 13.2 seconds
Total time elapsed: 23.4 seconds
##############################
Halving objects.
Done.
##############################
Time elapsed from last time log: 9.1 seconds
Total time elapsed: 34.7 seconds
##############################
Max local distortion = 8.320212700489922
Constructing intermediate views.
eta = 2.
#non-empty views with sz < 2 = 9946
#nodes in views with sz < 2 = 9946
/home/dhruv/codebase/pyLDLE2/docs/ldle_nbks/doubled_manifolds/../../../pyLDLE2/intermed_views_.py:122: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray.
  neigh_ind = np.array(neigh_ind)
Costs computed when eta = 2.
##############################
Time elapsed from last time log: 6.4 seconds
Total time elapsed: 7.2 seconds
##############################
ctr=7824, total_len_S=59993, avg_len_S=7.668
Remaining #nodes in views with sz < 2 = 0
Done with eta = 2.
##############################
Time elapsed from last time log: 284.2 seconds
Total time elapsed: 291.4 seconds
##############################
eta = 3.
#non-empty views with sz < 3 = 448
#nodes in views with sz < 3 = 896
Costs computed when eta = 3.
##############################
Time elapsed from last time log: 2.2 seconds
Total time elapsed: 293.6 seconds
##############################
ctr=795, total_len_S=14396, avg_len_S=18.108
Remaining #nodes in views with sz < 3 = 0
Done with eta = 3.
##############################
Time elapsed from last time log: 9.2 seconds
Total time elapsed: 302.8 seconds
##############################
eta = 4.
#non-empty views with sz < 4 = 360
#nodes in views with sz < 4 = 1080
Costs computed when eta = 4.
##############################
Time elapsed from last time log: 2.4 seconds
Total time elapsed: 305.3 seconds
##############################
ctr=990, total_len_S=27022, avg_len_S=27.295
Remaining #nodes in views with sz < 4 = 0
Done with eta = 4.
##############################
Time elapsed from last time log: 18.2 seconds
Total time elapsed: 323.4 seconds
##############################
eta = 5.
#non-empty views with sz < 5 = 287
#nodes in views with sz < 5 = 1148
Costs computed when eta = 5.
##############################
Time elapsed from last time log: 2.3 seconds
Total time elapsed: 325.7 seconds
##############################
ctr=1069, total_len_S=35627, avg_len_S=33.327
Remaining #nodes in views with sz < 5 = 0
Done with eta = 5.
##############################
Time elapsed from last time log: 22.3 seconds
Total time elapsed: 348.0 seconds
##############################
Pruning and cleaning up.
Done.
##############################
Time elapsed from last time log: 1.0 seconds
Total time elapsed: 349.0 seconds
##############################
After clustering, max distortion is 8.284210
Using rigid transforms for alignment.
Computing laterations scores for overlaps b/w intermed views
Done
##############################
Time elapsed from last time log: 2.8 seconds
Total time elapsed: 2.8 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.8 seconds
##############################
Computing initial embedding using: procrustes algorithm
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 2.8 seconds
##############################
Initial alignment of 287 views completed
Initial alignment of 574 views completed
Initial alignment of 861 views completed
Initial alignment of 1148 views completed
Embedding initialized.
##############################
Time elapsed from last time log: 1.0 seconds
Total time elapsed: 3.8 seconds
##############################
../../_images/ldle_nbks_doubled_manifolds_doubled_swissrollwithhole_7_5.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 0
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 7.6 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9946 + 1149 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 15.3 seconds
Total time elapsed: 22.9 seconds
##############################
../../_images/ldle_nbks_doubled_manifolds_doubled_swissrollwithhole_7_7.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 1
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 25.0 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9946 + 1149 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 11.8 seconds
Total time elapsed: 36.8 seconds
##############################
../../_images/ldle_nbks_doubled_manifolds_doubled_swissrollwithhole_7_9.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 2
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 39.2 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9946 + 1149 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 9.1 seconds
Total time elapsed: 48.3 seconds
##############################
../../_images/ldle_nbks_doubled_manifolds_doubled_swissrollwithhole_7_11.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 3
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 50.6 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9946 + 1149 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 9.5 seconds
Total time elapsed: 60.1 seconds
##############################
../../_images/ldle_nbks_doubled_manifolds_doubled_swissrollwithhole_7_13.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 4
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 61.8 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9946 + 1149 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 10.9 seconds
Total time elapsed: 72.8 seconds
##############################
../../_images/ldle_nbks_doubled_manifolds_doubled_swissrollwithhole_7_15.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 5
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 74.2 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9946 + 1149 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 10.0 seconds
Total time elapsed: 84.2 seconds
##############################
../../_images/ldle_nbks_doubled_manifolds_doubled_swissrollwithhole_7_17.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 6
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 85.5 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9946 + 1149 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 9.5 seconds
Total time elapsed: 95.0 seconds
##############################
../../_images/ldle_nbks_doubled_manifolds_doubled_swissrollwithhole_7_19.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 7
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 96.6 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9946 + 1149 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 9.8 seconds
Total time elapsed: 106.4 seconds
##############################
../../_images/ldle_nbks_doubled_manifolds_doubled_swissrollwithhole_7_21.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 8
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 108.0 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9946 + 1149 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 9.6 seconds
Total time elapsed: 117.5 seconds
##############################
../../_images/ldle_nbks_doubled_manifolds_doubled_swissrollwithhole_7_23.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 9
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 119.4 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9946 + 1149 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 9.7 seconds
Total time elapsed: 129.1 seconds
##############################
../../_images/ldle_nbks_doubled_manifolds_doubled_swissrollwithhole_7_25.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 10
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 130.9 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9946 + 1149 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 10.2 seconds
Total time elapsed: 141.1 seconds
##############################
../../_images/ldle_nbks_doubled_manifolds_doubled_swissrollwithhole_7_27.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 11
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 142.7 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9946 + 1149 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 9.6 seconds
Total time elapsed: 152.3 seconds
##############################
../../_images/ldle_nbks_doubled_manifolds_doubled_swissrollwithhole_7_29.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 12
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 154.2 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9946 + 1149 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 10.3 seconds
Total time elapsed: 164.4 seconds
##############################
../../_images/ldle_nbks_doubled_manifolds_doubled_swissrollwithhole_7_31.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 13
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 166.1 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9946 + 1149 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 10.4 seconds
Total time elapsed: 176.5 seconds
##############################
../../_images/ldle_nbks_doubled_manifolds_doubled_swissrollwithhole_7_33.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 14
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 178.3 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9946 + 1149 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 10.6 seconds
Total time elapsed: 188.8 seconds
##############################
../../_images/ldle_nbks_doubled_manifolds_doubled_swissrollwithhole_7_35.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 15
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 190.5 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9946 + 1149 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 10.9 seconds
Total time elapsed: 201.5 seconds
##############################
../../_images/ldle_nbks_doubled_manifolds_doubled_swissrollwithhole_7_37.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 16
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 203.3 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9946 + 1149 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 20.4 seconds
Total time elapsed: 223.7 seconds
##############################
../../_images/ldle_nbks_doubled_manifolds_doubled_swissrollwithhole_7_39.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 17
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 225.2 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9946 + 1149 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 15.6 seconds
Total time elapsed: 240.8 seconds
##############################
../../_images/ldle_nbks_doubled_manifolds_doubled_swissrollwithhole_7_41.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 18
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 243.5 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9946 + 1149 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 10.1 seconds
Total time elapsed: 253.6 seconds
##############################
../../_images/ldle_nbks_doubled_manifolds_doubled_swissrollwithhole_7_43.png
Refining with rgd algorithm for 100 iterations.
Refinement iteration: 19
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 255.3 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9946 + 1149 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 12.5 seconds
Total time elapsed: 267.8 seconds
##############################
Computing error.
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9946 + 1149 multiplied with B
Computing svd
Done
Alignment error: 0.516574
##############################
Time elapsed from last time log: 4.9 seconds
Total time elapsed: 272.7 seconds
##############################
../../_images/ldle_nbks_doubled_manifolds_doubled_swissrollwithhole_7_45.png
[7]:
array([[ 0.91911517,  0.01441589],
       [ 0.91970346,  0.01962448],
       [ 0.91939358,  0.02597837],
       ...,
       [-0.91806795, -0.06658604],
       [-0.91769423, -0.0629288 ],
       [-0.91895634, -0.05925789]])
[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_doubled_manifolds_doubled_swissrollwithhole_8_0.png
[9]:
util_.save(save_dir_root, 'ldle.dat', [X, labelsMat, buml_obj])