Sphere 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/spherewithhole/'
[5]:
X, labelsMat, ddX = datasets.Datasets().spherewithhole()
X.shape =  (9931, 3)
[6]:
# The supplied options would override the default options
buml_obj = buml_.BUML(local_opts={'algo':'LDLE'},
                      intermed_opts={'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: 2.7 seconds
Total time elapsed: 2.7 seconds
##############################
Computing Atilde: Inner Prod of Grad of EigFuncs.
FEM for Atilde.
Atilde: 0 points processed...
Atilde: 2482 points processed...
Atilde: 4964 points processed...
Atilde: 7446 points processed...
Atilde: 9928 points processed...
Atilde: all points processed...
Done.
##############################
Time elapsed from last time log: 0.7 seconds
Total time elapsed: 3.4 seconds
##############################
Computing LDLE.
local_param: all 9931 points processed...
max distortion is 218.203338
Done.
##############################
Time elapsed from last time log: 1.6 seconds
Total time elapsed: 5.1 seconds
##############################
Posprocessing local parameterizations.
#Param replaced: 8941, max distortion: 6.012715
#Param replaced: 2559, max distortion: 5.239490
#Param replaced: 630, max distortion: 5.094905
#Param replaced: 374, max distortion: 4.693018
#Param replaced: 312, max distortion: 4.693018
#Param replaced: 228, max distortion: 4.693018
#Param replaced: 183, max distortion: 4.693018
#Param replaced: 218, max distortion: 4.693018
#Param replaced: 322, max distortion: 4.693018
#Param replaced: 221, max distortion: 4.693018
#Param replaced: 165, max distortion: 4.693018
#Param replaced: 101, max distortion: 4.693018
#Param replaced: 62, max distortion: 4.693018
#Param replaced: 40, max distortion: 4.693018
#Param replaced: 23, max distortion: 4.693018
#Param replaced: 16, max distortion: 4.693018
#Param replaced: 2, max distortion: 4.693018
#Param replaced: 0, max distortion: 4.693018
Max local distortion after postprocessing: 4.693018235330209
Done.
##############################
Time elapsed from last time log: 9.9 seconds
Total time elapsed: 15.0 seconds
##############################
Max local distortion = 4.693018235330209
Constructing intermediate views.
eta = 2.
#non-empty views with sz < 2 = 9931
#nodes in views with sz < 2 = 9931
Costs computed when eta = 2.
##############################
Time elapsed from last time log: 9.1 seconds
Total time elapsed: 9.8 seconds
##############################
ctr=8041, total_len_S=63163, avg_len_S=7.855
Remaining #nodes in views with sz < 2 = 0
Done with eta = 2.
##############################
Time elapsed from last time log: 178.5 seconds
Total time elapsed: 188.3 seconds
##############################
eta = 3.
#non-empty views with sz < 3 = 336
#nodes in views with sz < 3 = 672
Costs computed when eta = 3.
##############################
Time elapsed from last time log: 1.6 seconds
Total time elapsed: 189.9 seconds
##############################
ctr=597, total_len_S=11407, avg_len_S=19.107
Remaining #nodes in views with sz < 3 = 0
Done with eta = 3.
##############################
Time elapsed from last time log: 4.2 seconds
Total time elapsed: 194.1 seconds
##############################
eta = 4.
#non-empty views with sz < 4 = 307
#nodes in views with sz < 4 = 921
Costs computed when eta = 4.
##############################
Time elapsed from last time log: 1.6 seconds
Total time elapsed: 195.7 seconds
##############################
ctr=844, total_len_S=22970, avg_len_S=27.216
Remaining #nodes in views with sz < 4 = 0
Done with eta = 4.
##############################
Time elapsed from last time log: 11.1 seconds
Total time elapsed: 206.8 seconds
##############################
eta = 5.
#non-empty views with sz < 5 = 232
#nodes in views with sz < 5 = 928
Costs computed when eta = 5.
##############################
Time elapsed from last time log: 1.6 seconds
Total time elapsed: 208.4 seconds
##############################
ctr=859, total_len_S=28743, avg_len_S=33.461
Remaining #nodes in views with sz < 5 = 0
Done with eta = 5.
##############################
Time elapsed from last time log: 14.8 seconds
Total time elapsed: 223.2 seconds
##############################
eta = 6.
#non-empty views with sz < 6 = 185
#nodes in views with sz < 6 = 925
Costs computed when eta = 6.
##############################
Time elapsed from last time log: 1.6 seconds
Total time elapsed: 224.8 seconds
##############################
ctr=876, total_len_S=34314, avg_len_S=39.171
Remaining #nodes in views with sz < 6 = 0
Done with eta = 6.
##############################
Time elapsed from last time log: 18.4 seconds
Total time elapsed: 243.2 seconds
##############################
eta = 7.
#non-empty views with sz < 7 = 112
#nodes in views with sz < 7 = 672
Costs computed when eta = 7.
##############################
Time elapsed from last time log: 1.5 seconds
Total time elapsed: 244.8 seconds
##############################
ctr=620, total_len_S=27031, avg_len_S=43.598
Remaining #nodes in views with sz < 7 = 0
Done with eta = 7.
##############################
Time elapsed from last time log: 12.7 seconds
Total time elapsed: 257.4 seconds
##############################
eta = 8.
#non-empty views with sz < 8 = 106
#nodes in views with sz < 8 = 742
Costs computed when eta = 8.
##############################
Time elapsed from last time log: 1.6 seconds
Total time elapsed: 259.1 seconds
##############################
ctr=706, total_len_S=33321, avg_len_S=47.197
Remaining #nodes in views with sz < 8 = 0
Done with eta = 8.
##############################
Time elapsed from last time log: 14.3 seconds
Total time elapsed: 273.4 seconds
##############################
eta = 9.
#non-empty views with sz < 9 = 75
#nodes in views with sz < 9 = 600
Costs computed when eta = 9.
##############################
Time elapsed from last time log: 1.6 seconds
Total time elapsed: 274.9 seconds
##############################
ctr=565, total_len_S=29964, avg_len_S=53.034
Remaining #nodes in views with sz < 9 = 0
Done with eta = 9.
##############################
Time elapsed from last time log: 12.1 seconds
Total time elapsed: 287.0 seconds
##############################
eta = 10.
#non-empty views with sz < 10 = 56
#nodes in views with sz < 10 = 504
Costs computed when eta = 10.
##############################
Time elapsed from last time log: 1.5 seconds
Total time elapsed: 288.5 seconds
##############################
ctr=478, total_len_S=28368, avg_len_S=59.347
Remaining #nodes in views with sz < 10 = 0
Done with eta = 10.
##############################
Time elapsed from last time log: 12.6 seconds
Total time elapsed: 301.2 seconds
##############################
Pruning and cleaning up.
Done.
##############################
Time elapsed from last time log: 0.5 seconds
Total time elapsed: 301.7 seconds
##############################
After clustering, max distortion is 8.014977
Using rigid transforms for alignment.
Computing laterations scores for overlaps b/w intermed views
Done
##############################
Time elapsed from last time log: 1.4 seconds
Total time elapsed: 1.4 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: 1.4 seconds
##############################
Computing initial embedding using: procrustes algorithm
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 1.4 seconds
##############################
Initial alignment of 154 views completed
Initial alignment of 308 views completed
Initial alignment of 462 views completed
Embedding initialized.
##############################
Time elapsed from last time log: 0.6 seconds
Total time elapsed: 2.0 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_spherewithhole_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: 8.0 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9931 + 616 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 4.6 seconds
Total time elapsed: 12.5 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_spherewithhole_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: 17.1 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9931 + 616 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 4.5 seconds
Total time elapsed: 21.7 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_spherewithhole_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: 25.9 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9931 + 616 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 4.4 seconds
Total time elapsed: 30.3 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_spherewithhole_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: 34.5 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9931 + 616 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 4.4 seconds
Total time elapsed: 38.9 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_spherewithhole_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: 42.7 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9931 + 616 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 4.5 seconds
Total time elapsed: 47.2 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_spherewithhole_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: 50.9 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9931 + 616 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 4.6 seconds
Total time elapsed: 55.4 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_spherewithhole_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: 59.0 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9931 + 616 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 4.4 seconds
Total time elapsed: 63.4 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_spherewithhole_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: 67.3 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9931 + 616 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 4.6 seconds
Total time elapsed: 71.9 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_spherewithhole_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: 75.3 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9931 + 616 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 4.7 seconds
Total time elapsed: 80.0 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_spherewithhole_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: 83.7 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9931 + 616 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 4.6 seconds
Total time elapsed: 88.3 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_spherewithhole_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: 92.4 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9931 + 616 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 11.9 seconds
Total time elapsed: 104.4 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_spherewithhole_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: 108.3 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9931 + 616 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.9 seconds
Total time elapsed: 117.2 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_spherewithhole_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: 124.1 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9931 + 616 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 5.3 seconds
Total time elapsed: 129.3 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_spherewithhole_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: 134.0 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9931 + 616 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 5.3 seconds
Total time elapsed: 139.3 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_spherewithhole_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: 143.4 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9931 + 616 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 7.1 seconds
Total time elapsed: 150.5 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_spherewithhole_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: 153.9 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9931 + 616 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 4.5 seconds
Total time elapsed: 158.4 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_spherewithhole_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: 161.3 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9931 + 616 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 4.5 seconds
Total time elapsed: 165.9 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_spherewithhole_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: 168.8 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9931 + 616 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 4.5 seconds
Total time elapsed: 173.4 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_spherewithhole_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: 176.7 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9931 + 616 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 4.6 seconds
Total time elapsed: 181.4 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_spherewithhole_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: 184.5 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9931 + 616 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 4.5 seconds
Total time elapsed: 189.1 seconds
##############################
Computing error.
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 9931 + 616 multiplied with B
Computing svd
Done
Alignment error: 8.035958
##############################
Time elapsed from last time log: 2.0 seconds
Total time elapsed: 191.1 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_spherewithhole_7_41.png
[7]:
array([[-0.61100786,  0.20045767],
       [-0.51397177,  0.2050517 ],
       [ 0.33749182,  0.32631811],
       ...,
       [ 0.0115148 , -0.10344648],
       [ 0.00643199, -0.09017631],
       [ 0.01479655, -0.09589217]])
[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_spherewithhole_8_0.png
[9]:
util_.save(save_dir_root, 'ldle.dat', [X, labelsMat, buml_obj])
[ ]: