Klein Bottle

[1]:
%matplotlib inline
[2]:
# Not really required
import sys
sys.path.insert(0, '../../..')
[3]:
from pyLDLE2 import datasets
from pyLDLE2 import buml_
from pyLDLE2 import util_
matplotlib.get_backend() =  module://matplotlib_inline.backend_inline
[4]:
save_dir_root = '../data/pyLDLE2/kleinbottle4d/'
[5]:
X, labelsMat, ddX = datasets.Datasets().kleinbottle4d()
X.shape =  (10000, 4)
[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
Constructing local views using LPCA
local_param: all 10000 points processed...
max distortion is 1.056582
Done.
##############################
Time elapsed from last time log: 0.9 seconds
Total time elapsed: 0.9 seconds
##############################
Posprocessing local parameterizations.
#Param replaced: 349, max distortion: 1.056582
#Param replaced: 0, max distortion: 1.056582
Max local distortion after postprocessing: 1.0565815811361594
Done.
##############################
Time elapsed from last time log: 2.1 seconds
Total time elapsed: 3.0 seconds
##############################
Max local distortion = 1.0565815811361594
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: 9.5 seconds
Total time elapsed: 10.2 seconds
##############################
ctr=5675, total_len_S=15660, avg_len_S=2.759
Remaining #nodes in views with sz < 2 = 0
Done with eta = 2.
##############################
Time elapsed from last time log: 25.8 seconds
Total time elapsed: 36.0 seconds
##############################
eta = 3.
#non-empty views with sz < 3 = 3078
#nodes in views with sz < 3 = 6156
Costs computed when eta = 3.
##############################
Time elapsed from last time log: 2.8 seconds
Total time elapsed: 38.9 seconds
##############################
ctr=3408, total_len_S=57941, avg_len_S=17.001
Remaining #nodes in views with sz < 3 = 0
Done with eta = 3.
##############################
Time elapsed from last time log: 106.8 seconds
Total time elapsed: 145.6 seconds
##############################
eta = 4.
#non-empty views with sz < 4 = 1114
#nodes in views with sz < 4 = 3342
Costs computed when eta = 4.
##############################
Time elapsed from last time log: 1.7 seconds
Total time elapsed: 147.3 seconds
##############################
ctr=2131, total_len_S=52837, avg_len_S=24.794
Remaining #nodes in views with sz < 4 = 0
Done with eta = 4.
##############################
Time elapsed from last time log: 56.0 seconds
Total time elapsed: 203.4 seconds
##############################
eta = 5.
#non-empty views with sz < 5 = 629
#nodes in views with sz < 5 = 2516
Costs computed when eta = 5.
##############################
Time elapsed from last time log: 1.4 seconds
Total time elapsed: 204.7 seconds
##############################
ctr=1652, total_len_S=50994, avg_len_S=30.868
Remaining #nodes in views with sz < 5 = 0
Done with eta = 5.
##############################
Time elapsed from last time log: 45.9 seconds
Total time elapsed: 250.6 seconds
##############################
Pruning and cleaning up.
Done.
##############################
Time elapsed from last time log: 0.9 seconds
Total time elapsed: 251.5 seconds
##############################
After clustering, max distortion is 1.061879
Using rigid transforms for alignment.
Computing laterations scores for overlaps b/w intermed views
Done
##############################
Time elapsed from last time log: 1.0 seconds
Total time elapsed: 1.0 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.0 seconds
##############################
Computing initial embedding using: procrustes algorithm
##############################
Time elapsed from last time log: 0.0 seconds
Total time elapsed: 1.0 seconds
##############################
Initial alignment of 389 views completed
Initial alignment of 778 views completed
Initial alignment of 1167 views completed
Embedding initialized.
##############################
Time elapsed from last time log: 1.3 seconds
Total time elapsed: 2.3 seconds
##############################
../../_images/lpca_nbks_non_orientable_manifolds_kleinbottle4d_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: 16.1 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1556 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 12.2 seconds
Total time elapsed: 28.3 seconds
##############################
../../_images/lpca_nbks_non_orientable_manifolds_kleinbottle4d_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: 39.5 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1556 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 9.3 seconds
Total time elapsed: 48.8 seconds
##############################
../../_images/lpca_nbks_non_orientable_manifolds_kleinbottle4d_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: 59.7 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1556 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 10.0 seconds
Total time elapsed: 69.8 seconds
##############################
../../_images/lpca_nbks_non_orientable_manifolds_kleinbottle4d_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: 80.5 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1556 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 11.6 seconds
Total time elapsed: 92.1 seconds
##############################
../../_images/lpca_nbks_non_orientable_manifolds_kleinbottle4d_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: 102.4 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1556 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 9.4 seconds
Total time elapsed: 111.8 seconds
##############################
../../_images/lpca_nbks_non_orientable_manifolds_kleinbottle4d_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: 122.5 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1556 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 10.5 seconds
Total time elapsed: 133.0 seconds
##############################
../../_images/lpca_nbks_non_orientable_manifolds_kleinbottle4d_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: 142.7 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1556 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 12.1 seconds
Total time elapsed: 154.9 seconds
##############################
../../_images/lpca_nbks_non_orientable_manifolds_kleinbottle4d_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: 164.9 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1556 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 9.4 seconds
Total time elapsed: 174.3 seconds
##############################
../../_images/lpca_nbks_non_orientable_manifolds_kleinbottle4d_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: 184.2 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1556 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 9.0 seconds
Total time elapsed: 193.1 seconds
##############################
../../_images/lpca_nbks_non_orientable_manifolds_kleinbottle4d_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: 202.1 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1556 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 9.0 seconds
Total time elapsed: 211.1 seconds
##############################
../../_images/lpca_nbks_non_orientable_manifolds_kleinbottle4d_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: 220.7 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1556 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 9.2 seconds
Total time elapsed: 229.8 seconds
##############################
../../_images/lpca_nbks_non_orientable_manifolds_kleinbottle4d_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: 238.9 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1556 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 9.0 seconds
Total time elapsed: 247.9 seconds
##############################
../../_images/lpca_nbks_non_orientable_manifolds_kleinbottle4d_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: 256.9 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1556 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.8 seconds
Total time elapsed: 265.7 seconds
##############################
../../_images/lpca_nbks_non_orientable_manifolds_kleinbottle4d_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: 274.9 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1556 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 9.2 seconds
Total time elapsed: 284.1 seconds
##############################
../../_images/lpca_nbks_non_orientable_manifolds_kleinbottle4d_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: 293.1 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1556 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.9 seconds
Total time elapsed: 302.0 seconds
##############################
../../_images/lpca_nbks_non_orientable_manifolds_kleinbottle4d_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: 311.2 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1556 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 8.9 seconds
Total time elapsed: 320.0 seconds
##############################
../../_images/lpca_nbks_non_orientable_manifolds_kleinbottle4d_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: 328.7 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1556 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 9.0 seconds
Total time elapsed: 337.8 seconds
##############################
../../_images/lpca_nbks_non_orientable_manifolds_kleinbottle4d_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: 347.5 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1556 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 9.1 seconds
Total time elapsed: 356.7 seconds
##############################
../../_images/lpca_nbks_non_orientable_manifolds_kleinbottle4d_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: 365.7 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1556 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 9.0 seconds
Total time elapsed: 374.6 seconds
##############################
../../_images/lpca_nbks_non_orientable_manifolds_kleinbottle4d_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: 383.5 seconds
##############################
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1556 multiplied with B
Computing svd
Done
Descent starts
Done.
##############################
Time elapsed from last time log: 9.0 seconds
Total time elapsed: 392.5 seconds
##############################
Computing error.
min and max weights: 1.0 1.0
Computing Pseudoinverse of a matrix of L of size 10000 + 1556 multiplied with B
Computing svd
Done
Alignment error: 1.520509
##############################
Time elapsed from last time log: 5.7 seconds
Total time elapsed: 398.1 seconds
##############################
../../_images/lpca_nbks_non_orientable_manifolds_kleinbottle4d_7_41.png
[7]:
array([[ 0.21161009, -0.47270385],
       [ 0.20363109, -0.47777038],
       [ 0.19686546, -0.48409761],
       ...,
       [ 0.19508274, -0.49839741],
       [ 0.20291344, -0.49299073],
       [ 0.20999865, -0.48656919]])
[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/lpca_nbks_non_orientable_manifolds_kleinbottle4d_8_0.png
[10]:
util_.save(save_dir_root, 'lpca.dat', [X, labelsMat, buml_obj])