Rectangle

[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/rectangle/'
[5]:
X, labelsMat, ddX = datasets.Datasets().rectanglegrid()
X.shape =  (10426, 2)
[6]:
# The supplied options would override the default options
buml_obj = buml_.BUML(local_opts={'algo':'LDLE'},
                      intermed_opts={'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)
Computing local views using LDLE
Constructing unnorm graph Laplacian + its eigendecomposition.
Done.
##############################
Time elapsed from last time log: 2.5 seconds
Total time elapsed: 2.5 seconds
##############################
Computing Atilde: Inner Prod of Grad of EigFuncs.
FEM for Atilde.
Atilde: 0 points processed...
Atilde: 2606 points processed...
Atilde: 5212 points processed...
Atilde: 7818 points processed...
Atilde: 10424 points processed...
Atilde: all points processed...
Done.
##############################
Time elapsed from last time log: 1.4 seconds
Total time elapsed: 3.9 seconds
##############################
Computing LDLE.
local_param: all 10426 points processed...
max distortion is 82196.230584
Done.
##############################
Time elapsed from last time log: 1.6 seconds
Total time elapsed: 5.5 seconds
##############################
Posprocessing local parameterizations.
#Param replaced: 10068, max distortion: 18.295574
#Param replaced: 6027, max distortion: 12.293169
#Param replaced: 2119, max distortion: 10.242281
#Param replaced: 475, max distortion: 10.242281
#Param replaced: 77, max distortion: 10.241642
#Param replaced: 10, max distortion: 10.241642
#Param replaced: 0, max distortion: 10.241642
Max local distortion after postprocessing: 10.241641910406395
Done.
##############################
Time elapsed from last time log: 9.1 seconds
Total time elapsed: 14.6 seconds
##############################
Max local distortion = 10.241641910406395
Constructing intermediate views.
eta = 2.
#non-empty views with sz < 2 = 10426
#nodes in views with sz < 2 = 10426
Costs computed when eta = 2.
##############################
Time elapsed from last time log: 9.3 seconds
Total time elapsed: 10.0 seconds
##############################
ctr=8036, total_len_S=60527, avg_len_S=7.532
Remaining #nodes in views with sz < 2 = 0
Done with eta = 2.
##############################
Time elapsed from last time log: 188.4 seconds
Total time elapsed: 198.4 seconds
##############################
eta = 3.
#non-empty views with sz < 3 = 689
#nodes in views with sz < 3 = 1378
Costs computed when eta = 3.
##############################
Time elapsed from last time log: 1.7 seconds
Total time elapsed: 200.1 seconds
##############################
ctr=1176, total_len_S=22659, avg_len_S=19.268
Remaining #nodes in views with sz < 3 = 0
Done with eta = 3.
##############################
Time elapsed from last time log: 13.2 seconds
Total time elapsed: 213.4 seconds
##############################
eta = 4.
#non-empty views with sz < 4 = 426
#nodes in views with sz < 4 = 1278
Costs computed when eta = 4.
##############################
Time elapsed from last time log: 1.7 seconds
Total time elapsed: 215.0 seconds
##############################
ctr=1115, total_len_S=30721, avg_len_S=27.552
Remaining #nodes in views with sz < 4 = 0
Done with eta = 4.
##############################
Time elapsed from last time log: 20.2 seconds
Total time elapsed: 235.2 seconds
##############################
eta = 5.
#non-empty views with sz < 5 = 314
#nodes in views with sz < 5 = 1256
Costs computed when eta = 5.
##############################
Time elapsed from last time log: 1.6 seconds
Total time elapsed: 236.9 seconds
##############################
ctr=1090, total_len_S=37207, avg_len_S=34.135
Remaining #nodes in views with sz < 5 = 0
Done with eta = 5.
##############################
Time elapsed from last time log: 22.3 seconds
Total time elapsed: 259.1 seconds
##############################
Pruning and cleaning up.
Done.
##############################
Time elapsed from last time log: 1.0 seconds
Total time elapsed: 260.2 seconds
##############################
After clustering, max distortion is 10.986591
Using rigid transforms for alignment.
Computing laterations scores for overlaps b/w intermed views
Done
##############################
Time elapsed from last time log: 1.7 seconds
Total time elapsed: 1.7 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.8 seconds
##############################
Computing initial embedding using: procrustes algorithm
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 1.8 seconds
##############################
Initial alignment of 293 views completed
Initial alignment of 586 views completed
Initial alignment of 879 views completed
Embedding initialized.
##############################
Time elapsed from last time log: 0.9 seconds
Total time elapsed: 2.6 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_rectangle_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: 7.1 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10426 + 1172 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 7.7 seconds
Total time elapsed: 14.8 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_rectangle_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: 18.0 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10426 + 1172 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.2 seconds
Total time elapsed: 26.1 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_rectangle_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: 29.0 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10426 + 1172 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.4 seconds
Total time elapsed: 37.4 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_rectangle_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: 39.7 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10426 + 1172 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 7.6 seconds
Total time elapsed: 47.2 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_rectangle_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: 49.5 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10426 + 1172 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.1 seconds
Total time elapsed: 57.6 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_rectangle_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: 59.8 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10426 + 1172 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.2 seconds
Total time elapsed: 68.0 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_rectangle_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: 70.0 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10426 + 1172 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.2 seconds
Total time elapsed: 78.2 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_rectangle_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: 80.2 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10426 + 1172 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 9.1 seconds
Total time elapsed: 89.3 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_rectangle_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: 90.8 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10426 + 1172 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.7 seconds
Total time elapsed: 99.6 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_rectangle_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: 101.6 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10426 + 1172 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.9 seconds
Total time elapsed: 110.5 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_rectangle_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: 112.1 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10426 + 1172 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 9.3 seconds
Total time elapsed: 121.4 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_rectangle_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: 122.7 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10426 + 1172 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.7 seconds
Total time elapsed: 131.5 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_rectangle_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: 133.4 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10426 + 1172 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 9.0 seconds
Total time elapsed: 142.4 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_rectangle_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: 143.8 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10426 + 1172 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 9.0 seconds
Total time elapsed: 152.7 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_rectangle_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: 154.4 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10426 + 1172 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.9 seconds
Total time elapsed: 163.2 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_rectangle_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: 164.7 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10426 + 1172 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.5 seconds
Total time elapsed: 173.2 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_rectangle_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: 174.8 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10426 + 1172 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 10.3 seconds
Total time elapsed: 185.1 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_rectangle_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: 187.1 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10426 + 1172 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.3 seconds
Total time elapsed: 195.5 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_rectangle_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: 197.2 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10426 + 1172 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 9.4 seconds
Total time elapsed: 206.7 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_rectangle_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: 208.2 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10426 + 1172 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 7.8 seconds
Total time elapsed: 216.0 seconds
##############################
Computing error.
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10426 + 1172 multiplied with B
Computing svd
Done
Alignment error: 4.450484
##############################
Time elapsed from last time log: 4.2 seconds
Total time elapsed: 220.2 seconds
##############################
../../_images/ldle_nbks_manifolds_with_boundary_rectangle_7_41.png
[7]:
array([[-1.12989155, -0.88045514],
       [-1.13706737, -0.88244556],
       [-1.14459253, -0.88586038],
       ...,
       [ 1.83097139,  0.00573058],
       [ 1.83119032,  0.01293303],
       [ 1.83146612,  0.01885548]])
[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_rectangle_8_0.png
[9]:
util_.save(save_dir_root, 'ldle.dat', [X, labelsMat, buml_obj])