Sphere

[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/sphere/'
[5]:
X, labelsMat, ddX = datasets.Datasets().sphere()
X.shape =  (10000, 3)
[6]:
# The supplied options would override the default options
buml_obj = buml_.BUML(local_opts={'algo':'LPCA'},
                      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": "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.004248
Done.
##############################
Time elapsed from last time log: 1.2 seconds
Total time elapsed: 1.2 seconds
##############################
Posprocessing local parameterizations.
#Param replaced: 0, max distortion: 1.004248
Max local distortion after postprocessing: 1.0042477110911947
Done.
##############################
Time elapsed from last time log: 2.5 seconds
Total time elapsed: 3.7 seconds
##############################
Max local distortion = 1.0042477110911947
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.9 seconds
Total time elapsed: 12.0 seconds
##############################
ctr=5624, total_len_S=16810, avg_len_S=2.989
Remaining #nodes in views with sz < 2 = 0
Done with eta = 2.
##############################
Time elapsed from last time log: 60.6 seconds
Total time elapsed: 72.6 seconds
##############################
eta = 3.
#non-empty views with sz < 3 = 3324
#nodes in views with sz < 3 = 6648
Costs computed when eta = 3.
##############################
Time elapsed from last time log: 4.2 seconds
Total time elapsed: 76.8 seconds
##############################
ctr=3679, total_len_S=63804, avg_len_S=17.343
Remaining #nodes in views with sz < 3 = 0
Done with eta = 3.
##############################
Time elapsed from last time log: 199.2 seconds
Total time elapsed: 276.0 seconds
##############################
eta = 4.
#non-empty views with sz < 4 = 1286
#nodes in views with sz < 4 = 3858
Costs computed when eta = 4.
##############################
Time elapsed from last time log: 2.4 seconds
Total time elapsed: 278.4 seconds
##############################
ctr=2594, total_len_S=65760, avg_len_S=25.351
Remaining #nodes in views with sz < 4 = 0
Done with eta = 4.
##############################
Time elapsed from last time log: 85.2 seconds
Total time elapsed: 363.6 seconds
##############################
eta = 5.
#non-empty views with sz < 5 = 612
#nodes in views with sz < 5 = 2448
Costs computed when eta = 5.
##############################
Time elapsed from last time log: 1.8 seconds
Total time elapsed: 365.4 seconds
##############################
ctr=1918, total_len_S=55970, avg_len_S=29.181
Remaining #nodes in views with sz < 5 = 0
Done with eta = 5.
##############################
Time elapsed from last time log: 44.3 seconds
Total time elapsed: 409.7 seconds
##############################
Pruning and cleaning up.
Done.
##############################
Time elapsed from last time log: 1.2 seconds
Total time elapsed: 410.9 seconds
##############################
After clustering, max distortion is 1.012415
Using rigid transforms for alignment.
Computing laterations scores for overlaps b/w intermed views
Done
##############################
Time elapsed from last time log: 1.3 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 361 views completed
Initial alignment of 722 views completed
Initial alignment of 1083 views completed
Initial alignment of 1444 views completed
Embedding initialized.
##############################
Time elapsed from last time log: 1.6 seconds
Total time elapsed: 2.9 seconds
##############################
../../_images/lpca_nbks_closed_manifolds_sphere_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: 17.4 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1446 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 10.9 seconds
Total time elapsed: 28.3 seconds
##############################
../../_images/lpca_nbks_closed_manifolds_sphere_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: 43.7 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1446 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 20.9 seconds
Total time elapsed: 64.6 seconds
##############################
../../_images/lpca_nbks_closed_manifolds_sphere_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: 74.4 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1446 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 11.4 seconds
Total time elapsed: 85.8 seconds
##############################
../../_images/lpca_nbks_closed_manifolds_sphere_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: 95.4 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1446 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 10.6 seconds
Total time elapsed: 106.0 seconds
##############################
../../_images/lpca_nbks_closed_manifolds_sphere_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: 115.9 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1446 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 11.3 seconds
Total time elapsed: 127.2 seconds
##############################
../../_images/lpca_nbks_closed_manifolds_sphere_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: 137.3 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1446 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 17.1 seconds
Total time elapsed: 154.3 seconds
##############################
../../_images/lpca_nbks_closed_manifolds_sphere_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: 163.1 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1446 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 18.3 seconds
Total time elapsed: 181.3 seconds
##############################
../../_images/lpca_nbks_closed_manifolds_sphere_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: 192.3 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1446 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 17.5 seconds
Total time elapsed: 209.7 seconds
##############################
../../_images/lpca_nbks_closed_manifolds_sphere_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: 219.6 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1446 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 14.1 seconds
Total time elapsed: 233.7 seconds
##############################
../../_images/lpca_nbks_closed_manifolds_sphere_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: 243.9 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1446 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 10.5 seconds
Total time elapsed: 254.4 seconds
##############################
../../_images/lpca_nbks_closed_manifolds_sphere_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: 263.7 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1446 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 11.4 seconds
Total time elapsed: 275.2 seconds
##############################
../../_images/lpca_nbks_closed_manifolds_sphere_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: 283.5 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1446 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 12.4 seconds
Total time elapsed: 296.0 seconds
##############################
../../_images/lpca_nbks_closed_manifolds_sphere_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: 302.8 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1446 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 25.8 seconds
Total time elapsed: 328.7 seconds
##############################
../../_images/lpca_nbks_closed_manifolds_sphere_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: 338.8 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1446 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 17.3 seconds
Total time elapsed: 356.0 seconds
##############################
../../_images/lpca_nbks_closed_manifolds_sphere_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: 364.8 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1446 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 13.1 seconds
Total time elapsed: 378.0 seconds
##############################
../../_images/lpca_nbks_closed_manifolds_sphere_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: 387.6 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1446 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 10.9 seconds
Total time elapsed: 398.5 seconds
##############################
../../_images/lpca_nbks_closed_manifolds_sphere_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: 408.1 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1446 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 16.4 seconds
Total time elapsed: 424.5 seconds
##############################
../../_images/lpca_nbks_closed_manifolds_sphere_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: 433.5 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1446 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 25.1 seconds
Total time elapsed: 458.6 seconds
##############################
../../_images/lpca_nbks_closed_manifolds_sphere_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: 469.5 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1446 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 23.7 seconds
Total time elapsed: 493.2 seconds
##############################
../../_images/lpca_nbks_closed_manifolds_sphere_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: 501.6 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1446 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 19.8 seconds
Total time elapsed: 521.4 seconds
##############################
Computing error.
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1446 multiplied with B
Computing svd
Done
Alignment error: 2.496967
##############################
Time elapsed from last time log: 8.7 seconds
Total time elapsed: 530.1 seconds
##############################
../../_images/lpca_nbks_closed_manifolds_sphere_7_41.png
[7]:
array([[-0.13668623, -0.37035817],
       [-0.14814647, -0.37076796],
       [-0.137852  , -0.36053965],
       ...,
       [ 0.12887644,  0.37633278],
       [ 0.13743101,  0.38798857],
       [ 0.1265057 ,  0.38635904]])
[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_sphere_8_0.png
[9]:
util_.save(save_dir_root, 'lpca.dat', [X, labelsMat, buml_obj])
[ ]: