Curved Torus

[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/curvedtorus3d/'
[5]:
X, labelsMat, ddX = datasets.Datasets().curvedtorus3d()
X.shape =  (10000, 3)
[6]:
# The supplied options would override the default options
buml_obj = buml_.BUML(local_opts={'algo':'LPCA'},
                  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": "LPCA",
    "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": "LPCA",
    "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 LPCA
local_param: all 10000 points processed...
max distortion is 1.062579
Done.
##############################
Time elapsed from last time log: 0.9 seconds
Total time elapsed: 0.9 seconds
##############################
Posprocessing local parameterizations.
#Param replaced: 5793, max distortion: 1.059517
#Param replaced: 361, max distortion: 1.059517
#Param replaced: 35, max distortion: 1.059517
#Param replaced: 5, max distortion: 1.059517
#Param replaced: 2, max distortion: 1.059517
#Param replaced: 0, max distortion: 1.059517
Max local distortion after postprocessing: 1.0595166372647962
Done.
##############################
Time elapsed from last time log: 3.3 seconds
Total time elapsed: 4.3 seconds
##############################
Max local distortion = 1.0595166372647962
Constructing intermediate views.
eta = 2.
#non-empty views with sz < 2 = 10000
#nodes in views with sz < 2 = 10000
Costs computed when eta = 2.
##############################
Time elapsed from last time log: 10.6 seconds
Total time elapsed: 11.5 seconds
##############################
ctr=6698, total_len_S=24799, avg_len_S=3.702
Remaining #nodes in views with sz < 2 = 0
Done with eta = 2.
##############################
Time elapsed from last time log: 53.5 seconds
Total time elapsed: 65.0 seconds
##############################
eta = 3.
#non-empty views with sz < 3 = 1344
#nodes in views with sz < 3 = 2688
Costs computed when eta = 3.
##############################
Time elapsed from last time log: 1.4 seconds
Total time elapsed: 66.3 seconds
##############################
ctr=2128, total_len_S=36965, avg_len_S=17.371
Remaining #nodes in views with sz < 3 = 0
Done with eta = 3.
##############################
Time elapsed from last time log: 34.7 seconds
Total time elapsed: 101.1 seconds
##############################
eta = 4.
#non-empty views with sz < 4 = 711
#nodes in views with sz < 4 = 2133
Costs computed when eta = 4.
##############################
Time elapsed from last time log: 1.2 seconds
Total time elapsed: 102.3 seconds
##############################
ctr=1774, total_len_S=45108, avg_len_S=25.427
Remaining #nodes in views with sz < 4 = 0
Done with eta = 4.
##############################
Time elapsed from last time log: 33.2 seconds
Total time elapsed: 135.5 seconds
##############################
eta = 5.
#non-empty views with sz < 5 = 401
#nodes in views with sz < 5 = 1604
Costs computed when eta = 5.
##############################
Time elapsed from last time log: 1.0 seconds
Total time elapsed: 136.5 seconds
##############################
ctr=1340, total_len_S=41904, avg_len_S=31.272
Remaining #nodes in views with sz < 5 = 0
Done with eta = 5.
##############################
Time elapsed from last time log: 25.5 seconds
Total time elapsed: 162.1 seconds
##############################
Pruning and cleaning up.
Done.
##############################
Time elapsed from last time log: 0.9 seconds
Total time elapsed: 163.0 seconds
##############################
After clustering, max distortion is 1.107944
Using rigid transforms for alignment.
Computing laterations scores for overlaps b/w intermed views
Done
##############################
Time elapsed from last time log: 0.9 seconds
Total time elapsed: 0.9 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: 0.9 seconds
##############################
Computing initial embedding using: procrustes algorithm
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 0.9 seconds
##############################
Initial alignment of 331 views completed
Initial alignment of 662 views completed
Initial alignment of 993 views completed
Initial alignment of 1324 views completed
Embedding initialized.
##############################
Time elapsed from last time log: 1.3 seconds
Total time elapsed: 2.2 seconds
##############################
../../_images/lpca_nbks_closed_manifolds_curvedtorus3d_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: 11.9 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1327 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.2 seconds
Total time elapsed: 20.1 seconds
##############################
../../_images/lpca_nbks_closed_manifolds_curvedtorus3d_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: 28.4 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1327 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.3 seconds
Total time elapsed: 36.7 seconds
##############################
../../_images/lpca_nbks_closed_manifolds_curvedtorus3d_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: 44.5 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1327 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.2 seconds
Total time elapsed: 52.8 seconds
##############################
../../_images/lpca_nbks_closed_manifolds_curvedtorus3d_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: 60.7 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1327 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.2 seconds
Total time elapsed: 68.9 seconds
##############################
../../_images/lpca_nbks_closed_manifolds_curvedtorus3d_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: 76.8 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1327 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.3 seconds
Total time elapsed: 85.1 seconds
##############################
../../_images/lpca_nbks_closed_manifolds_curvedtorus3d_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: 92.6 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1327 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.2 seconds
Total time elapsed: 100.8 seconds
##############################
../../_images/lpca_nbks_closed_manifolds_curvedtorus3d_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: 108.1 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1327 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.3 seconds
Total time elapsed: 116.4 seconds
##############################
../../_images/lpca_nbks_closed_manifolds_curvedtorus3d_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: 123.6 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1327 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.3 seconds
Total time elapsed: 131.8 seconds
##############################
../../_images/lpca_nbks_closed_manifolds_curvedtorus3d_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: 139.1 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1327 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.3 seconds
Total time elapsed: 147.4 seconds
##############################
../../_images/lpca_nbks_closed_manifolds_curvedtorus3d_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: 154.3 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1327 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.1 seconds
Total time elapsed: 162.4 seconds
##############################
../../_images/lpca_nbks_closed_manifolds_curvedtorus3d_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: 169.4 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1327 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.3 seconds
Total time elapsed: 177.7 seconds
##############################
../../_images/lpca_nbks_closed_manifolds_curvedtorus3d_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: 184.7 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1327 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.3 seconds
Total time elapsed: 193.0 seconds
##############################
../../_images/lpca_nbks_closed_manifolds_curvedtorus3d_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: 199.8 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1327 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.3 seconds
Total time elapsed: 208.2 seconds
##############################
../../_images/lpca_nbks_closed_manifolds_curvedtorus3d_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: 214.8 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1327 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.2 seconds
Total time elapsed: 223.0 seconds
##############################
../../_images/lpca_nbks_closed_manifolds_curvedtorus3d_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: 229.2 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1327 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.2 seconds
Total time elapsed: 237.4 seconds
##############################
../../_images/lpca_nbks_closed_manifolds_curvedtorus3d_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: 243.9 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1327 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.3 seconds
Total time elapsed: 252.1 seconds
##############################
../../_images/lpca_nbks_closed_manifolds_curvedtorus3d_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: 258.6 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1327 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.6 seconds
Total time elapsed: 267.2 seconds
##############################
../../_images/lpca_nbks_closed_manifolds_curvedtorus3d_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: 273.2 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1327 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.5 seconds
Total time elapsed: 281.7 seconds
##############################
../../_images/lpca_nbks_closed_manifolds_curvedtorus3d_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: 287.6 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1327 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.2 seconds
Total time elapsed: 295.8 seconds
##############################
../../_images/lpca_nbks_closed_manifolds_curvedtorus3d_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: 301.9 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1327 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.2 seconds
Total time elapsed: 310.2 seconds
##############################
Computing error.
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1327 multiplied with B
Computing svd
Done
Alignment error: 2.612199
##############################
Time elapsed from last time log: 5.5 seconds
Total time elapsed: 315.7 seconds
##############################
../../_images/lpca_nbks_closed_manifolds_curvedtorus3d_7_41.png
[7]:
array([[-0.22535743,  0.02597387],
       [ 0.06850035,  0.35667053],
       [-0.36589914, -0.08079284],
       ...,
       [ 0.03406304,  0.12632868],
       [ 0.26459306,  0.02235449],
       [ 0.05622306,  0.30684557]])
[8]:
%matplotlib inline
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/lpca_nbks_closed_manifolds_curvedtorus3d_8_0.png
[11]:
util_.save(save_dir_root, 'lpca.dat', [X, labelsMat, buml_obj])
[ ]: