Benchmarks for manifold

Isomap-dense-minimadelon

Benchmark setup

from sklearn.manifold import Isomap
from deps import load_data

kwargs = {'eigen_solver': 'dense'}
X, y, X_t, y_t = load_data('minimadelon')
obj = Isomap(**kwargs)

Benchmark statement

obj.fit(X)

Execution time

_images/Isomap-dense-minimadelon-step0-timing.png

Memory usage

_images/Isomap-dense-minimadelon-step0-memory.png

Additional output

cProfile

         314 function calls in 0.006 seconds

Ordered by: cumulative time

ncalls  tottime  percall  cumtime  percall filename:lineno(function)
     1    0.000    0.000    0.006    0.006 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/vbench/benchmark.py:286(f)
     1    0.000    0.000    0.006    0.006 <f>:1(<module>)
     1    0.000    0.000    0.006    0.006 /tmp/vb_sklearn/sklearn/manifold/isomap.py:147(fit)
     1    0.000    0.000    0.006    0.006 /tmp/vb_sklearn/sklearn/manifold/isomap.py:98(_fit_transform)
     1    0.000    0.000    0.002    0.002 /tmp/vb_sklearn/sklearn/neighbors/graph.py:11(kneighbors_graph)
     1    0.000    0.000    0.002    0.002 /tmp/vb_sklearn/sklearn/neighbors/base.py:261(kneighbors_graph)
     1    0.000    0.000    0.002    0.002 /tmp/vb_sklearn/sklearn/neighbors/base.py:156(kneighbors)
     1    0.001    0.001    0.002    0.002 {sklearn.utils.graph_shortest_path.graph_shortest_path}
     1    0.001    0.001    0.001    0.001 {method 'query' of 'sklearn.neighbors.ball_tree.BallTree' objects}
     1    0.000    0.000    0.001    0.001 /tmp/vb_sklearn/sklearn/decomposition/kernel_pca.py:188(fit_transform)
     1    0.000    0.000    0.001    0.001 /tmp/vb_sklearn/sklearn/decomposition/kernel_pca.py:165(fit)
     1    0.000    0.000    0.001    0.001 /tmp/vb_sklearn/sklearn/decomposition/kernel_pca.py:114(_fit_transform)
     1    0.001    0.001    0.001    0.001 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/decomp.py:196(eigh)
     3    0.000    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/compressed.py:20(__init__)
     1    0.000    0.000    0.001    0.001 /tmp/vb_sklearn/sklearn/neighbors/base.py:578(fit)
     1    0.000    0.000    0.001    0.001 /tmp/vb_sklearn/sklearn/neighbors/base.py:96(_fit)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/compressed.py:101(check_format)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/csc.py:124(tocsr)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:23(safe_asarray)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:370(__getattr__)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/csr.py:107(transpose)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/base.py:332(fit_transform)
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:10(assert_all_finite)
     5    0.000    0.000    0.000    0.000 {method 'sum' of 'numpy.ndarray' objects}
     8    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:553(isspmatrix)
    10    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:116(_isinstance)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:70(atleast2d_or_csr)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/compressed.py:622(prune)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/preprocessing.py:867(transform)
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:62(array2d)
    34    0.000    0.000    0.000    0.000 {numpy.core.multiarray.array}
    22    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:167(asarray)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:60(get_lapack_funcs)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/preprocessing.py:850(fit)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/lib/function_base.py:526(asarray_chkfinite)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:18(upcast)
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:1379(sum)
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/shape_base.py:58(atleast_2d)
    22    0.000    0.000    0.000    0.000 {method 'split' of 'str' objects}
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:45(find_best_lapack_type)
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/csr.py:395(isspmatrix_csr)
     2    0.000    0.000    0.000    0.000 {method 'ravel' of 'numpy.ndarray' objects}
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/data.py:17(__init__)
    19    0.000    0.000    0.000    0.000 {isinstance}
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:96(isshape)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/decomposition/kernel_pca.py:84(__init__)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:50(to_native)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/decomposition/kernel_pca.py:102(_get_kernel)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sparsetools/csc.py:107(csc_tocsr)
     2    0.000    0.000    0.000    0.000 {method 'any' of 'numpy.ndarray' objects}
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:59(set_shape)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:51(__init__)
     3    0.000    0.000    0.000    0.000 {numpy.core.multiarray.empty}
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:237(asanyarray)
    14    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/compressed.py:85(getnnz)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/lib/type_check.py:235(iscomplexobj)
    38    0.000    0.000    0.000    0.000 {len}
     1    0.000    0.000    0.000    0.000 {_csc.csc_tocsr}
    10    0.000    0.000    0.000    0.000 {numpy.core.multiarray.can_cast}
     1    0.000    0.000    0.000    0.000 {numpy.core.multiarray.arange}
     1    0.000    0.000    0.000    0.000 {method 'copy' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 {method 'argsort' of 'numpy.ndarray' objects}
     6    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/csr.py:180(_swap)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:23(cast_to_lapack_prefix)
    10    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:81(get_shape)
     2    0.000    0.000    0.000    0.000 {getattr}
     9    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:2116(rank)
     3    0.000    0.000    0.000    0.000 {method 'newbyteorder' of 'numpy.dtype' objects}
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/compressed.py:597(__set_sorted)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:54(getdtype)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:449(isfortran)
     4    0.000    0.000    0.000    0.000 {method 'append' of 'list' objects}
     3    0.000    0.000    0.000    0.000 {issubclass}
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/metrics/pairwise.py:564(pairwise_kernels)
     1    0.000    0.000    0.000    0.000 {min}
     1    0.000    0.000    0.000    0.000 {range}
     1    0.000    0.000    0.000    0.000 {method 'sort' of 'list' objects}
     1    0.000    0.000    0.000    0.000 {method 'lower' of 'str' objects}
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/misc.py:22(_datacopied)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/csc.py:173(_swap)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/data.py:20(_get_dtype)
     1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}

LineProfiler

   Timer unit: 1e-06 s

File: /tmp/vb_sklearn/sklearn/manifold/isomap.py
Function: fit at line 147
Total time: 0.005241 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   147                                               def fit(self, X, y=None):
   148                                                   """Compute the embedding vectors for data X
   149
   150                                                   Parameters
   151                                                   ----------
   152                                                   X : {array-like, sparse matrix, BallTree, cKDTree, NearestNeighbors}
   153                                                       Sample data, shape = (n_samples, n_features), in the form of a
   154                                                       numpy array, sparse array, precomputed tree, or NearestNeighbors
   155                                                       object.
   156
   157                                                   Returns
   158                                                   -------
   159                                                   self : returns an instance of self.
   160                                                   """
   161         1         5239   5239.0    100.0          self._fit_transform(X)
   162         1            2      2.0      0.0          return self

File: /tmp/vb_sklearn/sklearn/manifold/isomap.py
Function: transform at line 180
Total time: 0 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   180                                               def transform(self, X):
   181                                                   """Transform X.
   182
   183                                                   This is implemented by linking the points X into the graph of geodesic
   184                                                   distances of the training data. First the `n_neighbors` nearest
   185                                                   neighbors of X are found in the training data, and from these the
   186                                                   shortest geodesic distances from each point in X to each point in
   187                                                   the training data are computed in order to construct the kernel.
   188                                                   The embedding of X is the projection of this kernel onto the
   189                                                   embedding vectors of the training set.
   190
   191                                                   Parameters
   192                                                   ----------
   193                                                   X: array-like, shape (n_samples, n_features)
   194
   195                                                   Returns
   196                                                   -------
   197                                                   X_new: array-like, shape (n_samples, n_components)
   198                                                   """
   199                                                   distances, indices = self.nbrs_.kneighbors(X, return_distance=True)
   200
   201                                                   #Create the graph of shortest distances from X to self.training_data_
   202                                                   # via the nearest neighbors of X.
   203                                                   #This can be done as a single array operation, but it potentially
   204                                                   # takes a lot of memory.  To avoid that, use a loop:
   205                                                   G_X = np.zeros((X.shape[0], self.training_data_.shape[0]))
   206                                                   for i in range(X.shape[0]):
   207                                                       G_X[i] = np.min((self.dist_matrix_[indices[i]]
   208                                                                        + distances[i][:, None]), 0)
   209
   210                                                   G_X **= 2
   211                                                   G_X *= -0.5
   212
   213                                                   return self.kernel_pca_.transform(G_X)

Benchmark statement

obj.transform(X)

Execution time

_images/Isomap-dense-minimadelon-step1-timing.png

Memory usage

_images/Isomap-dense-minimadelon-step1-memory.png

Additional output

cProfile

         115 function calls in 0.004 seconds

Ordered by: cumulative time

ncalls  tottime  percall  cumtime  percall filename:lineno(function)
     1    0.000    0.000    0.004    0.004 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/vbench/benchmark.py:286(f)
     1    0.000    0.000    0.004    0.004 <f>:1(<module>)
     1    0.001    0.001    0.004    0.004 /tmp/vb_sklearn/sklearn/manifold/isomap.py:180(transform)
     1    0.000    0.000    0.002    0.002 /tmp/vb_sklearn/sklearn/neighbors/base.py:156(kneighbors)
     1    0.001    0.001    0.001    0.001 {method 'query' of 'sklearn.neighbors.ball_tree.BallTree' objects}
    30    0.000    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:1836(amin)
    30    0.001    0.000    0.001    0.000 {method 'min' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/decomposition/kernel_pca.py:210(transform)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:70(atleast2d_or_csr)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/preprocessing.py:867(transform)
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:62(array2d)
     2    0.000    0.000    0.000    0.000 {method 'sum' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:10(assert_all_finite)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:553(isspmatrix)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:116(_isinstance)
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/shape_base.py:58(atleast_2d)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:1379(sum)
     1    0.000    0.000    0.000    0.000 {numpy.core._dotblas.dot}
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:237(asanyarray)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/decomposition/kernel_pca.py:102(_get_kernel)
     4    0.000    0.000    0.000    0.000 {numpy.core.multiarray.array}
     6    0.000    0.000    0.000    0.000 {method 'split' of 'str' objects}
     1    0.000    0.000    0.000    0.000 {range}
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:167(asarray)
     4    0.000    0.000    0.000    0.000 {isinstance}
     1    0.000    0.000    0.000    0.000 {method 'copy' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 {numpy.core.multiarray.zeros}
     6    0.000    0.000    0.000    0.000 {len}
     2    0.000    0.000    0.000    0.000 {method 'append' of 'list' objects}
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/metrics/pairwise.py:564(pairwise_kernels)
     1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}

LineProfiler

   Timer unit: 1e-06 s

File: /tmp/vb_sklearn/sklearn/manifold/isomap.py
Function: fit at line 147
Total time: 0.005241 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   147                                               def fit(self, X, y=None):
   148                                                   """Compute the embedding vectors for data X
   149
   150                                                   Parameters
   151                                                   ----------
   152                                                   X : {array-like, sparse matrix, BallTree, cKDTree, NearestNeighbors}
   153                                                       Sample data, shape = (n_samples, n_features), in the form of a
   154                                                       numpy array, sparse array, precomputed tree, or NearestNeighbors
   155                                                       object.
   156
   157                                                   Returns
   158                                                   -------
   159                                                   self : returns an instance of self.
   160                                                   """
   161         1         5239   5239.0    100.0          self._fit_transform(X)
   162         1            2      2.0      0.0          return self

File: /tmp/vb_sklearn/sklearn/manifold/isomap.py
Function: transform at line 180
Total time: 0.004273 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   180                                               def transform(self, X):
   181                                                   """Transform X.
   182
   183                                                   This is implemented by linking the points X into the graph of geodesic
   184                                                   distances of the training data. First the `n_neighbors` nearest
   185                                                   neighbors of X are found in the training data, and from these the
   186                                                   shortest geodesic distances from each point in X to each point in
   187                                                   the training data are computed in order to construct the kernel.
   188                                                   The embedding of X is the projection of this kernel onto the
   189                                                   embedding vectors of the training set.
   190
   191                                                   Parameters
   192                                                   ----------
   193                                                   X: array-like, shape (n_samples, n_features)
   194
   195                                                   Returns
   196                                                   -------
   197                                                   X_new: array-like, shape (n_samples, n_components)
   198                                                   """
   199         1         1631   1631.0     38.2          distances, indices = self.nbrs_.kneighbors(X, return_distance=True)
   200
   201                                                   #Create the graph of shortest distances from X to self.training_data_
   202                                                   # via the nearest neighbors of X.
   203                                                   #This can be done as a single array operation, but it potentially
   204                                                   # takes a lot of memory.  To avoid that, use a loop:
   205         1           13     13.0      0.3          G_X = np.zeros((X.shape[0], self.training_data_.shape[0]))
   206        31           99      3.2      2.3          for i in range(X.shape[0]):
   207        30          797     26.6     18.7              G_X[i] = np.min((self.dist_matrix_[indices[i]]
   208        30         1388     46.3     32.5                               + distances[i][:, None]), 0)
   209
   210         1           14     14.0      0.3          G_X **= 2
   211         1           16     16.0      0.4          G_X *= -0.5
   212
   213         1          315    315.0      7.4          return self.kernel_pca_.transform(G_X)

Isomap-dense-blobs

Benchmark setup

from sklearn.manifold import Isomap
from deps import load_data

kwargs = {'eigen_solver': 'dense'}
X, y, X_t, y_t = load_data('blobs')
obj = Isomap(**kwargs)

Benchmark statement

obj.fit(X)

Execution time

_images/Isomap-dense-blobs-step0-timing.png

Memory usage

_images/Isomap-dense-blobs-step0-memory.png

Additional output

cProfile

         314 function calls in 0.046 seconds

Ordered by: cumulative time

ncalls  tottime  percall  cumtime  percall filename:lineno(function)
     1    0.000    0.000    0.046    0.046 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/vbench/benchmark.py:286(f)
     1    0.000    0.000    0.046    0.046 <f>:1(<module>)
     1    0.000    0.000    0.046    0.046 /tmp/vb_sklearn/sklearn/manifold/isomap.py:147(fit)
     1    0.001    0.001    0.046    0.046 /tmp/vb_sklearn/sklearn/manifold/isomap.py:98(_fit_transform)
     1    0.000    0.000    0.031    0.031 /tmp/vb_sklearn/sklearn/decomposition/kernel_pca.py:188(fit_transform)
     1    0.000    0.000    0.031    0.031 /tmp/vb_sklearn/sklearn/decomposition/kernel_pca.py:165(fit)
     1    0.000    0.000    0.031    0.031 /tmp/vb_sklearn/sklearn/decomposition/kernel_pca.py:114(_fit_transform)
     1    0.027    0.027    0.029    0.029 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/decomp.py:196(eigh)
     1    0.000    0.000    0.008    0.008 /tmp/vb_sklearn/sklearn/neighbors/graph.py:11(kneighbors_graph)
     1    0.000    0.000    0.008    0.008 /tmp/vb_sklearn/sklearn/neighbors/base.py:261(kneighbors_graph)
     1    0.000    0.000    0.008    0.008 /tmp/vb_sklearn/sklearn/neighbors/base.py:156(kneighbors)
     1    0.008    0.008    0.008    0.008 {method 'query' of 'sklearn.neighbors.ball_tree.BallTree' objects}
     1    0.005    0.005    0.006    0.006 {sklearn.utils.graph_shortest_path.graph_shortest_path}
     1    0.001    0.001    0.002    0.002 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/lib/function_base.py:526(asarray_chkfinite)
     1    0.000    0.000    0.001    0.001 /tmp/vb_sklearn/sklearn/base.py:332(fit_transform)
     1    0.001    0.001    0.001    0.001 /tmp/vb_sklearn/sklearn/preprocessing.py:867(transform)
     1    0.000    0.000    0.001    0.001 /tmp/vb_sklearn/sklearn/neighbors/base.py:578(fit)
     1    0.001    0.001    0.001    0.001 /tmp/vb_sklearn/sklearn/neighbors/base.py:96(_fit)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/compressed.py:20(__init__)
     5    0.000    0.000    0.000    0.000 {method 'sum' of 'numpy.ndarray' objects}
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:1379(sum)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/compressed.py:101(check_format)
     1    0.000    0.000    0.000    0.000 {method 'copy' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/csc.py:124(tocsr)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/preprocessing.py:850(fit)
     2    0.000    0.000    0.000    0.000 {method 'any' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:370(__getattr__)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:23(safe_asarray)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/csr.py:107(transpose)
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:10(assert_all_finite)
    10    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:116(_isinstance)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:70(atleast2d_or_csr)
     8    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:553(isspmatrix)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/compressed.py:622(prune)
    34    0.000    0.000    0.000    0.000 {numpy.core.multiarray.array}
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:60(get_lapack_funcs)
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:62(array2d)
    22    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:167(asarray)
     2    0.000    0.000    0.000    0.000 {method 'ravel' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:18(upcast)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sparsetools/csc.py:107(csc_tocsr)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:45(find_best_lapack_type)
    22    0.000    0.000    0.000    0.000 {method 'split' of 'str' objects}
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/shape_base.py:58(atleast_2d)
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/csr.py:395(isspmatrix_csr)
     1    0.000    0.000    0.000    0.000 {_csc.csc_tocsr}
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/data.py:17(__init__)
    19    0.000    0.000    0.000    0.000 {isinstance}
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:50(to_native)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:96(isshape)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/decomposition/kernel_pca.py:102(_get_kernel)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/decomposition/kernel_pca.py:84(__init__)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:59(set_shape)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:51(__init__)
    14    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/compressed.py:85(getnnz)
     3    0.000    0.000    0.000    0.000 {numpy.core.multiarray.empty}
     1    0.000    0.000    0.000    0.000 {numpy.core.multiarray.arange}
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/lib/type_check.py:235(iscomplexobj)
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:237(asanyarray)
     1    0.000    0.000    0.000    0.000 {method 'argsort' of 'numpy.ndarray' objects}
     9    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:2116(rank)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:23(cast_to_lapack_prefix)
    10    0.000    0.000    0.000    0.000 {numpy.core.multiarray.can_cast}
     2    0.000    0.000    0.000    0.000 {getattr}
    10    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:81(get_shape)
     3    0.000    0.000    0.000    0.000 {method 'newbyteorder' of 'numpy.dtype' objects}
    38    0.000    0.000    0.000    0.000 {len}
     6    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/csr.py:180(_swap)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:54(getdtype)
     3    0.000    0.000    0.000    0.000 {issubclass}
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/misc.py:22(_datacopied)
     1    0.000    0.000    0.000    0.000 {min}
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/csc.py:173(_swap)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/compressed.py:597(__set_sorted)
     1    0.000    0.000    0.000    0.000 {range}
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:449(isfortran)
     4    0.000    0.000    0.000    0.000 {method 'append' of 'list' objects}
     1    0.000    0.000    0.000    0.000 {method 'sort' of 'list' objects}
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/metrics/pairwise.py:564(pairwise_kernels)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/data.py:20(_get_dtype)
     1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}
     1    0.000    0.000    0.000    0.000 {method 'lower' of 'str' objects}

LineProfiler

   Timer unit: 1e-06 s

File: /tmp/vb_sklearn/sklearn/manifold/isomap.py
Function: fit at line 147
Total time: 0.044164 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   147                                               def fit(self, X, y=None):
   148                                                   """Compute the embedding vectors for data X
   149
   150                                                   Parameters
   151                                                   ----------
   152                                                   X : {array-like, sparse matrix, BallTree, cKDTree, NearestNeighbors}
   153                                                       Sample data, shape = (n_samples, n_features), in the form of a
   154                                                       numpy array, sparse array, precomputed tree, or NearestNeighbors
   155                                                       object.
   156
   157                                                   Returns
   158                                                   -------
   159                                                   self : returns an instance of self.
   160                                                   """
   161         1        44162  44162.0    100.0          self._fit_transform(X)
   162         1            2      2.0      0.0          return self

File: /tmp/vb_sklearn/sklearn/manifold/isomap.py
Function: transform at line 180
Total time: 0 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   180                                               def transform(self, X):
   181                                                   """Transform X.
   182
   183                                                   This is implemented by linking the points X into the graph of geodesic
   184                                                   distances of the training data. First the `n_neighbors` nearest
   185                                                   neighbors of X are found in the training data, and from these the
   186                                                   shortest geodesic distances from each point in X to each point in
   187                                                   the training data are computed in order to construct the kernel.
   188                                                   The embedding of X is the projection of this kernel onto the
   189                                                   embedding vectors of the training set.
   190
   191                                                   Parameters
   192                                                   ----------
   193                                                   X: array-like, shape (n_samples, n_features)
   194
   195                                                   Returns
   196                                                   -------
   197                                                   X_new: array-like, shape (n_samples, n_components)
   198                                                   """
   199                                                   distances, indices = self.nbrs_.kneighbors(X, return_distance=True)
   200
   201                                                   #Create the graph of shortest distances from X to self.training_data_
   202                                                   # via the nearest neighbors of X.
   203                                                   #This can be done as a single array operation, but it potentially
   204                                                   # takes a lot of memory.  To avoid that, use a loop:
   205                                                   G_X = np.zeros((X.shape[0], self.training_data_.shape[0]))
   206                                                   for i in range(X.shape[0]):
   207                                                       G_X[i] = np.min((self.dist_matrix_[indices[i]]
   208                                                                        + distances[i][:, None]), 0)
   209
   210                                                   G_X **= 2
   211                                                   G_X *= -0.5
   212
   213                                                   return self.kernel_pca_.transform(G_X)

Benchmark statement

obj.transform(X)

Execution time

_images/Isomap-dense-blobs-step1-timing.png

Memory usage

_images/Isomap-dense-blobs-step1-memory.png

Additional output

cProfile

         655 function calls in 0.036 seconds

Ordered by: cumulative time

ncalls  tottime  percall  cumtime  percall filename:lineno(function)
     1    0.000    0.000    0.036    0.036 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/vbench/benchmark.py:286(f)
     1    0.000    0.000    0.036    0.036 <f>:1(<module>)
     1    0.021    0.021    0.036    0.036 /tmp/vb_sklearn/sklearn/manifold/isomap.py:180(transform)
     1    0.000    0.000    0.008    0.008 /tmp/vb_sklearn/sklearn/neighbors/base.py:156(kneighbors)
     1    0.008    0.008    0.008    0.008 {method 'query' of 'sklearn.neighbors.ball_tree.BallTree' objects}
   300    0.000    0.000    0.005    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:1836(amin)
   300    0.005    0.000    0.005    0.000 {method 'min' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.001    0.001 /tmp/vb_sklearn/sklearn/decomposition/kernel_pca.py:210(transform)
     1    0.001    0.001    0.001    0.001 /tmp/vb_sklearn/sklearn/preprocessing.py:867(transform)
     1    0.000    0.000    0.000    0.000 {numpy.core._dotblas.dot}
     2    0.000    0.000    0.000    0.000 {method 'sum' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:1379(sum)
     1    0.000    0.000    0.000    0.000 {method 'copy' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:70(atleast2d_or_csr)
     1    0.000    0.000    0.000    0.000 {numpy.core.multiarray.zeros}
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:10(assert_all_finite)
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:62(array2d)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:553(isspmatrix)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:116(_isinstance)
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/shape_base.py:58(atleast_2d)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/decomposition/kernel_pca.py:102(_get_kernel)
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:237(asanyarray)
     4    0.000    0.000    0.000    0.000 {numpy.core.multiarray.array}
     1    0.000    0.000    0.000    0.000 {range}
     4    0.000    0.000    0.000    0.000 {isinstance}
     6    0.000    0.000    0.000    0.000 {method 'split' of 'str' objects}
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:167(asarray)
     6    0.000    0.000    0.000    0.000 {len}
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/metrics/pairwise.py:564(pairwise_kernels)
     1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}
     2    0.000    0.000    0.000    0.000 {method 'append' of 'list' objects}

LineProfiler

   Timer unit: 1e-06 s

File: /tmp/vb_sklearn/sklearn/manifold/isomap.py
Function: fit at line 147
Total time: 0.044164 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   147                                               def fit(self, X, y=None):
   148                                                   """Compute the embedding vectors for data X
   149
   150                                                   Parameters
   151                                                   ----------
   152                                                   X : {array-like, sparse matrix, BallTree, cKDTree, NearestNeighbors}
   153                                                       Sample data, shape = (n_samples, n_features), in the form of a
   154                                                       numpy array, sparse array, precomputed tree, or NearestNeighbors
   155                                                       object.
   156
   157                                                   Returns
   158                                                   -------
   159                                                   self : returns an instance of self.
   160                                                   """
   161         1        44162  44162.0    100.0          self._fit_transform(X)
   162         1            2      2.0      0.0          return self

File: /tmp/vb_sklearn/sklearn/manifold/isomap.py
Function: transform at line 180
Total time: 0.038649 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   180                                               def transform(self, X):
   181                                                   """Transform X.
   182
   183                                                   This is implemented by linking the points X into the graph of geodesic
   184                                                   distances of the training data. First the `n_neighbors` nearest
   185                                                   neighbors of X are found in the training data, and from these the
   186                                                   shortest geodesic distances from each point in X to each point in
   187                                                   the training data are computed in order to construct the kernel.
   188                                                   The embedding of X is the projection of this kernel onto the
   189                                                   embedding vectors of the training set.
   190
   191                                                   Parameters
   192                                                   ----------
   193                                                   X: array-like, shape (n_samples, n_features)
   194
   195                                                   Returns
   196                                                   -------
   197                                                   X_new: array-like, shape (n_samples, n_components)
   198                                                   """
   199         1         7846   7846.0     20.3          distances, indices = self.nbrs_.kneighbors(X, return_distance=True)
   200
   201                                                   #Create the graph of shortest distances from X to self.training_data_
   202                                                   # via the nearest neighbors of X.
   203                                                   #This can be done as a single array operation, but it potentially
   204                                                   # takes a lot of memory.  To avoid that, use a loop:
   205         1           59     59.0      0.2          G_X = np.zeros((X.shape[0], self.training_data_.shape[0]))
   206       301          537      1.8      1.4          for i in range(X.shape[0]):
   207       300        16633     55.4     43.0              G_X[i] = np.min((self.dist_matrix_[indices[i]]
   208       300        11944     39.8     30.9                               + distances[i][:, None]), 0)
   209
   210         1          149    149.0      0.4          G_X **= 2
   211         1          168    168.0      0.4          G_X *= -0.5
   212
   213         1         1313   1313.0      3.4          return self.kernel_pca_.transform(G_X)

Isomap-arpack-minimadelon

Benchmark setup

from sklearn.manifold import Isomap
from deps import load_data

kwargs = {'eigen_solver': 'arpack'}
X, y, X_t, y_t = load_data('minimadelon')
obj = Isomap(**kwargs)

Benchmark statement

obj.fit(X)

Execution time

_images/Isomap-arpack-minimadelon-step0-timing.png

Memory usage

_images/Isomap-arpack-minimadelon-step0-memory.png

Additional output

cProfile

         478 function calls in 0.014 seconds

Ordered by: cumulative time

ncalls  tottime  percall  cumtime  percall filename:lineno(function)
     1    0.000    0.000    0.014    0.014 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/vbench/benchmark.py:286(f)
     1    0.000    0.000    0.014    0.014 <f>:1(<module>)
     1    0.000    0.000    0.014    0.014 /tmp/vb_sklearn/sklearn/manifold/isomap.py:147(fit)
     1    0.000    0.000    0.014    0.014 /tmp/vb_sklearn/sklearn/manifold/isomap.py:98(_fit_transform)
     1    0.000    0.000    0.010    0.010 /tmp/vb_sklearn/sklearn/decomposition/kernel_pca.py:188(fit_transform)
     1    0.000    0.000    0.010    0.010 /tmp/vb_sklearn/sklearn/decomposition/kernel_pca.py:165(fit)
     1    0.000    0.000    0.010    0.010 /tmp/vb_sklearn/sklearn/decomposition/kernel_pca.py:114(_fit_transform)
     1    0.000    0.000    0.009    0.009 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:1275(eigsh)
    72    0.008    0.000    0.009    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:540(iterate)
     1    0.000    0.000    0.002    0.002 /tmp/vb_sklearn/sklearn/neighbors/graph.py:11(kneighbors_graph)
     1    0.000    0.000    0.002    0.002 /tmp/vb_sklearn/sklearn/neighbors/base.py:261(kneighbors_graph)
     1    0.000    0.000    0.002    0.002 /tmp/vb_sklearn/sklearn/neighbors/base.py:156(kneighbors)
     1    0.001    0.001    0.002    0.002 {sklearn.utils.graph_shortest_path.graph_shortest_path}
     1    0.001    0.001    0.002    0.002 {method 'query' of 'sklearn.neighbors.ball_tree.BallTree' objects}
     3    0.000    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/compressed.py:20(__init__)
    71    0.001    0.000    0.001    0.000 {method 'dot' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.001    0.001 /tmp/vb_sklearn/sklearn/neighbors/base.py:578(fit)
     1    0.000    0.000    0.001    0.001 /tmp/vb_sklearn/sklearn/neighbors/base.py:96(_fit)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/compressed.py:101(check_format)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/csc.py:124(tocsr)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:23(safe_asarray)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:370(__getattr__)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/csr.py:107(transpose)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/base.py:332(fit_transform)
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:10(assert_all_finite)
     8    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:553(isspmatrix)
     5    0.000    0.000    0.000    0.000 {method 'sum' of 'numpy.ndarray' objects}
    10    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:116(_isinstance)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:70(atleast2d_or_csr)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:897(_aslinearoperator_with_dtype)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/interface.py:235(aslinearoperator)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/compressed.py:622(prune)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:387(__init__)
    36    0.000    0.000    0.000    0.000 {numpy.core.multiarray.array}
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/preprocessing.py:867(transform)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:580(extract)
    23    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:167(asarray)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/interface.py:204(__init__)
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:62(array2d)
     4    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:96(isshape)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/preprocessing.py:850(fit)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/interface.py:59(__init__)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/shape_base.py:58(atleast_2d)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:18(upcast)
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:1379(sum)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:316(__init__)
    20    0.000    0.000    0.000    0.000 {method 'split' of 'str' objects}
    11    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:2116(rank)
     7    0.000    0.000    0.000    0.000 {numpy.core.multiarray.zeros}
    25    0.000    0.000    0.000    0.000 {isinstance}
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/data.py:17(__init__)
     2    0.000    0.000    0.000    0.000 {method 'ravel' of 'numpy.ndarray' objects}
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:50(to_native)
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/csr.py:395(isspmatrix_csr)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/decomposition/kernel_pca.py:102(_get_kernel)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sparsetools/csc.py:107(csc_tocsr)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:59(set_shape)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/decomposition/kernel_pca.py:84(__init__)
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:81(isintlike)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:51(__init__)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:237(asanyarray)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numerictypes.py:733(issubdtype)
     3    0.000    0.000    0.000    0.000 {numpy.core.multiarray.empty}
    14    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/compressed.py:85(getnnz)
     1    0.000    0.000    0.000    0.000 {method 'argsort' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 {_csc.csc_tocsr}
    39    0.000    0.000    0.000    0.000 {len}
     1    0.000    0.000    0.000    0.000 {numpy.core.multiarray.arange}
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:111(issequence)
    10    0.000    0.000    0.000    0.000 {numpy.core.multiarray.can_cast}
     1    0.000    0.000    0.000    0.000 {method 'copy' of 'numpy.ndarray' objects}
     6    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/csr.py:180(_swap)
    10    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:81(get_shape)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numerictypes.py:665(issubclass_)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:54(getdtype)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/compressed.py:597(__set_sorted)
     3    0.000    0.000    0.000    0.000 {method 'newbyteorder' of 'numpy.dtype' objects}
     2    0.000    0.000    0.000    0.000 {min}
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:57(_single_precision_cast)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/metrics/pairwise.py:564(pairwise_kernels)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/csc.py:173(_swap)
     3    0.000    0.000    0.000    0.000 {method 'append' of 'list' objects}
     2    0.000    0.000    0.000    0.000 {issubclass}
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/data.py:20(_get_dtype)
     1    0.000    0.000    0.000    0.000 {hasattr}
     1    0.000    0.000    0.000    0.000 {method 'lower' of 'str' objects}
     1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}

LineProfiler

   Timer unit: 1e-06 s

File: /tmp/vb_sklearn/sklearn/manifold/isomap.py
Function: fit at line 147
Total time: 0.013853 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   147                                               def fit(self, X, y=None):
   148                                                   """Compute the embedding vectors for data X
   149
   150                                                   Parameters
   151                                                   ----------
   152                                                   X : {array-like, sparse matrix, BallTree, cKDTree, NearestNeighbors}
   153                                                       Sample data, shape = (n_samples, n_features), in the form of a
   154                                                       numpy array, sparse array, precomputed tree, or NearestNeighbors
   155                                                       object.
   156
   157                                                   Returns
   158                                                   -------
   159                                                   self : returns an instance of self.
   160                                                   """
   161         1        13851  13851.0    100.0          self._fit_transform(X)
   162         1            2      2.0      0.0          return self

File: /tmp/vb_sklearn/sklearn/manifold/isomap.py
Function: transform at line 180
Total time: 0 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   180                                               def transform(self, X):
   181                                                   """Transform X.
   182
   183                                                   This is implemented by linking the points X into the graph of geodesic
   184                                                   distances of the training data. First the `n_neighbors` nearest
   185                                                   neighbors of X are found in the training data, and from these the
   186                                                   shortest geodesic distances from each point in X to each point in
   187                                                   the training data are computed in order to construct the kernel.
   188                                                   The embedding of X is the projection of this kernel onto the
   189                                                   embedding vectors of the training set.
   190
   191                                                   Parameters
   192                                                   ----------
   193                                                   X: array-like, shape (n_samples, n_features)
   194
   195                                                   Returns
   196                                                   -------
   197                                                   X_new: array-like, shape (n_samples, n_components)
   198                                                   """
   199                                                   distances, indices = self.nbrs_.kneighbors(X, return_distance=True)
   200
   201                                                   #Create the graph of shortest distances from X to self.training_data_
   202                                                   # via the nearest neighbors of X.
   203                                                   #This can be done as a single array operation, but it potentially
   204                                                   # takes a lot of memory.  To avoid that, use a loop:
   205                                                   G_X = np.zeros((X.shape[0], self.training_data_.shape[0]))
   206                                                   for i in range(X.shape[0]):
   207                                                       G_X[i] = np.min((self.dist_matrix_[indices[i]]
   208                                                                        + distances[i][:, None]), 0)
   209
   210                                                   G_X **= 2
   211                                                   G_X *= -0.5
   212
   213                                                   return self.kernel_pca_.transform(G_X)

Benchmark statement

obj.transform(X)

Execution time

_images/Isomap-arpack-minimadelon-step1-timing.png

Memory usage

_images/Isomap-arpack-minimadelon-step1-memory.png

Additional output

cProfile

         115 function calls in 0.004 seconds

Ordered by: cumulative time

ncalls  tottime  percall  cumtime  percall filename:lineno(function)
     1    0.000    0.000    0.004    0.004 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/vbench/benchmark.py:286(f)
     1    0.000    0.000    0.004    0.004 <f>:1(<module>)
     1    0.001    0.001    0.004    0.004 /tmp/vb_sklearn/sklearn/manifold/isomap.py:180(transform)
     1    0.000    0.000    0.002    0.002 /tmp/vb_sklearn/sklearn/neighbors/base.py:156(kneighbors)
     1    0.001    0.001    0.001    0.001 {method 'query' of 'sklearn.neighbors.ball_tree.BallTree' objects}
    30    0.000    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:1836(amin)
    30    0.001    0.000    0.001    0.000 {method 'min' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/decomposition/kernel_pca.py:210(transform)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:70(atleast2d_or_csr)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/preprocessing.py:867(transform)
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:62(array2d)
     2    0.000    0.000    0.000    0.000 {method 'sum' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:10(assert_all_finite)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:553(isspmatrix)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:116(_isinstance)
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/shape_base.py:58(atleast_2d)
     1    0.000    0.000    0.000    0.000 {numpy.core._dotblas.dot}
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:1379(sum)
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:237(asanyarray)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/decomposition/kernel_pca.py:102(_get_kernel)
     4    0.000    0.000    0.000    0.000 {numpy.core.multiarray.array}
     1    0.000    0.000    0.000    0.000 {method 'copy' of 'numpy.ndarray' objects}
     4    0.000    0.000    0.000    0.000 {isinstance}
     6    0.000    0.000    0.000    0.000 {method 'split' of 'str' objects}
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:167(asarray)
     1    0.000    0.000    0.000    0.000 {numpy.core.multiarray.zeros}
     6    0.000    0.000    0.000    0.000 {len}
     1    0.000    0.000    0.000    0.000 {range}
     2    0.000    0.000    0.000    0.000 {method 'append' of 'list' objects}
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/metrics/pairwise.py:564(pairwise_kernels)
     1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}

LineProfiler

   Timer unit: 1e-06 s

File: /tmp/vb_sklearn/sklearn/manifold/isomap.py
Function: fit at line 147
Total time: 0.013853 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   147                                               def fit(self, X, y=None):
   148                                                   """Compute the embedding vectors for data X
   149
   150                                                   Parameters
   151                                                   ----------
   152                                                   X : {array-like, sparse matrix, BallTree, cKDTree, NearestNeighbors}
   153                                                       Sample data, shape = (n_samples, n_features), in the form of a
   154                                                       numpy array, sparse array, precomputed tree, or NearestNeighbors
   155                                                       object.
   156
   157                                                   Returns
   158                                                   -------
   159                                                   self : returns an instance of self.
   160                                                   """
   161         1        13851  13851.0    100.0          self._fit_transform(X)
   162         1            2      2.0      0.0          return self

File: /tmp/vb_sklearn/sklearn/manifold/isomap.py
Function: transform at line 180
Total time: 0.004068 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   180                                               def transform(self, X):
   181                                                   """Transform X.
   182
   183                                                   This is implemented by linking the points X into the graph of geodesic
   184                                                   distances of the training data. First the `n_neighbors` nearest
   185                                                   neighbors of X are found in the training data, and from these the
   186                                                   shortest geodesic distances from each point in X to each point in
   187                                                   the training data are computed in order to construct the kernel.
   188                                                   The embedding of X is the projection of this kernel onto the
   189                                                   embedding vectors of the training set.
   190
   191                                                   Parameters
   192                                                   ----------
   193                                                   X: array-like, shape (n_samples, n_features)
   194
   195                                                   Returns
   196                                                   -------
   197                                                   X_new: array-like, shape (n_samples, n_components)
   198                                                   """
   199         1         1603   1603.0     39.4          distances, indices = self.nbrs_.kneighbors(X, return_distance=True)
   200
   201                                                   #Create the graph of shortest distances from X to self.training_data_
   202                                                   # via the nearest neighbors of X.
   203                                                   #This can be done as a single array operation, but it potentially
   204                                                   # takes a lot of memory.  To avoid that, use a loop:
   205         1           10     10.0      0.2          G_X = np.zeros((X.shape[0], self.training_data_.shape[0]))
   206        31           98      3.2      2.4          for i in range(X.shape[0]):
   207        30          696     23.2     17.1              G_X[i] = np.min((self.dist_matrix_[indices[i]]
   208        30         1441     48.0     35.4                               + distances[i][:, None]), 0)
   209
   210         1           12     12.0      0.3          G_X **= 2
   211         1           16     16.0      0.4          G_X *= -0.5
   212
   213         1          192    192.0      4.7          return self.kernel_pca_.transform(G_X)

Isomap-arpack-blobs

Benchmark setup

from sklearn.manifold import Isomap
from deps import load_data

kwargs = {'eigen_solver': 'arpack'}
X, y, X_t, y_t = load_data('blobs')
obj = Isomap(**kwargs)

Benchmark statement

obj.fit(X)

Execution time

_images/Isomap-arpack-blobs-step0-timing.png

Memory usage

_images/Isomap-arpack-blobs-step0-memory.png

Additional output

cProfile

         1426 function calls in 0.192 seconds

Ordered by: cumulative time

ncalls  tottime  percall  cumtime  percall filename:lineno(function)
     1    0.000    0.000    0.192    0.192 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/vbench/benchmark.py:286(f)
     1    0.000    0.000    0.192    0.192 <f>:1(<module>)
     1    0.000    0.000    0.192    0.192 /tmp/vb_sklearn/sklearn/manifold/isomap.py:147(fit)
     1    0.001    0.001    0.192    0.192 /tmp/vb_sklearn/sklearn/manifold/isomap.py:98(_fit_transform)
     1    0.000    0.000    0.165    0.165 /tmp/vb_sklearn/sklearn/decomposition/kernel_pca.py:188(fit_transform)
     1    0.000    0.000    0.165    0.165 /tmp/vb_sklearn/sklearn/decomposition/kernel_pca.py:165(fit)
     1    0.000    0.000    0.165    0.165 /tmp/vb_sklearn/sklearn/decomposition/kernel_pca.py:114(_fit_transform)
     1    0.002    0.002    0.163    0.163 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:1275(eigsh)
   546    0.074    0.000    0.161    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:540(iterate)
   545    0.087    0.000    0.087    0.000 {method 'dot' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.015    0.015 /tmp/vb_sklearn/sklearn/neighbors/graph.py:11(kneighbors_graph)
     1    0.000    0.000    0.015    0.015 /tmp/vb_sklearn/sklearn/neighbors/base.py:261(kneighbors_graph)
     1    0.000    0.000    0.014    0.014 /tmp/vb_sklearn/sklearn/neighbors/base.py:156(kneighbors)
     1    0.014    0.014    0.014    0.014 {method 'query' of 'sklearn.neighbors.ball_tree.BallTree' objects}
     1    0.009    0.009    0.010    0.010 {sklearn.utils.graph_shortest_path.graph_shortest_path}
     1    0.000    0.000    0.002    0.002 /tmp/vb_sklearn/sklearn/base.py:332(fit_transform)
     1    0.001    0.001    0.002    0.002 /tmp/vb_sklearn/sklearn/preprocessing.py:867(transform)
     1    0.000    0.000    0.001    0.001 /tmp/vb_sklearn/sklearn/neighbors/base.py:578(fit)
     1    0.001    0.001    0.001    0.001 /tmp/vb_sklearn/sklearn/neighbors/base.py:96(_fit)
     3    0.000    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/compressed.py:20(__init__)
     5    0.001    0.000    0.001    0.000 {method 'sum' of 'numpy.ndarray' objects}
     2    0.000    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:1379(sum)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/compressed.py:101(check_format)
     1    0.000    0.000    0.000    0.000 {method 'copy' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/csc.py:124(tocsr)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/preprocessing.py:850(fit)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:370(__getattr__)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:23(safe_asarray)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/csr.py:107(transpose)
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:10(assert_all_finite)
    10    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:116(_isinstance)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:70(atleast2d_or_csr)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:897(_aslinearoperator_with_dtype)
     8    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:553(isspmatrix)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/interface.py:235(aslinearoperator)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/compressed.py:622(prune)
    36    0.000    0.000    0.000    0.000 {numpy.core.multiarray.array}
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:387(__init__)
    23    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:167(asarray)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:580(extract)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/interface.py:204(__init__)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:18(upcast)
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:62(array2d)
     4    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:96(isshape)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/interface.py:59(__init__)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:316(__init__)
     2    0.000    0.000    0.000    0.000 {method 'ravel' of 'numpy.ndarray' objects}
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/shape_base.py:58(atleast_2d)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sparsetools/csc.py:107(csc_tocsr)
    20    0.000    0.000    0.000    0.000 {method 'split' of 'str' objects}
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/csr.py:395(isspmatrix_csr)
    11    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:2116(rank)
     7    0.000    0.000    0.000    0.000 {numpy.core.multiarray.zeros}
    25    0.000    0.000    0.000    0.000 {isinstance}
     1    0.000    0.000    0.000    0.000 {_csc.csc_tocsr}
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/data.py:17(__init__)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:50(to_native)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/decomposition/kernel_pca.py:102(_get_kernel)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:59(set_shape)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/decomposition/kernel_pca.py:84(__init__)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:51(__init__)
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:81(isintlike)
     3    0.000    0.000    0.000    0.000 {numpy.core.multiarray.empty}
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:237(asanyarray)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numerictypes.py:733(issubdtype)
    14    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/compressed.py:85(getnnz)
     1    0.000    0.000    0.000    0.000 {numpy.core.multiarray.arange}
    39    0.000    0.000    0.000    0.000 {len}
    10    0.000    0.000    0.000    0.000 {numpy.core.multiarray.can_cast}
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:111(issequence)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numerictypes.py:665(issubclass_)
     1    0.000    0.000    0.000    0.000 {method 'argsort' of 'numpy.ndarray' objects}
     6    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/csr.py:180(_swap)
    10    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:81(get_shape)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:54(getdtype)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/compressed.py:597(__set_sorted)
     3    0.000    0.000    0.000    0.000 {method 'newbyteorder' of 'numpy.dtype' objects}
     2    0.000    0.000    0.000    0.000 {min}
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:57(_single_precision_cast)
     3    0.000    0.000    0.000    0.000 {method 'append' of 'list' objects}
     2    0.000    0.000    0.000    0.000 {issubclass}
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/csc.py:173(_swap)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/data.py:20(_get_dtype)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/metrics/pairwise.py:564(pairwise_kernels)
     1    0.000    0.000    0.000    0.000 {hasattr}
     1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}
     1    0.000    0.000    0.000    0.000 {method 'lower' of 'str' objects}

LineProfiler

   Timer unit: 1e-06 s

File: /tmp/vb_sklearn/sklearn/manifold/isomap.py
Function: fit at line 147
Total time: 0.203606 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   147                                               def fit(self, X, y=None):
   148                                                   """Compute the embedding vectors for data X
   149
   150                                                   Parameters
   151                                                   ----------
   152                                                   X : {array-like, sparse matrix, BallTree, cKDTree, NearestNeighbors}
   153                                                       Sample data, shape = (n_samples, n_features), in the form of a
   154                                                       numpy array, sparse array, precomputed tree, or NearestNeighbors
   155                                                       object.
   156
   157                                                   Returns
   158                                                   -------
   159                                                   self : returns an instance of self.
   160                                                   """
   161         1       203603 203603.0    100.0          self._fit_transform(X)
   162         1            3      3.0      0.0          return self

File: /tmp/vb_sklearn/sklearn/manifold/isomap.py
Function: transform at line 180
Total time: 0 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   180                                               def transform(self, X):
   181                                                   """Transform X.
   182
   183                                                   This is implemented by linking the points X into the graph of geodesic
   184                                                   distances of the training data. First the `n_neighbors` nearest
   185                                                   neighbors of X are found in the training data, and from these the
   186                                                   shortest geodesic distances from each point in X to each point in
   187                                                   the training data are computed in order to construct the kernel.
   188                                                   The embedding of X is the projection of this kernel onto the
   189                                                   embedding vectors of the training set.
   190
   191                                                   Parameters
   192                                                   ----------
   193                                                   X: array-like, shape (n_samples, n_features)
   194
   195                                                   Returns
   196                                                   -------
   197                                                   X_new: array-like, shape (n_samples, n_components)
   198                                                   """
   199                                                   distances, indices = self.nbrs_.kneighbors(X, return_distance=True)
   200
   201                                                   #Create the graph of shortest distances from X to self.training_data_
   202                                                   # via the nearest neighbors of X.
   203                                                   #This can be done as a single array operation, but it potentially
   204                                                   # takes a lot of memory.  To avoid that, use a loop:
   205                                                   G_X = np.zeros((X.shape[0], self.training_data_.shape[0]))
   206                                                   for i in range(X.shape[0]):
   207                                                       G_X[i] = np.min((self.dist_matrix_[indices[i]]
   208                                                                        + distances[i][:, None]), 0)
   209
   210                                                   G_X **= 2
   211                                                   G_X *= -0.5
   212
   213                                                   return self.kernel_pca_.transform(G_X)

Benchmark statement

obj.transform(X)

Execution time

_images/Isomap-arpack-blobs-step1-timing.png

Memory usage

_images/Isomap-arpack-blobs-step1-memory.png

Additional output

cProfile

         655 function calls in 0.064 seconds

Ordered by: cumulative time

ncalls  tottime  percall  cumtime  percall filename:lineno(function)
     1    0.000    0.000    0.064    0.064 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/vbench/benchmark.py:286(f)
     1    0.000    0.000    0.064    0.064 <f>:1(<module>)
     1    0.038    0.038    0.064    0.064 /tmp/vb_sklearn/sklearn/manifold/isomap.py:180(transform)
     1    0.000    0.000    0.014    0.014 /tmp/vb_sklearn/sklearn/neighbors/base.py:156(kneighbors)
     1    0.014    0.014    0.014    0.014 {method 'query' of 'sklearn.neighbors.ball_tree.BallTree' objects}
   300    0.001    0.000    0.009    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:1836(amin)
   300    0.008    0.000    0.008    0.000 {method 'min' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.003    0.003 /tmp/vb_sklearn/sklearn/decomposition/kernel_pca.py:210(transform)
     1    0.001    0.001    0.002    0.002 /tmp/vb_sklearn/sklearn/preprocessing.py:867(transform)
     1    0.001    0.001    0.001    0.001 {numpy.core._dotblas.dot}
     1    0.000    0.000    0.000    0.000 {method 'copy' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 {numpy.core.multiarray.zeros}
     2    0.000    0.000    0.000    0.000 {method 'sum' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:1379(sum)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:70(atleast2d_or_csr)
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:62(array2d)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:10(assert_all_finite)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:553(isspmatrix)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:116(_isinstance)
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/shape_base.py:58(atleast_2d)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/decomposition/kernel_pca.py:102(_get_kernel)
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:237(asanyarray)
     4    0.000    0.000    0.000    0.000 {numpy.core.multiarray.array}
     1    0.000    0.000    0.000    0.000 {range}
     4    0.000    0.000    0.000    0.000 {isinstance}
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:167(asarray)
     6    0.000    0.000    0.000    0.000 {method 'split' of 'str' objects}
     6    0.000    0.000    0.000    0.000 {len}
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/metrics/pairwise.py:564(pairwise_kernels)
     2    0.000    0.000    0.000    0.000 {method 'append' of 'list' objects}
     1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}

LineProfiler

   Timer unit: 1e-06 s

File: /tmp/vb_sklearn/sklearn/manifold/isomap.py
Function: fit at line 147
Total time: 0.203606 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   147                                               def fit(self, X, y=None):
   148                                                   """Compute the embedding vectors for data X
   149
   150                                                   Parameters
   151                                                   ----------
   152                                                   X : {array-like, sparse matrix, BallTree, cKDTree, NearestNeighbors}
   153                                                       Sample data, shape = (n_samples, n_features), in the form of a
   154                                                       numpy array, sparse array, precomputed tree, or NearestNeighbors
   155                                                       object.
   156
   157                                                   Returns
   158                                                   -------
   159                                                   self : returns an instance of self.
   160                                                   """
   161         1       203603 203603.0    100.0          self._fit_transform(X)
   162         1            3      3.0      0.0          return self

File: /tmp/vb_sklearn/sklearn/manifold/isomap.py
Function: transform at line 180
Total time: 0.068086 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   180                                               def transform(self, X):
   181                                                   """Transform X.
   182
   183                                                   This is implemented by linking the points X into the graph of geodesic
   184                                                   distances of the training data. First the `n_neighbors` nearest
   185                                                   neighbors of X are found in the training data, and from these the
   186                                                   shortest geodesic distances from each point in X to each point in
   187                                                   the training data are computed in order to construct the kernel.
   188                                                   The embedding of X is the projection of this kernel onto the
   189                                                   embedding vectors of the training set.
   190
   191                                                   Parameters
   192                                                   ----------
   193                                                   X: array-like, shape (n_samples, n_features)
   194
   195                                                   Returns
   196                                                   -------
   197                                                   X_new: array-like, shape (n_samples, n_components)
   198                                                   """
   199         1        13835  13835.0     20.3          distances, indices = self.nbrs_.kneighbors(X, return_distance=True)
   200
   201                                                   #Create the graph of shortest distances from X to self.training_data_
   202                                                   # via the nearest neighbors of X.
   203                                                   #This can be done as a single array operation, but it potentially
   204                                                   # takes a lot of memory.  To avoid that, use a loop:
   205         1          136    136.0      0.2          G_X = np.zeros((X.shape[0], self.training_data_.shape[0]))
   206       301          983      3.3      1.4          for i in range(X.shape[0]):
   207       300        29486     98.3     43.3              G_X[i] = np.min((self.dist_matrix_[indices[i]]
   208       300        20478     68.3     30.1                               + distances[i][:, None]), 0)
   209
   210         1          256    256.0      0.4          G_X **= 2
   211         1          250    250.0      0.4          G_X *= -0.5
   212
   213         1         2662   2662.0      3.9          return self.kernel_pca_.transform(G_X)

LocallyLinearEmbedding-standard-arpack-minimadelon

Benchmark setup

from sklearn.manifold import LocallyLinearEmbedding
from deps import load_data

kwargs = {'random_state': 0, 'method': 'standard', 'eigen_solver': 'arpack'}
X, y, X_t, y_t = load_data('minimadelon')
obj = LocallyLinearEmbedding(**kwargs)

Benchmark statement

obj.fit(X)

Execution time

_images/LocallyLinearEmbedding-standard-arpack-minimadelon-step0-timing.png

Memory usage

_images/LocallyLinearEmbedding-standard-arpack-minimadelon-step0-memory.png

Additional output

cProfile

         2380 function calls (2379 primitive calls) in 0.034 seconds

Ordered by: cumulative time

ncalls  tottime  percall  cumtime  percall filename:lineno(function)
     1    0.000    0.000    0.034    0.034 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/vbench/benchmark.py:286(f)
     1    0.000    0.000    0.034    0.034 <f>:1(<module>)
     1    0.000    0.000    0.034    0.034 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:633(fit)
     1    0.000    0.000    0.034    0.034 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:613(_fit_transform)
     1    0.000    0.000    0.033    0.033 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:177(locally_linear_embedding)
     1    0.005    0.005    0.025    0.025 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:68(barycenter_kneighbors_graph)
     1    0.004    0.004    0.018    0.018 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:17(barycenter_weights)
    30    0.002    0.000    0.007    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/basic.py:19(solve)
    30    0.006    0.000    0.006    0.000 {numpy.core._dotblas.dot}
     1    0.000    0.000    0.004    0.004 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:106(null_space)
     1    0.000    0.000    0.004    0.004 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:1275(eigsh)
    30    0.000    0.000    0.003    0.000 {map}
    13    0.002    0.000    0.003    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:540(iterate)
    60    0.001    0.000    0.003    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/lib/function_base.py:526(asarray_chkfinite)
  10/9    0.000    0.000    0.002    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/compressed.py:20(__init__)
    30    0.001    0.000    0.002    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:60(get_lapack_funcs)
     1    0.000    0.000    0.002    0.002 /tmp/vb_sklearn/sklearn/neighbors/base.py:156(kneighbors)
     1    0.000    0.000    0.002    0.002 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/construct.py:104(eye)
    10    0.001    0.000    0.002    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/compressed.py:101(check_format)
     1    0.001    0.001    0.001    0.001 {method 'query' of 'sklearn.neighbors.ball_tree.BallTree' objects}
     4    0.000    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:178(asformat)
    30    0.000    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:986(trace)
    30    0.001    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:45(find_best_lapack_type)
   120    0.001    0.000    0.001    0.000 {method 'any' of 'numpy.ndarray' objects}
    12    0.000    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/interface.py:92(matvec)
     1    0.000    0.000    0.001    0.001 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/dia.py:187(tocsr)
     1    0.000    0.000    0.001    0.001 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:229(__mul__)
   143    0.000    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:167(asarray)
     1    0.000    0.000    0.001    0.001 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/compressed.py:276(_mul_sparse_matrix)
   196    0.001    0.000    0.001    0.000 {numpy.core.multiarray.array}
     1    0.000    0.000    0.001    0.001 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:1023(get_OPinv_matvec)
     1    0.000    0.000    0.001    0.001 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:1012(get_inv_matvec)
    12    0.000    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:915(_matvec)
     1    0.000    0.000    0.001    0.001 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/compressed.py:189(__sub__)
    30    0.001    0.000    0.001    0.000 {method 'trace' of 'numpy.ndarray' objects}
    31    0.000    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:1379(sum)
    11    0.000    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/compressed.py:622(prune)
     1    0.000    0.000    0.001    0.001 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/compressed.py:655(_binopt)
     1    0.000    0.000    0.001    0.001 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:910(__init__)
    33    0.001    0.000    0.001    0.000 {method 'sum' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.001    0.001 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/coo.py:281(tocsr)
     3    0.000    0.000    0.001    0.000 /tmp/vb_sklearn/sklearn/neighbors/base.py:578(fit)
     3    0.000    0.000    0.001    0.000 /tmp/vb_sklearn/sklearn/neighbors/base.py:96(_fit)
    12    0.000    0.000    0.000    0.000 {method 'solve' of 'factored_lu' objects}
     4    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:370(__getattr__)
    25    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:116(_isinstance)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/dia.py:195(tocoo)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/construct.py:23(spdiags)
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/csr.py:107(transpose)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/dia.py:73(__init__)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/dsolve/linsolve.py:101(splu)
    19    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:553(isspmatrix)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/csr.py:135(tocsc)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/csc.py:124(tocsr)
    60    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:23(cast_to_lapack_prefix)
     1    0.000    0.000    0.000    0.000 {scipy.sparse.linalg.dsolve._superlu.gstrf}
     5    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:18(upcast)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/coo.py:115(__init__)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:23(safe_asarray)
   110    0.000    0.000    0.000    0.000 {method 'split' of 'str' objects}
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:10(assert_all_finite)
    11    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:96(isshape)
    96    0.000    0.000    0.000    0.000 {isinstance}
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/coo.py:205(_check)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:70(atleast2d_or_csr)
   148    0.000    0.000    0.000    0.000 {issubclass}
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:77(isscalarlike)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/compressed.py:567(sum_duplicates)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:387(__init__)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:124(isdense)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:580(extract)
    14    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numerictypes.py:733(issubdtype)
    17    0.000    0.000    0.000    0.000 {numpy.core.multiarray.empty}
    11    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:50(to_native)
    16    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:237(asanyarray)
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:62(array2d)
    12    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/data.py:17(__init__)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/lib/arraysetops.py:90(unique)
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/compressed.py:613(sort_indices)
    12    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:59(set_shape)
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/compressed.py:581(__get_sorted)
    30    0.000    0.000    0.000    0.000 {method 'sort' of 'list' objects}
    14    0.000    0.000    0.000    0.000 {method 'reshape' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/interface.py:59(__init__)
   194    0.000    0.000    0.000    0.000 {len}
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/shape_base.py:58(atleast_2d)
    12    0.000    0.000    0.000    0.000 {method 'astype' of 'numpy.ndarray' objects}
    30    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:449(isfortran)
    47    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:2116(rank)
    12    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:51(__init__)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:316(__init__)
     4    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:81(isintlike)
    51    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/compressed.py:85(getnnz)
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:181(check_random_state)
    94    0.000    0.000    0.000    0.000 {method 'append' of 'list' objects}
    30    0.000    0.000    0.000    0.000 {range}
    35    0.000    0.000    0.000    0.000 {getattr}
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:1791(ones)
     5    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/coo.py:194(getnnz)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/shape_base.py:6(atleast_1d)
    58    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:81(get_shape)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sparsetools/csc.py:140(csc_matmat_pass2)
    14    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numerictypes.py:665(issubclass_)
    50    0.000    0.000    0.000    0.000 {numpy.core.multiarray.can_cast}
    60    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/misc.py:22(_datacopied)
     1    0.000    0.000    0.000    0.000 {_csc.csc_matmat_pass2}
     1    0.000    0.000    0.000    0.000 {numpy.core.multiarray.concatenate}
     3    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/neighbors/unsupervised.py:85(__init__)
     6    0.000    0.000    0.000    0.000 {numpy.core.multiarray.zeros}
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sparsetools/csr.py:486(csr_minus_csr)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/dia.py:229(isspmatrix_dia)
     2    0.000    0.000    0.000    0.000 {hasattr}
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sparsetools/csc.py:70(csc_matmat_pass1)
     4    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:111(issequence)
     1    0.000    0.000    0.000    0.000 {_csr.csr_minus_csr}
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/compressed.py:90(_set_self)
     2    0.000    0.000    0.000    0.000 {method 'max' of 'numpy.ndarray' objects}
     3    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/neighbors/base.py:77(_init_params)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sparsetools/coo.py:75(coo_tocsr)
     1    0.000    0.000    0.000    0.000 {_csc.csc_matmat_pass1}
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:1574(isscalar)
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sparsetools/csr.py:85(csr_has_sorted_indices)
     5    0.000    0.000    0.000    0.000 {method 'ravel' of 'numpy.ndarray' objects}
    17    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/csr.py:180(_swap)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sparsetools/csr.py:177(csr_tocsc)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sparsetools/csc.py:107(csc_tocsr)
     1    0.000    0.000    0.000    0.000 {method 'rand' of 'mtrand.RandomState' objects}
     2    0.000    0.000    0.000    0.000 {method 'min' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/csc.py:181(isspmatrix_csc)
     2    0.000    0.000    0.000    0.000 {numpy.core.multiarray.arange}
     1    0.000    0.000    0.000    0.000 {_csc.csc_tocsr}
    16    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/csc.py:173(_swap)
     2    0.000    0.000    0.000    0.000 {method 'fill' of 'numpy.ndarray' objects}
    11    0.000    0.000    0.000    0.000 {method 'newbyteorder' of 'numpy.dtype' objects}
     1    0.000    0.000    0.000    0.000 {_csr.csr_tocsc}
    11    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/data.py:20(_get_dtype)
     8    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:54(getdtype)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sparsetools/csr.py:567(csr_sum_duplicates)
     1    0.000    0.000    0.000    0.000 {_coo.coo_tocsr}
     2    0.000    0.000    0.000    0.000 {_csr.csr_has_sorted_indices}
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/csr.py:395(isspmatrix_csr)
     1    0.000    0.000    0.000    0.000 {method 'repeat' of 'numpy.ndarray' objects}
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/compressed.py:597(__set_sorted)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:92(asfptype)
     1    0.000    0.000    0.000    0.000 {_csr.csr_sum_duplicates}
     2    0.000    0.000    0.000    0.000 {min}
     1    0.000    0.000    0.000    0.000 {method 'transpose' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 {method 'flatten' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:57(_single_precision_cast)
     1    0.000    0.000    0.000    0.000 {method 'copy' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 {method 'update' of 'dict' objects}
     1    0.000    0.000    0.000    0.000 {numpy.core.multiarray.empty_like}
     1    0.000    0.000    0.000    0.000 {max}
     1    0.000    0.000    0.000    0.000 {method 'sort' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}

LineProfiler

   Timer unit: 1e-06 s

File: /tmp/vb_sklearn/sklearn/manifold/locally_linear.py
Function: fit at line 633
Total time: 0.034186 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   633                                               def fit(self, X, y=None):
   634                                                   """Compute the embedding vectors for data X
   635
   636                                                   Parameters
   637                                                   ----------
   638                                                   X : array-like of shape [n_samples, n_features]
   639                                                       training set.
   640
   641                                                   Returns
   642                                                   -------
   643                                                   self : returns an instance of self.
   644                                                   """
   645         1        34184  34184.0    100.0          self._fit_transform(X)
   646         1            2      2.0      0.0          return self

File: /tmp/vb_sklearn/sklearn/manifold/locally_linear.py
Function: transform at line 663
Total time: 0 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   663                                               def transform(self, X):
   664                                                   """
   665                                                   Transform new points into embedding space.
   666
   667                                                   Parameters
   668                                                   ----------
   669                                                   X : array-like, shape = [n_samples, n_features]
   670
   671                                                   Returns
   672                                                   -------
   673                                                   X_new : array, shape = [n_samples, n_components]
   674
   675                                                   Notes
   676                                                   -----
   677                                                   Because of scaling performed by this method, it is discouraged to use
   678                                                   it together with methods that are not scale-invariant (like SVMs)
   679                                                   """
   680                                                   X = array2d(X)
   681                                                   ind = self.nbrs_.kneighbors(X, n_neighbors=self.n_neighbors,
   682                                                                               return_distance=False)
   683                                                   weights = barycenter_weights(X, self.nbrs_._fit_X[ind],
   684                                                                                reg=self.reg)
   685                                                   X_new = np.empty((X.shape[0], self.n_components))
   686                                                   for i in range(X.shape[0]):
   687                                                       X_new[i] = np.dot(self.embedding_[ind[i]].T, weights[i])
   688                                                   return X_new

Benchmark statement

obj.transform(X)

Execution time

_images/LocallyLinearEmbedding-standard-arpack-minimadelon-step1-timing.png

Memory usage

_images/LocallyLinearEmbedding-standard-arpack-minimadelon-step1-memory.png

Additional output

cProfile

         1331 function calls in 0.023 seconds

Ordered by: cumulative time

ncalls  tottime  percall  cumtime  percall filename:lineno(function)
     1    0.000    0.000    0.023    0.023 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/vbench/benchmark.py:286(f)
     1    0.000    0.000    0.023    0.023 <f>:1(<module>)
     1    0.005    0.005    0.023    0.023 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:663(transform)
     1    0.003    0.003    0.016    0.016 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:17(barycenter_weights)
    30    0.001    0.000    0.006    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/basic.py:19(solve)
    60    0.005    0.000    0.005    0.000 {numpy.core._dotblas.dot}
    30    0.000    0.000    0.003    0.000 {map}
    60    0.001    0.000    0.002    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/lib/function_base.py:526(asarray_chkfinite)
     1    0.000    0.000    0.002    0.002 /tmp/vb_sklearn/sklearn/neighbors/base.py:156(kneighbors)
     1    0.002    0.002    0.002    0.002 {method 'query' of 'sklearn.neighbors.ball_tree.BallTree' objects}
    30    0.001    0.000    0.002    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:60(get_lapack_funcs)
    30    0.000    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:986(trace)
    30    0.000    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:45(find_best_lapack_type)
   120    0.001    0.000    0.001    0.000 {method 'any' of 'numpy.ndarray' objects}
    30    0.001    0.000    0.001    0.000 {method 'trace' of 'numpy.ndarray' objects}
    95    0.000    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:167(asarray)
    30    0.000    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:1379(sum)
    31    0.000    0.000    0.000    0.000 {method 'sum' of 'numpy.ndarray' objects}
    98    0.000    0.000    0.000    0.000 {numpy.core.multiarray.array}
    60    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:23(cast_to_lapack_prefix)
     3    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:62(array2d)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:70(atleast2d_or_csr)
   120    0.000    0.000    0.000    0.000 {issubclass}
    68    0.000    0.000    0.000    0.000 {method 'split' of 'str' objects}
     4    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:553(isspmatrix)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:10(assert_all_finite)
    34    0.000    0.000    0.000    0.000 {isinstance}
     4    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:116(_isinstance)
    30    0.000    0.000    0.000    0.000 {method 'sort' of 'list' objects}
    30    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:449(isfortran)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/shape_base.py:58(atleast_2d)
    31    0.000    0.000    0.000    0.000 {range}
    93    0.000    0.000    0.000    0.000 {method 'append' of 'list' objects}
    30    0.000    0.000    0.000    0.000 {getattr}
    60    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/misc.py:22(_datacopied)
    69    0.000    0.000    0.000    0.000 {len}
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:237(asanyarray)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:1791(ones)
     3    0.000    0.000    0.000    0.000 {numpy.core.multiarray.empty}
     1    0.000    0.000    0.000    0.000 {method 'fill' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 {method 'transpose' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}

LineProfiler

   Timer unit: 1e-06 s

File: /tmp/vb_sklearn/sklearn/manifold/locally_linear.py
Function: fit at line 633
Total time: 0.034186 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   633                                               def fit(self, X, y=None):
   634                                                   """Compute the embedding vectors for data X
   635
   636                                                   Parameters
   637                                                   ----------
   638                                                   X : array-like of shape [n_samples, n_features]
   639                                                       training set.
   640
   641                                                   Returns
   642                                                   -------
   643                                                   self : returns an instance of self.
   644                                                   """
   645         1        34184  34184.0    100.0          self._fit_transform(X)
   646         1            2      2.0      0.0          return self

File: /tmp/vb_sklearn/sklearn/manifold/locally_linear.py
Function: transform at line 663
Total time: 0.026378 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   663                                               def transform(self, X):
   664                                                   """
   665                                                   Transform new points into embedding space.
   666
   667                                                   Parameters
   668                                                   ----------
   669                                                   X : array-like, shape = [n_samples, n_features]
   670
   671                                                   Returns
   672                                                   -------
   673                                                   X_new : array, shape = [n_samples, n_components]
   674
   675                                                   Notes
   676                                                   -----
   677                                                   Because of scaling performed by this method, it is discouraged to use
   678                                                   it together with methods that are not scale-invariant (like SVMs)
   679                                                   """
   680         1          106    106.0      0.4          X = array2d(X)
   681         1            6      6.0      0.0          ind = self.nbrs_.kneighbors(X, n_neighbors=self.n_neighbors,
   682         1         1775   1775.0      6.7                                      return_distance=False)
   683         1         4165   4165.0     15.8          weights = barycenter_weights(X, self.nbrs_._fit_X[ind],
   684         1        19582  19582.0     74.2                                       reg=self.reg)
   685         1           15     15.0      0.1          X_new = np.empty((X.shape[0], self.n_components))
   686        31           82      2.6      0.3          for i in range(X.shape[0]):
   687        30          645     21.5      2.4              X_new[i] = np.dot(self.embedding_[ind[i]].T, weights[i])
   688         1            2      2.0      0.0          return X_new

LocallyLinearEmbedding-standard-arpack-blobs

Benchmark setup

from sklearn.manifold import LocallyLinearEmbedding
from deps import load_data

kwargs = {'random_state': 0, 'method': 'standard', 'eigen_solver': 'arpack'}
X, y, X_t, y_t = load_data('blobs')
obj = LocallyLinearEmbedding(**kwargs)

Benchmark statement

obj.fit(X)

Execution time

_images/LocallyLinearEmbedding-standard-arpack-blobs-step0-timing.png

Memory usage

_images/LocallyLinearEmbedding-standard-arpack-blobs-step0-memory.png

Additional output

cProfile

         13570 function calls (13569 primitive calls) in 0.130 seconds

Ordered by: cumulative time

ncalls  tottime  percall  cumtime  percall filename:lineno(function)
     1    0.000    0.000    0.130    0.130 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/vbench/benchmark.py:286(f)
     1    0.000    0.000    0.130    0.130 <f>:1(<module>)
     1    0.000    0.000    0.130    0.130 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:633(fit)
     1    0.000    0.000    0.130    0.130 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:613(_fit_transform)
     1    0.000    0.000    0.128    0.128 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:177(locally_linear_embedding)
     1    0.005    0.005    0.113    0.113 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:68(barycenter_kneighbors_graph)
     1    0.026    0.026    0.093    0.093 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:17(barycenter_weights)
   300    0.011    0.000    0.050    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/basic.py:19(solve)
   300    0.002    0.000    0.024    0.000 {map}
   600    0.011    0.000    0.022    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/lib/function_base.py:526(asarray_chkfinite)
     1    0.000    0.000    0.014    0.014 /tmp/vb_sklearn/sklearn/neighbors/base.py:156(kneighbors)
   300    0.004    0.000    0.014    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:60(get_lapack_funcs)
     1    0.014    0.014    0.014    0.014 {method 'query' of 'sklearn.neighbors.ball_tree.BallTree' objects}
     1    0.000    0.000    0.011    0.011 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:106(null_space)
     1    0.000    0.000    0.011    0.011 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:1275(eigsh)
  1200    0.009    0.000    0.009    0.000 {method 'any' of 'numpy.ndarray' objects}
   300    0.004    0.000    0.009    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:45(find_best_lapack_type)
    21    0.004    0.000    0.008    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:540(iterate)
   300    0.001    0.000    0.007    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:986(trace)
   300    0.006    0.000    0.006    0.000 {numpy.core._dotblas.dot}
   961    0.002    0.000    0.005    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:167(asarray)
   301    0.001    0.000    0.005    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:1379(sum)
   300    0.005    0.000    0.005    0.000 {method 'trace' of 'numpy.ndarray' objects}
    20    0.000    0.000    0.004    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/interface.py:92(matvec)
   303    0.003    0.000    0.003    0.000 {method 'sum' of 'numpy.ndarray' objects}
    20    0.000    0.000    0.003    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:915(_matvec)
  1022    0.003    0.000    0.003    0.000 {numpy.core.multiarray.array}
    20    0.003    0.000    0.003    0.000 {method 'solve' of 'factored_lu' objects}
     1    0.000    0.000    0.003    0.003 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:1023(get_OPinv_matvec)
     1    0.000    0.000    0.003    0.003 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:1012(get_inv_matvec)
   600    0.001    0.000    0.002    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:23(cast_to_lapack_prefix)
     1    0.000    0.000    0.002    0.002 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:910(__init__)
  10/9    0.000    0.000    0.002    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/compressed.py:20(__init__)
     1    0.000    0.000    0.002    0.002 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/dsolve/linsolve.py:101(splu)
     1    0.002    0.002    0.002    0.002 {scipy.sparse.linalg.dsolve._superlu.gstrf}
     1    0.000    0.000    0.001    0.001 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/construct.py:104(eye)
     4    0.000    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:178(asformat)
     1    0.000    0.000    0.001    0.001 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:229(__mul__)
    10    0.001    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/compressed.py:101(check_format)
     1    0.000    0.000    0.001    0.001 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/compressed.py:276(_mul_sparse_matrix)
     3    0.000    0.000    0.001    0.000 /tmp/vb_sklearn/sklearn/neighbors/base.py:578(fit)
     3    0.001    0.000    0.001    0.000 /tmp/vb_sklearn/sklearn/neighbors/base.py:96(_fit)
     1    0.000    0.000    0.001    0.001 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/dia.py:187(tocsr)
  1244    0.001    0.000    0.001    0.000 {issubclass}
   650    0.001    0.000    0.001    0.000 {method 'split' of 'str' objects}
   374    0.001    0.000    0.001    0.000 {isinstance}
     1    0.000    0.000    0.001    0.001 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/compressed.py:189(__sub__)
     1    0.000    0.000    0.001    0.001 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/compressed.py:655(_binopt)
   300    0.001    0.000    0.001    0.000 {method 'sort' of 'list' objects}
   300    0.001    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:449(isfortran)
     1    0.000    0.000    0.001    0.001 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/coo.py:281(tocsr)
   904    0.001    0.000    0.001    0.000 {method 'append' of 'list' objects}
    11    0.000    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/compressed.py:622(prune)
     4    0.000    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:370(__getattr__)
     1    0.000    0.000    0.001    0.001 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/dia.py:195(tocoo)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/csc.py:124(tocsr)
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/csr.py:107(transpose)
   300    0.000    0.000    0.000    0.000 {range}
   305    0.000    0.000    0.000    0.000 {getattr}
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/csr.py:135(tocsc)
   600    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/misc.py:22(_datacopied)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/construct.py:23(spdiags)
    25    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:116(_isinstance)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/dia.py:73(__init__)
    19    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:553(isspmatrix)
     5    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:18(upcast)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sparsetools/csc.py:140(csc_matmat_pass2)
     1    0.000    0.000    0.000    0.000 {_csc.csc_matmat_pass2}
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/coo.py:115(__init__)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:23(safe_asarray)
   734    0.000    0.000    0.000    0.000 {len}
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:10(assert_all_finite)
    22    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numerictypes.py:733(issubdtype)
    24    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:237(asanyarray)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:70(atleast2d_or_csr)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sparsetools/csc.py:70(csc_matmat_pass1)
    11    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:96(isshape)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/coo.py:205(_check)
     1    0.000    0.000    0.000    0.000 {_csc.csc_matmat_pass1}
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:387(__init__)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:580(extract)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/compressed.py:567(sum_duplicates)
    12    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:59(set_shape)
    22    0.000    0.000    0.000    0.000 {method 'reshape' of 'numpy.ndarray' objects}
    17    0.000    0.000    0.000    0.000 {numpy.core.multiarray.empty}
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sparsetools/csc.py:107(csc_tocsr)
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:62(array2d)
     1    0.000    0.000    0.000    0.000 {_csc.csc_tocsr}
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/compressed.py:613(sort_indices)
    11    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:50(to_native)
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/compressed.py:581(__get_sorted)
    20    0.000    0.000    0.000    0.000 {method 'astype' of 'numpy.ndarray' objects}
    12    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/data.py:17(__init__)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/lib/arraysetops.py:90(unique)
    22    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numerictypes.py:665(issubclass_)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/interface.py:59(__init__)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:316(__init__)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sparsetools/csr.py:486(csr_minus_csr)
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:77(isscalarlike)
     1    0.000    0.000    0.000    0.000 {_csr.csr_minus_csr}
    47    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:2116(rank)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/shape_base.py:58(atleast_2d)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/shape_base.py:6(atleast_1d)
    12    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:51(__init__)
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:181(check_random_state)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:124(isdense)
    51    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/compressed.py:85(getnnz)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sparsetools/csr.py:177(csr_tocsc)
     5    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/coo.py:194(getnnz)
     6    0.000    0.000    0.000    0.000 {numpy.core.multiarray.zeros}
     4    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:81(isintlike)
    50    0.000    0.000    0.000    0.000 {numpy.core.multiarray.can_cast}
     3    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/neighbors/unsupervised.py:85(__init__)
     1    0.000    0.000    0.000    0.000 {_csr.csr_tocsc}
     1    0.000    0.000    0.000    0.000 {numpy.core.multiarray.concatenate}
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sparsetools/csr.py:85(csr_has_sorted_indices)
    58    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:81(get_shape)
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:1791(ones)
     2    0.000    0.000    0.000    0.000 {hasattr}
     5    0.000    0.000    0.000    0.000 {method 'ravel' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 {method 'rand' of 'mtrand.RandomState' objects}
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sparsetools/coo.py:75(coo_tocsr)
     2    0.000    0.000    0.000    0.000 {method 'max' of 'numpy.ndarray' objects}
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/compressed.py:90(_set_self)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/dia.py:229(isspmatrix_dia)
     3    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/neighbors/base.py:77(_init_params)
     2    0.000    0.000    0.000    0.000 {_csr.csr_has_sorted_indices}
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:1574(isscalar)
     4    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:111(issequence)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/csc.py:181(isspmatrix_csc)
     2    0.000    0.000    0.000    0.000 {numpy.core.multiarray.arange}
     2    0.000    0.000    0.000    0.000 {method 'min' of 'numpy.ndarray' objects}
    11    0.000    0.000    0.000    0.000 {method 'newbyteorder' of 'numpy.dtype' objects}
    17    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/csr.py:180(_swap)
     1    0.000    0.000    0.000    0.000 {_coo.coo_tocsr}
     8    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:54(getdtype)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/csr.py:395(isspmatrix_csr)
    16    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/csc.py:173(_swap)
     2    0.000    0.000    0.000    0.000 {method 'fill' of 'numpy.ndarray' objects}
    11    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/data.py:20(_get_dtype)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sparsetools/csr.py:567(csr_sum_duplicates)
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/compressed.py:597(__set_sorted)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:92(asfptype)
     1    0.000    0.000    0.000    0.000 {_csr.csr_sum_duplicates}
     1    0.000    0.000    0.000    0.000 {method 'repeat' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 {method 'flatten' of 'numpy.ndarray' objects}
     2    0.000    0.000    0.000    0.000 {min}
     1    0.000    0.000    0.000    0.000 {method 'copy' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 {numpy.core.multiarray.empty_like}
     1    0.000    0.000    0.000    0.000 {method 'transpose' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:57(_single_precision_cast)
     1    0.000    0.000    0.000    0.000 {method 'update' of 'dict' objects}
     1    0.000    0.000    0.000    0.000 {max}
     1    0.000    0.000    0.000    0.000 {method 'sort' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}

LineProfiler

   Timer unit: 1e-06 s

File: /tmp/vb_sklearn/sklearn/manifold/locally_linear.py
Function: fit at line 633
Total time: 0.149039 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   633                                               def fit(self, X, y=None):
   634                                                   """Compute the embedding vectors for data X
   635
   636                                                   Parameters
   637                                                   ----------
   638                                                   X : array-like of shape [n_samples, n_features]
   639                                                       training set.
   640
   641                                                   Returns
   642                                                   -------
   643                                                   self : returns an instance of self.
   644                                                   """
   645         1       149036 149036.0    100.0          self._fit_transform(X)
   646         1            3      3.0      0.0          return self

File: /tmp/vb_sklearn/sklearn/manifold/locally_linear.py
Function: transform at line 663
Total time: 0 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   663                                               def transform(self, X):
   664                                                   """
   665                                                   Transform new points into embedding space.
   666
   667                                                   Parameters
   668                                                   ----------
   669                                                   X : array-like, shape = [n_samples, n_features]
   670
   671                                                   Returns
   672                                                   -------
   673                                                   X_new : array, shape = [n_samples, n_components]
   674
   675                                                   Notes
   676                                                   -----
   677                                                   Because of scaling performed by this method, it is discouraged to use
   678                                                   it together with methods that are not scale-invariant (like SVMs)
   679                                                   """
   680                                                   X = array2d(X)
   681                                                   ind = self.nbrs_.kneighbors(X, n_neighbors=self.n_neighbors,
   682                                                                               return_distance=False)
   683                                                   weights = barycenter_weights(X, self.nbrs_._fit_X[ind],
   684                                                                                reg=self.reg)
   685                                                   X_new = np.empty((X.shape[0], self.n_components))
   686                                                   for i in range(X.shape[0]):
   687                                                       X_new[i] = np.dot(self.embedding_[ind[i]].T, weights[i])
   688                                                   return X_new

Benchmark statement

obj.transform(X)

Execution time

_images/LocallyLinearEmbedding-standard-arpack-blobs-step1-timing.png

Memory usage

_images/LocallyLinearEmbedding-standard-arpack-blobs-step1-memory.png

Additional output

cProfile

         12671 function calls in 0.115 seconds

Ordered by: cumulative time

ncalls  tottime  percall  cumtime  percall filename:lineno(function)
     1    0.000    0.000    0.115    0.115 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/vbench/benchmark.py:286(f)
     1    0.000    0.000    0.115    0.115 <f>:1(<module>)
     1    0.009    0.009    0.115    0.115 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:663(transform)
     1    0.025    0.025    0.091    0.091 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:17(barycenter_weights)
   300    0.011    0.000    0.048    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/basic.py:19(solve)
   300    0.002    0.000    0.023    0.000 {map}
   600    0.010    0.000    0.021    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/lib/function_base.py:526(asarray_chkfinite)
   300    0.004    0.000    0.014    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:60(get_lapack_funcs)
     1    0.000    0.000    0.014    0.014 /tmp/vb_sklearn/sklearn/neighbors/base.py:156(kneighbors)
     1    0.014    0.014    0.014    0.014 {method 'query' of 'sklearn.neighbors.ball_tree.BallTree' objects}
   300    0.004    0.000    0.009    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:45(find_best_lapack_type)
  1200    0.008    0.000    0.008    0.000 {method 'any' of 'numpy.ndarray' objects}
   300    0.001    0.000    0.007    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:986(trace)
   600    0.007    0.000    0.007    0.000 {numpy.core._dotblas.dot}
   300    0.001    0.000    0.005    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:1379(sum)
   905    0.002    0.000    0.005    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:167(asarray)
   300    0.004    0.000    0.004    0.000 {method 'trace' of 'numpy.ndarray' objects}
   301    0.003    0.000    0.003    0.000 {method 'sum' of 'numpy.ndarray' objects}
   908    0.003    0.000    0.003    0.000 {numpy.core.multiarray.array}
   600    0.001    0.000    0.002    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:23(cast_to_lapack_prefix)
  1200    0.001    0.000    0.001    0.000 {issubclass}
   608    0.001    0.000    0.001    0.000 {method 'split' of 'str' objects}
   304    0.001    0.000    0.001    0.000 {isinstance}
   300    0.001    0.000    0.001    0.000 {method 'sort' of 'list' objects}
   300    0.001    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:449(isfortran)
   903    0.000    0.000    0.000    0.000 {method 'append' of 'list' objects}
   301    0.000    0.000    0.000    0.000 {range}
   600    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/misc.py:22(_datacopied)
   300    0.000    0.000    0.000    0.000 {getattr}
   609    0.000    0.000    0.000    0.000 {len}
     3    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:62(array2d)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:70(atleast2d_or_csr)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:10(assert_all_finite)
     4    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:553(isspmatrix)
     4    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:116(_isinstance)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/shape_base.py:58(atleast_2d)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:237(asanyarray)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:1791(ones)
     3    0.000    0.000    0.000    0.000 {numpy.core.multiarray.empty}
     1    0.000    0.000    0.000    0.000 {method 'fill' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 {method 'transpose' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}

LineProfiler

   Timer unit: 1e-06 s

File: /tmp/vb_sklearn/sklearn/manifold/locally_linear.py
Function: fit at line 633
Total time: 0.149039 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   633                                               def fit(self, X, y=None):
   634                                                   """Compute the embedding vectors for data X
   635
   636                                                   Parameters
   637                                                   ----------
   638                                                   X : array-like of shape [n_samples, n_features]
   639                                                       training set.
   640
   641                                                   Returns
   642                                                   -------
   643                                                   self : returns an instance of self.
   644                                                   """
   645         1       149036 149036.0    100.0          self._fit_transform(X)
   646         1            3      3.0      0.0          return self

File: /tmp/vb_sklearn/sklearn/manifold/locally_linear.py
Function: transform at line 663
Total time: 0.137573 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   663                                               def transform(self, X):
   664                                                   """
   665                                                   Transform new points into embedding space.
   666
   667                                                   Parameters
   668                                                   ----------
   669                                                   X : array-like, shape = [n_samples, n_features]
   670
   671                                                   Returns
   672                                                   -------
   673                                                   X_new : array, shape = [n_samples, n_components]
   674
   675                                                   Notes
   676                                                   -----
   677                                                   Because of scaling performed by this method, it is discouraged to use
   678                                                   it together with methods that are not scale-invariant (like SVMs)
   679                                                   """
   680         1           61     61.0      0.0          X = array2d(X)
   681         1            6      6.0      0.0          ind = self.nbrs_.kneighbors(X, n_neighbors=self.n_neighbors,
   682         1        13764  13764.0     10.0                                      return_distance=False)
   683         1         4608   4608.0      3.3          weights = barycenter_weights(X, self.nbrs_._fit_X[ind],
   684         1       112704 112704.0     81.9                                       reg=self.reg)
   685         1           11     11.0      0.0          X_new = np.empty((X.shape[0], self.n_components))
   686       301          709      2.4      0.5          for i in range(X.shape[0]):
   687       300         5707     19.0      4.1              X_new[i] = np.dot(self.embedding_[ind[i]].T, weights[i])
   688         1            3      3.0      0.0          return X_new

LocallyLinearEmbedding-hessian-dense-minimadelon

Benchmark setup

from sklearn.manifold import LocallyLinearEmbedding
from deps import load_data

kwargs = {'n_neighbors': 6, 'random_state': 0, 'method': 'hessian', 'eigen_solver': 'dense'}
X, y, X_t, y_t = load_data('minimadelon')
obj = LocallyLinearEmbedding(**kwargs)

Benchmark statement

obj.fit(X)

Execution time

_images/LocallyLinearEmbedding-hessian-dense-minimadelon-step0-timing.png

Memory usage

_images/LocallyLinearEmbedding-hessian-dense-minimadelon-step0-memory.png

Additional output

cProfile

         3173 function calls in 0.027 seconds

Ordered by: cumulative time

ncalls  tottime  percall  cumtime  percall filename:lineno(function)
     1    0.000    0.000    0.027    0.027 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/vbench/benchmark.py:286(f)
     1    0.000    0.000    0.027    0.027 <f>:1(<module>)
     1    0.000    0.000    0.027    0.027 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:633(fit)
     1    0.000    0.000    0.027    0.027 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:613(_fit_transform)
     1    0.007    0.007    0.026    0.026 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:177(locally_linear_embedding)
    30    0.002    0.000    0.007    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/decomp_qr.py:16(qr)
    31    0.003    0.000    0.005    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/decomp.py:196(eigh)
    60    0.003    0.000    0.003    0.000 {numpy.core._dotblas.dot}
    91    0.001    0.000    0.002    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:60(get_lapack_funcs)
    61    0.001    0.000    0.002    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/lib/function_base.py:526(asarray_chkfinite)
    30    0.001    0.000    0.002    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/special_matrices.py:98(triu)
   121    0.001    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:45(find_best_lapack_type)
    30    0.001    0.000    0.001    0.000 {method 'mean' of 'numpy.ndarray' objects}
    30    0.000    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/special_matrices.py:20(tri)
     1    0.000    0.000    0.001    0.001 /tmp/vb_sklearn/sklearn/neighbors/base.py:156(kneighbors)
     1    0.001    0.001    0.001    0.001 {method 'query' of 'sklearn.neighbors.ball_tree.BallTree' objects}
   122    0.001    0.000    0.001    0.000 {method 'any' of 'numpy.ndarray' objects}
   186    0.000    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:167(asarray)
    30    0.000    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/lib/function_base.py:3211(meshgrid)
    30    0.000    0.000    0.000    0.000 {method 'outer' of 'numpy.ufunc' objects}
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:106(null_space)
    33    0.000    0.000    0.000    0.000 {method 'sum' of 'numpy.ndarray' objects}
   188    0.000    0.000    0.000    0.000 {numpy.core.multiarray.array}
   121    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:23(cast_to_lapack_prefix)
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/neighbors/base.py:578(fit)
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/neighbors/base.py:96(_fit)
    60    0.000    0.000    0.000    0.000 {method 'astype' of 'numpy.generic' objects}
   152    0.000    0.000    0.000    0.000 {getattr}
    60    0.000    0.000    0.000    0.000 {method 'repeat' of 'numpy.ndarray' objects}
   273    0.000    0.000    0.000    0.000 {issubclass}
    31    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/lib/type_check.py:235(iscomplexobj)
    30    0.000    0.000    0.000    0.000 {abs}
   192    0.000    0.000    0.000    0.000 {method 'split' of 'str' objects}
   152    0.000    0.000    0.000    0.000 {range}
    60    0.000    0.000    0.000    0.000 {numpy.core.multiarray.arange}
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:23(safe_asarray)
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:10(assert_all_finite)
   121    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:449(isfortran)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:70(atleast2d_or_csr)
   214    0.000    0.000    0.000    0.000 {method 'append' of 'list' objects}
    60    0.000    0.000    0.000    0.000 {method 'reshape' of 'numpy.ndarray' objects}
    31    0.000    0.000    0.000    0.000 {numpy.core.multiarray.empty}
     5    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:553(isspmatrix)
    30    0.000    0.000    0.000    0.000 {method 'astype' of 'numpy.ndarray' objects}
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:62(array2d)
    30    0.000    0.000    0.000    0.000 {numpy.core.multiarray.where}
   121    0.000    0.000    0.000    0.000 {method 'sort' of 'list' objects}
   248    0.000    0.000    0.000    0.000 {len}
     5    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:116(_isinstance)
    60    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/misc.py:22(_datacopied)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:181(check_random_state)
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/shape_base.py:58(atleast_2d)
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/neighbors/unsupervised.py:85(__init__)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:1379(sum)
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/neighbors/base.py:77(_init_params)
    11    0.000    0.000    0.000    0.000 {isinstance}
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:598(argsort)
     1    0.000    0.000    0.000    0.000 {numpy.core.multiarray.zeros}
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:237(asanyarray)
     1    0.000    0.000    0.000    0.000 {method 'argsort' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 {hasattr}
     1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}

LineProfiler

   Timer unit: 1e-06 s

File: /tmp/vb_sklearn/sklearn/manifold/locally_linear.py
Function: fit at line 633
Total time: 0.030587 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   633                                               def fit(self, X, y=None):
   634                                                   """Compute the embedding vectors for data X
   635
   636                                                   Parameters
   637                                                   ----------
   638                                                   X : array-like of shape [n_samples, n_features]
   639                                                       training set.
   640
   641                                                   Returns
   642                                                   -------
   643                                                   self : returns an instance of self.
   644                                                   """
   645         1        30585  30585.0    100.0          self._fit_transform(X)
   646         1            2      2.0      0.0          return self

File: /tmp/vb_sklearn/sklearn/manifold/locally_linear.py
Function: transform at line 663
Total time: 0 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   663                                               def transform(self, X):
   664                                                   """
   665                                                   Transform new points into embedding space.
   666
   667                                                   Parameters
   668                                                   ----------
   669                                                   X : array-like, shape = [n_samples, n_features]
   670
   671                                                   Returns
   672                                                   -------
   673                                                   X_new : array, shape = [n_samples, n_components]
   674
   675                                                   Notes
   676                                                   -----
   677                                                   Because of scaling performed by this method, it is discouraged to use
   678                                                   it together with methods that are not scale-invariant (like SVMs)
   679                                                   """
   680                                                   X = array2d(X)
   681                                                   ind = self.nbrs_.kneighbors(X, n_neighbors=self.n_neighbors,
   682                                                                               return_distance=False)
   683                                                   weights = barycenter_weights(X, self.nbrs_._fit_X[ind],
   684                                                                                reg=self.reg)
   685                                                   X_new = np.empty((X.shape[0], self.n_components))
   686                                                   for i in range(X.shape[0]):
   687                                                       X_new[i] = np.dot(self.embedding_[ind[i]].T, weights[i])
   688                                                   return X_new

Benchmark statement

obj.transform(X)

Execution time

_images/LocallyLinearEmbedding-hessian-dense-minimadelon-step1-timing.png

Memory usage

_images/LocallyLinearEmbedding-hessian-dense-minimadelon-step1-memory.png

Additional output

cProfile

         1331 function calls in 0.013 seconds

Ordered by: cumulative time

ncalls  tottime  percall  cumtime  percall filename:lineno(function)
     1    0.000    0.000    0.013    0.013 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/vbench/benchmark.py:286(f)
     1    0.000    0.000    0.013    0.013 <f>:1(<module>)
     1    0.003    0.003    0.013    0.013 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:663(transform)
     1    0.002    0.002    0.009    0.009 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:17(barycenter_weights)
    30    0.001    0.000    0.003    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/basic.py:19(solve)
    60    0.003    0.000    0.003    0.000 {numpy.core._dotblas.dot}
    30    0.000    0.000    0.001    0.000 {map}
    60    0.001    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/lib/function_base.py:526(asarray_chkfinite)
     1    0.000    0.000    0.001    0.001 /tmp/vb_sklearn/sklearn/neighbors/base.py:156(kneighbors)
    30    0.000    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:60(get_lapack_funcs)
     1    0.001    0.001    0.001    0.001 {method 'query' of 'sklearn.neighbors.ball_tree.BallTree' objects}
    30    0.000    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:986(trace)
    30    0.000    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:45(find_best_lapack_type)
   120    0.000    0.000    0.000    0.000 {method 'any' of 'numpy.ndarray' objects}
    30    0.000    0.000    0.000    0.000 {method 'trace' of 'numpy.ndarray' objects}
    95    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:167(asarray)
    30    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:1379(sum)
    31    0.000    0.000    0.000    0.000 {method 'sum' of 'numpy.ndarray' objects}
    98    0.000    0.000    0.000    0.000 {numpy.core.multiarray.array}
    60    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:23(cast_to_lapack_prefix)
     3    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:62(array2d)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:70(atleast2d_or_csr)
   120    0.000    0.000    0.000    0.000 {issubclass}
    68    0.000    0.000    0.000    0.000 {method 'split' of 'str' objects}
     3    0.000    0.000    0.000    0.000 {numpy.core.multiarray.empty}
    34    0.000    0.000    0.000    0.000 {isinstance}
    93    0.000    0.000    0.000    0.000 {method 'append' of 'list' objects}
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:10(assert_all_finite)
    30    0.000    0.000    0.000    0.000 {method 'sort' of 'list' objects}
     4    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:553(isspmatrix)
    30    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:449(isfortran)
     4    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:116(_isinstance)
    31    0.000    0.000    0.000    0.000 {range}
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/shape_base.py:58(atleast_2d)
    60    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/misc.py:22(_datacopied)
    30    0.000    0.000    0.000    0.000 {getattr}
    69    0.000    0.000    0.000    0.000 {len}
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:237(asanyarray)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:1791(ones)
     1    0.000    0.000    0.000    0.000 {method 'fill' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 {method 'transpose' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}

LineProfiler

   Timer unit: 1e-06 s

File: /tmp/vb_sklearn/sklearn/manifold/locally_linear.py
Function: fit at line 633
Total time: 0.030587 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   633                                               def fit(self, X, y=None):
   634                                                   """Compute the embedding vectors for data X
   635
   636                                                   Parameters
   637                                                   ----------
   638                                                   X : array-like of shape [n_samples, n_features]
   639                                                       training set.
   640
   641                                                   Returns
   642                                                   -------
   643                                                   self : returns an instance of self.
   644                                                   """
   645         1        30585  30585.0    100.0          self._fit_transform(X)
   646         1            2      2.0      0.0          return self

File: /tmp/vb_sklearn/sklearn/manifold/locally_linear.py
Function: transform at line 663
Total time: 0.014017 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   663                                               def transform(self, X):
   664                                                   """
   665                                                   Transform new points into embedding space.
   666
   667                                                   Parameters
   668                                                   ----------
   669                                                   X : array-like, shape = [n_samples, n_features]
   670
   671                                                   Returns
   672                                                   -------
   673                                                   X_new : array, shape = [n_samples, n_components]
   674
   675                                                   Notes
   676                                                   -----
   677                                                   Because of scaling performed by this method, it is discouraged to use
   678                                                   it together with methods that are not scale-invariant (like SVMs)
   679                                                   """
   680         1           35     35.0      0.2          X = array2d(X)
   681         1            2      2.0      0.0          ind = self.nbrs_.kneighbors(X, n_neighbors=self.n_neighbors,
   682         1          938    938.0      6.7                                      return_distance=False)
   683         1         2792   2792.0     19.9          weights = barycenter_weights(X, self.nbrs_._fit_X[ind],
   684         1         9868   9868.0     70.4                                       reg=self.reg)
   685         1            5      5.0      0.0          X_new = np.empty((X.shape[0], self.n_components))
   686        31           44      1.4      0.3          for i in range(X.shape[0]):
   687        30          332     11.1      2.4              X_new[i] = np.dot(self.embedding_[ind[i]].T, weights[i])
   688         1            1      1.0      0.0          return X_new

LocallyLinearEmbedding-hessian-dense-blobs

Benchmark setup

from sklearn.manifold import LocallyLinearEmbedding
from deps import load_data

kwargs = {'n_neighbors': 6, 'random_state': 0, 'method': 'hessian', 'eigen_solver': 'dense'}
X, y, X_t, y_t = load_data('blobs')
obj = LocallyLinearEmbedding(**kwargs)

Benchmark statement

obj.fit(X)

Execution time

_images/LocallyLinearEmbedding-hessian-dense-blobs-step0-timing.png

Memory usage

_images/LocallyLinearEmbedding-hessian-dense-blobs-step0-memory.png

Additional output

cProfile

         30713 function calls in 0.373 seconds

Ordered by: cumulative time

ncalls  tottime  percall  cumtime  percall filename:lineno(function)
     1    0.000    0.000    0.373    0.373 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/vbench/benchmark.py:286(f)
     1    0.000    0.000    0.373    0.373 <f>:1(<module>)
     1    0.000    0.000    0.373    0.373 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:633(fit)
     1    0.000    0.000    0.373    0.373 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:613(_fit_transform)
     1    0.074    0.074    0.371    0.371 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:177(locally_linear_embedding)
   301    0.096    0.000    0.130    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/decomp.py:196(eigh)
   300    0.036    0.000    0.115    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/decomp_qr.py:16(qr)
     1    0.000    0.000    0.051    0.051 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:106(null_space)
   901    0.013    0.000    0.037    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:60(get_lapack_funcs)
   601    0.016    0.000    0.031    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/lib/function_base.py:526(asarray_chkfinite)
   300    0.010    0.000    0.029    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/special_matrices.py:98(triu)
  1201    0.013    0.000    0.024    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:45(find_best_lapack_type)
   300    0.006    0.000    0.017    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/special_matrices.py:20(tri)
     1    0.000    0.000    0.015    0.015 /tmp/vb_sklearn/sklearn/neighbors/base.py:156(kneighbors)
     1    0.014    0.014    0.014    0.014 {method 'query' of 'sklearn.neighbors.ball_tree.BallTree' objects}
  1202    0.011    0.000    0.011    0.000 {method 'any' of 'numpy.ndarray' objects}
   300    0.003    0.000    0.011    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/lib/function_base.py:3211(meshgrid)
  1806    0.004    0.000    0.010    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:167(asarray)
   600    0.010    0.000    0.010    0.000 {numpy.core._dotblas.dot}
   300    0.009    0.000    0.009    0.000 {method 'mean' of 'numpy.ndarray' objects}
   300    0.008    0.000    0.008    0.000 {method 'outer' of 'numpy.ufunc' objects}
  1201    0.003    0.000    0.006    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:23(cast_to_lapack_prefix)
  1808    0.005    0.000    0.005    0.000 {numpy.core.multiarray.array}
   600    0.004    0.000    0.004    0.000 {method 'astype' of 'numpy.generic' objects}
   303    0.004    0.000    0.004    0.000 {method 'sum' of 'numpy.ndarray' objects}
  1502    0.003    0.000    0.003    0.000 {getattr}
   600    0.003    0.000    0.003    0.000 {method 'repeat' of 'numpy.ndarray' objects}
   301    0.001    0.000    0.003    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/lib/type_check.py:235(iscomplexobj)
  2703    0.003    0.000    0.003    0.000 {issubclass}
   300    0.003    0.000    0.003    0.000 {abs}
   600    0.003    0.000    0.003    0.000 {numpy.core.multiarray.arange}
  1502    0.002    0.000    0.002    0.000 {range}
  1812    0.002    0.000    0.002    0.000 {method 'split' of 'str' objects}
  1201    0.002    0.000    0.002    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:449(isfortran)
   600    0.001    0.000    0.001    0.000 {method 'reshape' of 'numpy.ndarray' objects}
  2104    0.001    0.000    0.001    0.000 {method 'append' of 'list' objects}
     2    0.000    0.000    0.001    0.001 /tmp/vb_sklearn/sklearn/neighbors/base.py:578(fit)
     2    0.001    0.001    0.001    0.001 /tmp/vb_sklearn/sklearn/neighbors/base.py:96(_fit)
   301    0.001    0.000    0.001    0.000 {numpy.core.multiarray.empty}
   300    0.001    0.000    0.001    0.000 {method 'astype' of 'numpy.ndarray' objects}
  1201    0.001    0.000    0.001    0.000 {method 'sort' of 'list' objects}
   300    0.001    0.000    0.001    0.000 {numpy.core.multiarray.where}
  2408    0.001    0.000    0.001    0.000 {len}
   600    0.001    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/misc.py:22(_datacopied)
     1    0.000    0.000    0.000    0.000 {numpy.core.multiarray.zeros}
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:23(safe_asarray)
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:10(assert_all_finite)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:70(atleast2d_or_csr)
     5    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:553(isspmatrix)
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:62(array2d)
     5    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:116(_isinstance)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:181(check_random_state)
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/shape_base.py:58(atleast_2d)
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/neighbors/unsupervised.py:85(__init__)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:1379(sum)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:598(argsort)
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/neighbors/base.py:77(_init_params)
    11    0.000    0.000    0.000    0.000 {isinstance}
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:237(asanyarray)
     1    0.000    0.000    0.000    0.000 {method 'argsort' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 {hasattr}
     1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}

LineProfiler

   Timer unit: 1e-06 s

File: /tmp/vb_sklearn/sklearn/manifold/locally_linear.py
Function: fit at line 633
Total time: 0.366184 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   633                                               def fit(self, X, y=None):
   634                                                   """Compute the embedding vectors for data X
   635
   636                                                   Parameters
   637                                                   ----------
   638                                                   X : array-like of shape [n_samples, n_features]
   639                                                       training set.
   640
   641                                                   Returns
   642                                                   -------
   643                                                   self : returns an instance of self.
   644                                                   """
   645         1       366182 366182.0    100.0          self._fit_transform(X)
   646         1            2      2.0      0.0          return self

File: /tmp/vb_sklearn/sklearn/manifold/locally_linear.py
Function: transform at line 663
Total time: 0 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   663                                               def transform(self, X):
   664                                                   """
   665                                                   Transform new points into embedding space.
   666
   667                                                   Parameters
   668                                                   ----------
   669                                                   X : array-like, shape = [n_samples, n_features]
   670
   671                                                   Returns
   672                                                   -------
   673                                                   X_new : array, shape = [n_samples, n_components]
   674
   675                                                   Notes
   676                                                   -----
   677                                                   Because of scaling performed by this method, it is discouraged to use
   678                                                   it together with methods that are not scale-invariant (like SVMs)
   679                                                   """
   680                                                   X = array2d(X)
   681                                                   ind = self.nbrs_.kneighbors(X, n_neighbors=self.n_neighbors,
   682                                                                               return_distance=False)
   683                                                   weights = barycenter_weights(X, self.nbrs_._fit_X[ind],
   684                                                                                reg=self.reg)
   685                                                   X_new = np.empty((X.shape[0], self.n_components))
   686                                                   for i in range(X.shape[0]):
   687                                                       X_new[i] = np.dot(self.embedding_[ind[i]].T, weights[i])
   688                                                   return X_new

Benchmark statement

obj.transform(X)

Execution time

_images/LocallyLinearEmbedding-hessian-dense-blobs-step1-timing.png

Memory usage

_images/LocallyLinearEmbedding-hessian-dense-blobs-step1-memory.png

Additional output

cProfile

         12671 function calls in 0.116 seconds

Ordered by: cumulative time

ncalls  tottime  percall  cumtime  percall filename:lineno(function)
     1    0.000    0.000    0.116    0.116 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/vbench/benchmark.py:286(f)
     1    0.000    0.000    0.116    0.116 <f>:1(<module>)
     1    0.009    0.009    0.116    0.116 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:663(transform)
     1    0.025    0.025    0.092    0.092 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:17(barycenter_weights)
   300    0.011    0.000    0.049    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/basic.py:19(solve)
   300    0.002    0.000    0.023    0.000 {map}
   600    0.011    0.000    0.022    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/lib/function_base.py:526(asarray_chkfinite)
   300    0.004    0.000    0.014    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:60(get_lapack_funcs)
     1    0.000    0.000    0.014    0.014 /tmp/vb_sklearn/sklearn/neighbors/base.py:156(kneighbors)
     1    0.014    0.014    0.014    0.014 {method 'query' of 'sklearn.neighbors.ball_tree.BallTree' objects}
   300    0.004    0.000    0.009    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:45(find_best_lapack_type)
  1200    0.008    0.000    0.008    0.000 {method 'any' of 'numpy.ndarray' objects}
   300    0.001    0.000    0.007    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:986(trace)
   600    0.007    0.000    0.007    0.000 {numpy.core._dotblas.dot}
   300    0.001    0.000    0.005    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:1379(sum)
   905    0.002    0.000    0.005    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:167(asarray)
   300    0.004    0.000    0.004    0.000 {method 'trace' of 'numpy.ndarray' objects}
   301    0.003    0.000    0.003    0.000 {method 'sum' of 'numpy.ndarray' objects}
   908    0.003    0.000    0.003    0.000 {numpy.core.multiarray.array}
   600    0.001    0.000    0.003    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:23(cast_to_lapack_prefix)
  1200    0.001    0.000    0.001    0.000 {issubclass}
   608    0.001    0.000    0.001    0.000 {method 'split' of 'str' objects}
   304    0.001    0.000    0.001    0.000 {isinstance}
   300    0.001    0.000    0.001    0.000 {method 'sort' of 'list' objects}
   300    0.001    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:449(isfortran)
   301    0.000    0.000    0.000    0.000 {range}
   903    0.000    0.000    0.000    0.000 {method 'append' of 'list' objects}
   600    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/misc.py:22(_datacopied)
   300    0.000    0.000    0.000    0.000 {getattr}
   609    0.000    0.000    0.000    0.000 {len}
     3    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:62(array2d)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:70(atleast2d_or_csr)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:10(assert_all_finite)
     4    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:553(isspmatrix)
     4    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:116(_isinstance)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/shape_base.py:58(atleast_2d)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:237(asanyarray)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:1791(ones)
     3    0.000    0.000    0.000    0.000 {numpy.core.multiarray.empty}
     1    0.000    0.000    0.000    0.000 {method 'fill' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 {method 'transpose' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}

LineProfiler

   Timer unit: 1e-06 s

File: /tmp/vb_sklearn/sklearn/manifold/locally_linear.py
Function: fit at line 633
Total time: 0.366184 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   633                                               def fit(self, X, y=None):
   634                                                   """Compute the embedding vectors for data X
   635
   636                                                   Parameters
   637                                                   ----------
   638                                                   X : array-like of shape [n_samples, n_features]
   639                                                       training set.
   640
   641                                                   Returns
   642                                                   -------
   643                                                   self : returns an instance of self.
   644                                                   """
   645         1       366182 366182.0    100.0          self._fit_transform(X)
   646         1            2      2.0      0.0          return self

File: /tmp/vb_sklearn/sklearn/manifold/locally_linear.py
Function: transform at line 663
Total time: 0.14307 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   663                                               def transform(self, X):
   664                                                   """
   665                                                   Transform new points into embedding space.
   666
   667                                                   Parameters
   668                                                   ----------
   669                                                   X : array-like, shape = [n_samples, n_features]
   670
   671                                                   Returns
   672                                                   -------
   673                                                   X_new : array, shape = [n_samples, n_components]
   674
   675                                                   Notes
   676                                                   -----
   677                                                   Because of scaling performed by this method, it is discouraged to use
   678                                                   it together with methods that are not scale-invariant (like SVMs)
   679                                                   """
   680         1           49     49.0      0.0          X = array2d(X)
   681         1            3      3.0      0.0          ind = self.nbrs_.kneighbors(X, n_neighbors=self.n_neighbors,
   682         1         7895   7895.0      5.5                                      return_distance=False)
   683         1         2932   2932.0      2.0          weights = barycenter_weights(X, self.nbrs_._fit_X[ind],
   684         1       128502 128502.0     89.8                                       reg=self.reg)
   685         1            7      7.0      0.0          X_new = np.empty((X.shape[0], self.n_components))
   686       301          393      1.3      0.3          for i in range(X.shape[0]):
   687       300         3288     11.0      2.3              X_new[i] = np.dot(self.embedding_[ind[i]].T, weights[i])
   688         1            1      1.0      0.0          return X_new

LocallyLinearEmbedding-modified-dense-minimadelon

Benchmark setup

from sklearn.manifold import LocallyLinearEmbedding
from deps import load_data

kwargs = {'random_state': 0, 'method': 'modified', 'eigen_solver': 'dense'}
X, y, X_t, y_t = load_data('minimadelon')
obj = LocallyLinearEmbedding(**kwargs)

Benchmark statement

obj.fit(X)

Execution time

_images/LocallyLinearEmbedding-modified-dense-minimadelon-step0-timing.png

Memory usage

_images/LocallyLinearEmbedding-modified-dense-minimadelon-step0-memory.png

Additional output

cProfile

         2299 function calls in 0.038 seconds

Ordered by: cumulative time

ncalls  tottime  percall  cumtime  percall filename:lineno(function)
     1    0.000    0.000    0.038    0.038 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/vbench/benchmark.py:286(f)
     1    0.000    0.000    0.038    0.038 <f>:1(<module>)
     1    0.000    0.000    0.038    0.038 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:633(fit)
     1    0.000    0.000    0.038    0.038 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:613(_fit_transform)
     1    0.015    0.015    0.037    0.037 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:177(locally_linear_embedding)
    31    0.005    0.000    0.008    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/decomp.py:196(eigh)
   151    0.006    0.000    0.006    0.000 {numpy.core._dotblas.dot}
    60    0.001    0.000    0.002    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/linalg/linalg.py:1840(norm)
    31    0.001    0.000    0.002    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/lib/function_base.py:526(asarray_chkfinite)
     1    0.000    0.000    0.002    0.002 /tmp/vb_sklearn/sklearn/neighbors/base.py:156(kneighbors)
    31    0.001    0.000    0.002    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:60(get_lapack_funcs)
     1    0.001    0.001    0.001    0.001 {method 'query' of 'sklearn.neighbors.ball_tree.BallTree' objects}
   246    0.001    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:167(asarray)
    30    0.001    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:740(outer)
    30    0.000    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/lib/function_base.py:3211(meshgrid)
    67    0.001    0.000    0.001    0.000 {method 'sum' of 'numpy.ndarray' objects}
    31    0.000    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:45(find_best_lapack_type)
     1    0.000    0.000    0.001    0.001 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:106(null_space)
    61    0.000    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:1791(ones)
   249    0.001    0.000    0.001    0.000 {numpy.core.multiarray.array}
    62    0.001    0.000    0.001    0.000 {method 'any' of 'numpy.ndarray' objects}
     2    0.000    0.000    0.001    0.000 /tmp/vb_sklearn/sklearn/neighbors/base.py:578(fit)
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/neighbors/base.py:96(_fit)
    31    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/lib/type_check.py:235(iscomplexobj)
    60    0.000    0.000    0.000    0.000 {method 'repeat' of 'numpy.ndarray' objects}
    61    0.000    0.000    0.000    0.000 {numpy.core.multiarray.empty}
    60    0.000    0.000    0.000    0.000 {method 'reduce' of 'numpy.ufunc' objects}
    61    0.000    0.000    0.000    0.000 {method 'fill' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:23(safe_asarray)
    30    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:757(searchsorted)
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:10(assert_all_finite)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:70(atleast2d_or_csr)
    30    0.000    0.000    0.000    0.000 {method 'searchsorted' of 'numpy.ndarray' objects}
   120    0.000    0.000    0.000    0.000 {method 'ravel' of 'numpy.ndarray' objects}
    62    0.000    0.000    0.000    0.000 {getattr}
    31    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:23(cast_to_lapack_prefix)
    72    0.000    0.000    0.000    0.000 {method 'split' of 'str' objects}
    60    0.000    0.000    0.000    0.000 {method 'reshape' of 'numpy.ndarray' objects}
    93    0.000    0.000    0.000    0.000 {issubclass}
     5    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:553(isspmatrix)
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:62(array2d)
     5    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:116(_isinstance)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/lib/function_base.py:2861(median)
    35    0.000    0.000    0.000    0.000 {range}
    31    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:449(isfortran)
    60    0.000    0.000    0.000    0.000 {method 'conj' of 'numpy.ndarray' objects}
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/shape_base.py:58(atleast_2d)
   128    0.000    0.000    0.000    0.000 {len}
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:181(check_random_state)
     5    0.000    0.000    0.000    0.000 {numpy.core.multiarray.zeros}
    64    0.000    0.000    0.000    0.000 {method 'append' of 'list' objects}
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/neighbors/unsupervised.py:85(__init__)
    31    0.000    0.000    0.000    0.000 {method 'sort' of 'list' objects}
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:490(sort)
    30    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/misc.py:22(_datacopied)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:237(asanyarray)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:2299(mean)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:1379(sum)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:1643(cumsum)
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/neighbors/base.py:77(_init_params)
     1    0.000    0.000    0.000    0.000 {method 'mean' of 'numpy.ndarray' objects}
    11    0.000    0.000    0.000    0.000 {isinstance}
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:598(argsort)
     1    0.000    0.000    0.000    0.000 {method 'cumsum' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 {method 'argsort' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 {hasattr}
     1    0.000    0.000    0.000    0.000 {method 'sort' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 {method 'flatten' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 {min}
     1    0.000    0.000    0.000    0.000 {method 'transpose' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}

LineProfiler

   Timer unit: 1e-06 s

File: /tmp/vb_sklearn/sklearn/manifold/locally_linear.py
Function: fit at line 633
Total time: 0.042141 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   633                                               def fit(self, X, y=None):
   634                                                   """Compute the embedding vectors for data X
   635
   636                                                   Parameters
   637                                                   ----------
   638                                                   X : array-like of shape [n_samples, n_features]
   639                                                       training set.
   640
   641                                                   Returns
   642                                                   -------
   643                                                   self : returns an instance of self.
   644                                                   """
   645         1        42138  42138.0    100.0          self._fit_transform(X)
   646         1            3      3.0      0.0          return self

File: /tmp/vb_sklearn/sklearn/manifold/locally_linear.py
Function: transform at line 663
Total time: 0 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   663                                               def transform(self, X):
   664                                                   """
   665                                                   Transform new points into embedding space.
   666
   667                                                   Parameters
   668                                                   ----------
   669                                                   X : array-like, shape = [n_samples, n_features]
   670
   671                                                   Returns
   672                                                   -------
   673                                                   X_new : array, shape = [n_samples, n_components]
   674
   675                                                   Notes
   676                                                   -----
   677                                                   Because of scaling performed by this method, it is discouraged to use
   678                                                   it together with methods that are not scale-invariant (like SVMs)
   679                                                   """
   680                                                   X = array2d(X)
   681                                                   ind = self.nbrs_.kneighbors(X, n_neighbors=self.n_neighbors,
   682                                                                               return_distance=False)
   683                                                   weights = barycenter_weights(X, self.nbrs_._fit_X[ind],
   684                                                                                reg=self.reg)
   685                                                   X_new = np.empty((X.shape[0], self.n_components))
   686                                                   for i in range(X.shape[0]):
   687                                                       X_new[i] = np.dot(self.embedding_[ind[i]].T, weights[i])
   688                                                   return X_new

Benchmark statement

obj.transform(X)

Execution time

_images/LocallyLinearEmbedding-modified-dense-minimadelon-step1-timing.png

Memory usage

_images/LocallyLinearEmbedding-modified-dense-minimadelon-step1-memory.png

Additional output

cProfile

         1331 function calls in 0.022 seconds

Ordered by: cumulative time

ncalls  tottime  percall  cumtime  percall filename:lineno(function)
     1    0.000    0.000    0.022    0.022 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/vbench/benchmark.py:286(f)
     1    0.000    0.000    0.022    0.022 <f>:1(<module>)
     1    0.005    0.005    0.022    0.022 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:663(transform)
     1    0.003    0.003    0.015    0.015 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:17(barycenter_weights)
    60    0.005    0.000    0.005    0.000 {numpy.core._dotblas.dot}
    30    0.001    0.000    0.005    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/basic.py:19(solve)
    30    0.000    0.000    0.002    0.000 {map}
    60    0.001    0.000    0.002    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/lib/function_base.py:526(asarray_chkfinite)
     1    0.000    0.000    0.002    0.002 /tmp/vb_sklearn/sklearn/neighbors/base.py:156(kneighbors)
    30    0.000    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:60(get_lapack_funcs)
     1    0.001    0.001    0.001    0.001 {method 'query' of 'sklearn.neighbors.ball_tree.BallTree' objects}
    30    0.000    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:986(trace)
    30    0.000    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:45(find_best_lapack_type)
   120    0.001    0.000    0.001    0.000 {method 'any' of 'numpy.ndarray' objects}
    30    0.001    0.000    0.001    0.000 {method 'trace' of 'numpy.ndarray' objects}
    95    0.000    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:167(asarray)
    30    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:1379(sum)
    31    0.000    0.000    0.000    0.000 {method 'sum' of 'numpy.ndarray' objects}
    98    0.000    0.000    0.000    0.000 {numpy.core.multiarray.array}
    60    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:23(cast_to_lapack_prefix)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:70(atleast2d_or_csr)
     3    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:62(array2d)
   120    0.000    0.000    0.000    0.000 {issubclass}
    68    0.000    0.000    0.000    0.000 {method 'split' of 'str' objects}
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:10(assert_all_finite)
    34    0.000    0.000    0.000    0.000 {isinstance}
     4    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:553(isspmatrix)
    30    0.000    0.000    0.000    0.000 {method 'sort' of 'list' objects}
    30    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:449(isfortran)
     4    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:116(_isinstance)
    31    0.000    0.000    0.000    0.000 {range}
    93    0.000    0.000    0.000    0.000 {method 'append' of 'list' objects}
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/shape_base.py:58(atleast_2d)
    60    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/misc.py:22(_datacopied)
    30    0.000    0.000    0.000    0.000 {getattr}
    69    0.000    0.000    0.000    0.000 {len}
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:237(asanyarray)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:1791(ones)
     3    0.000    0.000    0.000    0.000 {numpy.core.multiarray.empty}
     1    0.000    0.000    0.000    0.000 {method 'fill' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 {method 'transpose' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}

LineProfiler

   Timer unit: 1e-06 s

File: /tmp/vb_sklearn/sklearn/manifold/locally_linear.py
Function: fit at line 633
Total time: 0.042141 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   633                                               def fit(self, X, y=None):
   634                                                   """Compute the embedding vectors for data X
   635
   636                                                   Parameters
   637                                                   ----------
   638                                                   X : array-like of shape [n_samples, n_features]
   639                                                       training set.
   640
   641                                                   Returns
   642                                                   -------
   643                                                   self : returns an instance of self.
   644                                                   """
   645         1        42138  42138.0    100.0          self._fit_transform(X)
   646         1            3      3.0      0.0          return self

File: /tmp/vb_sklearn/sklearn/manifold/locally_linear.py
Function: transform at line 663
Total time: 0.023489 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   663                                               def transform(self, X):
   664                                                   """
   665                                                   Transform new points into embedding space.
   666
   667                                                   Parameters
   668                                                   ----------
   669                                                   X : array-like, shape = [n_samples, n_features]
   670
   671                                                   Returns
   672                                                   -------
   673                                                   X_new : array, shape = [n_samples, n_components]
   674
   675                                                   Notes
   676                                                   -----
   677                                                   Because of scaling performed by this method, it is discouraged to use
   678                                                   it together with methods that are not scale-invariant (like SVMs)
   679                                                   """
   680         1           63     63.0      0.3          X = array2d(X)
   681         1            4      4.0      0.0          ind = self.nbrs_.kneighbors(X, n_neighbors=self.n_neighbors,
   682         1         1609   1609.0      6.9                                      return_distance=False)
   683         1         4194   4194.0     17.9          weights = barycenter_weights(X, self.nbrs_._fit_X[ind],
   684         1        16912  16912.0     72.0                                       reg=self.reg)
   685         1            9      9.0      0.0          X_new = np.empty((X.shape[0], self.n_components))
   686        31           94      3.0      0.4          for i in range(X.shape[0]):
   687        30          602     20.1      2.6              X_new[i] = np.dot(self.embedding_[ind[i]].T, weights[i])
   688         1            2      2.0      0.0          return X_new

LocallyLinearEmbedding-modified-dense-blobs

Benchmark setup

from sklearn.manifold import LocallyLinearEmbedding
from deps import load_data

kwargs = {'random_state': 0, 'method': 'modified', 'eigen_solver': 'dense'}
X, y, X_t, y_t = load_data('blobs')
obj = LocallyLinearEmbedding(**kwargs)

Benchmark statement

obj.fit(X)

Execution time

_images/LocallyLinearEmbedding-modified-dense-blobs-step0-timing.png

Memory usage

_images/LocallyLinearEmbedding-modified-dense-blobs-step0-memory.png

Additional output

cProfile

         21739 function calls in 0.304 seconds

Ordered by: cumulative time

ncalls  tottime  percall  cumtime  percall filename:lineno(function)
     1    0.000    0.000    0.304    0.304 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/vbench/benchmark.py:286(f)
     1    0.000    0.000    0.304    0.304 <f>:1(<module>)
     1    0.000    0.000    0.304    0.304 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:633(fit)
     1    0.000    0.000    0.304    0.304 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:613(_fit_transform)
     1    0.097    0.097    0.303    0.303 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:177(locally_linear_embedding)
   301    0.087    0.000    0.121    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/decomp.py:196(eigh)
     1    0.000    0.000    0.051    0.051 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:106(null_space)
   600    0.012    0.000    0.019    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/linalg/linalg.py:1840(norm)
   301    0.009    0.000    0.017    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/lib/function_base.py:526(asarray_chkfinite)
  1501    0.016    0.000    0.016    0.000 {numpy.core._dotblas.dot}
     1    0.000    0.000    0.014    0.014 /tmp/vb_sklearn/sklearn/neighbors/base.py:156(kneighbors)
     1    0.014    0.014    0.014    0.014 {method 'query' of 'sklearn.neighbors.ball_tree.BallTree' objects}
   301    0.004    0.000    0.013    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:60(get_lapack_funcs)
   300    0.009    0.000    0.011    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:740(outer)
  2406    0.005    0.000    0.011    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:167(asarray)
   300    0.003    0.000    0.009    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/lib/function_base.py:3211(meshgrid)
   607    0.007    0.000    0.007    0.000 {method 'sum' of 'numpy.ndarray' objects}
   301    0.003    0.000    0.006    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:45(find_best_lapack_type)
   601    0.002    0.000    0.006    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:1791(ones)
   602    0.006    0.000    0.006    0.000 {method 'any' of 'numpy.ndarray' objects}
  2409    0.006    0.000    0.006    0.000 {numpy.core.multiarray.array}
   301    0.001    0.000    0.003    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/lib/type_check.py:235(iscomplexobj)
   600    0.003    0.000    0.003    0.000 {method 'repeat' of 'numpy.ndarray' objects}
   601    0.003    0.000    0.003    0.000 {numpy.core.multiarray.empty}
   600    0.002    0.000    0.002    0.000 {method 'reduce' of 'numpy.ufunc' objects}
   300    0.000    0.000    0.002    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:757(searchsorted)
   300    0.002    0.000    0.002    0.000 {method 'searchsorted' of 'numpy.ndarray' objects}
   601    0.002    0.000    0.002    0.000 {method 'fill' of 'numpy.ndarray' objects}
  1200    0.002    0.000    0.002    0.000 {method 'ravel' of 'numpy.ndarray' objects}
   602    0.001    0.000    0.001    0.000 {getattr}
     2    0.000    0.000    0.001    0.001 /tmp/vb_sklearn/sklearn/neighbors/base.py:578(fit)
     2    0.001    0.001    0.001    0.001 /tmp/vb_sklearn/sklearn/neighbors/base.py:96(_fit)
   301    0.001    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:23(cast_to_lapack_prefix)
   600    0.001    0.000    0.001    0.000 {method 'reshape' of 'numpy.ndarray' objects}
   903    0.001    0.000    0.001    0.000 {issubclass}
   612    0.001    0.000    0.001    0.000 {method 'split' of 'str' objects}
   301    0.001    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:449(isfortran)
   600    0.001    0.000    0.001    0.000 {method 'conj' of 'numpy.ndarray' objects}
   305    0.001    0.000    0.001    0.000 {range}
  1208    0.000    0.000    0.000    0.000 {len}
     5    0.000    0.000    0.000    0.000 {numpy.core.multiarray.zeros}
   604    0.000    0.000    0.000    0.000 {method 'append' of 'list' objects}
   301    0.000    0.000    0.000    0.000 {method 'sort' of 'list' objects}
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:23(safe_asarray)
   300    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/misc.py:22(_datacopied)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:70(atleast2d_or_csr)
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:10(assert_all_finite)
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:62(array2d)
     5    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:553(isspmatrix)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/lib/function_base.py:2861(median)
     5    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:116(_isinstance)
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/shape_base.py:58(atleast_2d)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:490(sort)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:181(check_random_state)
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/neighbors/unsupervised.py:85(__init__)
     1    0.000    0.000    0.000    0.000 {method 'sort' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:1643(cumsum)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:1379(sum)
     1    0.000    0.000    0.000    0.000 {method 'cumsum' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:2299(mean)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:598(argsort)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:237(asanyarray)
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/neighbors/base.py:77(_init_params)
    11    0.000    0.000    0.000    0.000 {isinstance}
     1    0.000    0.000    0.000    0.000 {method 'mean' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 {method 'argsort' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 {hasattr}
     1    0.000    0.000    0.000    0.000 {method 'flatten' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 {method 'transpose' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 {min}
     1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}

LineProfiler

   Timer unit: 1e-06 s

File: /tmp/vb_sklearn/sklearn/manifold/locally_linear.py
Function: fit at line 633
Total time: 0.312933 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   633                                               def fit(self, X, y=None):
   634                                                   """Compute the embedding vectors for data X
   635
   636                                                   Parameters
   637                                                   ----------
   638                                                   X : array-like of shape [n_samples, n_features]
   639                                                       training set.
   640
   641                                                   Returns
   642                                                   -------
   643                                                   self : returns an instance of self.
   644                                                   """
   645         1       312932 312932.0    100.0          self._fit_transform(X)
   646         1            1      1.0      0.0          return self

File: /tmp/vb_sklearn/sklearn/manifold/locally_linear.py
Function: transform at line 663
Total time: 0 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   663                                               def transform(self, X):
   664                                                   """
   665                                                   Transform new points into embedding space.
   666
   667                                                   Parameters
   668                                                   ----------
   669                                                   X : array-like, shape = [n_samples, n_features]
   670
   671                                                   Returns
   672                                                   -------
   673                                                   X_new : array, shape = [n_samples, n_components]
   674
   675                                                   Notes
   676                                                   -----
   677                                                   Because of scaling performed by this method, it is discouraged to use
   678                                                   it together with methods that are not scale-invariant (like SVMs)
   679                                                   """
   680                                                   X = array2d(X)
   681                                                   ind = self.nbrs_.kneighbors(X, n_neighbors=self.n_neighbors,
   682                                                                               return_distance=False)
   683                                                   weights = barycenter_weights(X, self.nbrs_._fit_X[ind],
   684                                                                                reg=self.reg)
   685                                                   X_new = np.empty((X.shape[0], self.n_components))
   686                                                   for i in range(X.shape[0]):
   687                                                       X_new[i] = np.dot(self.embedding_[ind[i]].T, weights[i])
   688                                                   return X_new

Benchmark statement

obj.transform(X)

Execution time

_images/LocallyLinearEmbedding-modified-dense-blobs-step1-timing.png

Memory usage

_images/LocallyLinearEmbedding-modified-dense-blobs-step1-memory.png

Additional output

cProfile

         12671 function calls in 0.115 seconds

Ordered by: cumulative time

ncalls  tottime  percall  cumtime  percall filename:lineno(function)
     1    0.000    0.000    0.115    0.115 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/vbench/benchmark.py:286(f)
     1    0.000    0.000    0.115    0.115 <f>:1(<module>)
     1    0.008    0.008    0.115    0.115 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:663(transform)
     1    0.026    0.026    0.092    0.092 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:17(barycenter_weights)
   300    0.011    0.000    0.049    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/basic.py:19(solve)
   300    0.002    0.000    0.023    0.000 {map}
   600    0.010    0.000    0.022    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/lib/function_base.py:526(asarray_chkfinite)
   300    0.004    0.000    0.014    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:60(get_lapack_funcs)
     1    0.000    0.000    0.014    0.014 /tmp/vb_sklearn/sklearn/neighbors/base.py:156(kneighbors)
     1    0.014    0.014    0.014    0.014 {method 'query' of 'sklearn.neighbors.ball_tree.BallTree' objects}
  1200    0.009    0.000    0.009    0.000 {method 'any' of 'numpy.ndarray' objects}
   300    0.004    0.000    0.008    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:45(find_best_lapack_type)
   300    0.001    0.000    0.007    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:986(trace)
   600    0.007    0.000    0.007    0.000 {numpy.core._dotblas.dot}
   300    0.001    0.000    0.005    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:1379(sum)
   905    0.002    0.000    0.005    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:167(asarray)
   300    0.004    0.000    0.004    0.000 {method 'trace' of 'numpy.ndarray' objects}
   301    0.003    0.000    0.003    0.000 {method 'sum' of 'numpy.ndarray' objects}
   908    0.003    0.000    0.003    0.000 {numpy.core.multiarray.array}
   600    0.001    0.000    0.002    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:23(cast_to_lapack_prefix)
  1200    0.001    0.000    0.001    0.000 {issubclass}
   608    0.001    0.000    0.001    0.000 {method 'split' of 'str' objects}
   304    0.001    0.000    0.001    0.000 {isinstance}
   300    0.001    0.000    0.001    0.000 {method 'sort' of 'list' objects}
   903    0.001    0.000    0.001    0.000 {method 'append' of 'list' objects}
   300    0.001    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:449(isfortran)
   301    0.000    0.000    0.000    0.000 {range}
   600    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/misc.py:22(_datacopied)
   300    0.000    0.000    0.000    0.000 {getattr}
   609    0.000    0.000    0.000    0.000 {len}
     3    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:62(array2d)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:70(atleast2d_or_csr)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:10(assert_all_finite)
     4    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:553(isspmatrix)
     4    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:116(_isinstance)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/shape_base.py:58(atleast_2d)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:237(asanyarray)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:1791(ones)
     3    0.000    0.000    0.000    0.000 {numpy.core.multiarray.empty}
     1    0.000    0.000    0.000    0.000 {method 'fill' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 {method 'transpose' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}

LineProfiler

   Timer unit: 1e-06 s

File: /tmp/vb_sklearn/sklearn/manifold/locally_linear.py
Function: fit at line 633
Total time: 0.312933 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   633                                               def fit(self, X, y=None):
   634                                                   """Compute the embedding vectors for data X
   635
   636                                                   Parameters
   637                                                   ----------
   638                                                   X : array-like of shape [n_samples, n_features]
   639                                                       training set.
   640
   641                                                   Returns
   642                                                   -------
   643                                                   self : returns an instance of self.
   644                                                   """
   645         1       312932 312932.0    100.0          self._fit_transform(X)
   646         1            1      1.0      0.0          return self

File: /tmp/vb_sklearn/sklearn/manifold/locally_linear.py
Function: transform at line 663
Total time: 0.145764 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   663                                               def transform(self, X):
   664                                                   """
   665                                                   Transform new points into embedding space.
   666
   667                                                   Parameters
   668                                                   ----------
   669                                                   X : array-like, shape = [n_samples, n_features]
   670
   671                                                   Returns
   672                                                   -------
   673                                                   X_new : array, shape = [n_samples, n_components]
   674
   675                                                   Notes
   676                                                   -----
   677                                                   Because of scaling performed by this method, it is discouraged to use
   678                                                   it together with methods that are not scale-invariant (like SVMs)
   679                                                   """
   680         1           45     45.0      0.0          X = array2d(X)
   681         1            3      3.0      0.0          ind = self.nbrs_.kneighbors(X, n_neighbors=self.n_neighbors,
   682         1         7886   7886.0      5.4                                      return_distance=False)
   683         1         2397   2397.0      1.6          weights = barycenter_weights(X, self.nbrs_._fit_X[ind],
   684         1       131789 131789.0     90.4                                       reg=self.reg)
   685         1            7      7.0      0.0          X_new = np.empty((X.shape[0], self.n_components))
   686       301          397      1.3      0.3          for i in range(X.shape[0]):
   687       300         3239     10.8      2.2              X_new[i] = np.dot(self.embedding_[ind[i]].T, weights[i])
   688         1            1      1.0      0.0          return X_new

LocallyLinearEmbedding-ltsa-arpack-minimadelon

Benchmark setup

from sklearn.manifold import LocallyLinearEmbedding
from deps import load_data

kwargs = {'method': 'ltsa', 'eigen_solver': 'arpack'}
X, y, X_t, y_t = load_data('minimadelon')
obj = LocallyLinearEmbedding(**kwargs)

Benchmark statement

obj.fit(X)

Execution time

_images/LocallyLinearEmbedding-ltsa-arpack-minimadelon-step0-timing.png

Memory usage

_images/LocallyLinearEmbedding-ltsa-arpack-minimadelon-step0-memory.png

Additional output

cProfile

         1647 function calls in 0.021 seconds

Ordered by: cumulative time

ncalls  tottime  percall  cumtime  percall filename:lineno(function)
     1    0.000    0.000    0.021    0.021 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/vbench/benchmark.py:286(f)
     1    0.000    0.000    0.021    0.021 <f>:1(<module>)
     1    0.000    0.000    0.021    0.021 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:633(fit)
     1    0.000    0.000    0.021    0.021 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:613(_fit_transform)
     1    0.006    0.006    0.021    0.021 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:177(locally_linear_embedding)
    30    0.003    0.000    0.005    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/decomp.py:196(eigh)
     1    0.000    0.000    0.004    0.004 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:106(null_space)
     1    0.000    0.000    0.004    0.004 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:1275(eigsh)
     8    0.002    0.000    0.004    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:540(iterate)
    60    0.003    0.000    0.003    0.000 {numpy.core._dotblas.dot}
     7    0.000    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/interface.py:92(matvec)
     7    0.000    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:934(_matvec)
     7    0.001    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/decomp_lu.py:65(lu_solve)
    37    0.001    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/lib/function_base.py:526(asarray_chkfinite)
    30    0.001    0.000    0.001    0.000 {method 'mean' of 'numpy.ndarray' objects}
    38    0.000    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:60(get_lapack_funcs)
     1    0.000    0.000    0.001    0.001 /tmp/vb_sklearn/sklearn/neighbors/base.py:156(kneighbors)
     1    0.001    0.001    0.001    0.001 {method 'query' of 'sklearn.neighbors.ball_tree.BallTree' objects}
    30    0.000    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/lib/function_base.py:3211(meshgrid)
    38    0.000    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:45(find_best_lapack_type)
   141    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:167(asarray)
    74    0.000    0.000    0.000    0.000 {method 'any' of 'numpy.ndarray' objects}
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/neighbors/base.py:578(fit)
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/neighbors/base.py:96(_fit)
   151    0.000    0.000    0.000    0.000 {numpy.core.multiarray.array}
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:1023(get_OPinv_matvec)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:1012(get_inv_matvec)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:930(__init__)
    30    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/lib/type_check.py:235(iscomplexobj)
    60    0.000    0.000    0.000    0.000 {method 'repeat' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:23(safe_asarray)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/decomp_lu.py:15(lu_factor)
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:10(assert_all_finite)
    45    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:23(cast_to_lapack_prefix)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:70(atleast2d_or_csr)
    37    0.000    0.000    0.000    0.000 {numpy.core.multiarray.zeros}
    67    0.000    0.000    0.000    0.000 {method 'reshape' of 'numpy.ndarray' objects}
    69    0.000    0.000    0.000    0.000 {getattr}
     3    0.000    0.000    0.000    0.000 {method 'sum' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:387(__init__)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:580(extract)
   122    0.000    0.000    0.000    0.000 {issubclass}
    88    0.000    0.000    0.000    0.000 {method 'split' of 'str' objects}
     5    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:553(isspmatrix)
     6    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:116(_isinstance)
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:62(array2d)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/interface.py:59(__init__)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:96(isshape)
    39    0.000    0.000    0.000    0.000 {range}
    38    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:449(isfortran)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:316(__init__)
    85    0.000    0.000    0.000    0.000 {method 'append' of 'list' objects}
     9    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:237(asanyarray)
   135    0.000    0.000    0.000    0.000 {len}
    38    0.000    0.000    0.000    0.000 {method 'sort' of 'list' objects}
    24    0.000    0.000    0.000    0.000 {isinstance}
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/shape_base.py:58(atleast_2d)
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:2116(rank)
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:181(check_random_state)
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/neighbors/unsupervised.py:85(__init__)
    38    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/misc.py:22(_datacopied)
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/neighbors/base.py:77(_init_params)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:1379(sum)
     1    0.000    0.000    0.000    0.000 {_warnings.warn}
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:81(isintlike)
     1    0.000    0.000    0.000    0.000 {method 'rand' of 'mtrand.RandomState' objects}
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:124(isdense)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numerictypes.py:733(issubdtype)
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:111(issequence)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numerictypes.py:665(issubclass_)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:57(_single_precision_cast)
     1    0.000    0.000    0.000    0.000 {min}
     1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}

LineProfiler

   Timer unit: 1e-06 s

File: /tmp/vb_sklearn/sklearn/manifold/locally_linear.py
Function: fit at line 633
Total time: 0.023031 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   633                                               def fit(self, X, y=None):
   634                                                   """Compute the embedding vectors for data X
   635
   636                                                   Parameters
   637                                                   ----------
   638                                                   X : array-like of shape [n_samples, n_features]
   639                                                       training set.
   640
   641                                                   Returns
   642                                                   -------
   643                                                   self : returns an instance of self.
   644                                                   """
   645         1        23030  23030.0    100.0          self._fit_transform(X)
   646         1            1      1.0      0.0          return self

File: /tmp/vb_sklearn/sklearn/manifold/locally_linear.py
Function: transform at line 663
Total time: 0 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   663                                               def transform(self, X):
   664                                                   """
   665                                                   Transform new points into embedding space.
   666
   667                                                   Parameters
   668                                                   ----------
   669                                                   X : array-like, shape = [n_samples, n_features]
   670
   671                                                   Returns
   672                                                   -------
   673                                                   X_new : array, shape = [n_samples, n_components]
   674
   675                                                   Notes
   676                                                   -----
   677                                                   Because of scaling performed by this method, it is discouraged to use
   678                                                   it together with methods that are not scale-invariant (like SVMs)
   679                                                   """
   680                                                   X = array2d(X)
   681                                                   ind = self.nbrs_.kneighbors(X, n_neighbors=self.n_neighbors,
   682                                                                               return_distance=False)
   683                                                   weights = barycenter_weights(X, self.nbrs_._fit_X[ind],
   684                                                                                reg=self.reg)
   685                                                   X_new = np.empty((X.shape[0], self.n_components))
   686                                                   for i in range(X.shape[0]):
   687                                                       X_new[i] = np.dot(self.embedding_[ind[i]].T, weights[i])
   688                                                   return X_new

Benchmark statement

obj.transform(X)

Execution time

_images/LocallyLinearEmbedding-ltsa-arpack-minimadelon-step1-timing.png

Memory usage

_images/LocallyLinearEmbedding-ltsa-arpack-minimadelon-step1-memory.png

Additional output

cProfile

         1331 function calls in 0.012 seconds

Ordered by: cumulative time

ncalls  tottime  percall  cumtime  percall filename:lineno(function)
     1    0.000    0.000    0.012    0.012 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/vbench/benchmark.py:286(f)
     1    0.000    0.000    0.012    0.012 <f>:1(<module>)
     1    0.003    0.003    0.012    0.012 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:663(transform)
     1    0.002    0.002    0.009    0.009 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:17(barycenter_weights)
    60    0.003    0.000    0.003    0.000 {numpy.core._dotblas.dot}
    30    0.001    0.000    0.003    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/basic.py:19(solve)
    30    0.000    0.000    0.001    0.000 {map}
    60    0.001    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/lib/function_base.py:526(asarray_chkfinite)
     1    0.000    0.000    0.001    0.001 /tmp/vb_sklearn/sklearn/neighbors/base.py:156(kneighbors)
    30    0.000    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:60(get_lapack_funcs)
     1    0.001    0.001    0.001    0.001 {method 'query' of 'sklearn.neighbors.ball_tree.BallTree' objects}
    30    0.000    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:986(trace)
    30    0.000    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:45(find_best_lapack_type)
   120    0.000    0.000    0.000    0.000 {method 'any' of 'numpy.ndarray' objects}
    30    0.000    0.000    0.000    0.000 {method 'trace' of 'numpy.ndarray' objects}
    95    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:167(asarray)
    30    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:1379(sum)
    31    0.000    0.000    0.000    0.000 {method 'sum' of 'numpy.ndarray' objects}
    98    0.000    0.000    0.000    0.000 {numpy.core.multiarray.array}
    60    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:23(cast_to_lapack_prefix)
     3    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:62(array2d)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:70(atleast2d_or_csr)
   120    0.000    0.000    0.000    0.000 {issubclass}
    68    0.000    0.000    0.000    0.000 {method 'split' of 'str' objects}
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:10(assert_all_finite)
    30    0.000    0.000    0.000    0.000 {method 'sort' of 'list' objects}
    34    0.000    0.000    0.000    0.000 {isinstance}
     4    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:553(isspmatrix)
    30    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:449(isfortran)
     4    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:116(_isinstance)
    31    0.000    0.000    0.000    0.000 {range}
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/shape_base.py:58(atleast_2d)
    93    0.000    0.000    0.000    0.000 {method 'append' of 'list' objects}
    30    0.000    0.000    0.000    0.000 {getattr}
    60    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/misc.py:22(_datacopied)
    69    0.000    0.000    0.000    0.000 {len}
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:237(asanyarray)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:1791(ones)
     3    0.000    0.000    0.000    0.000 {numpy.core.multiarray.empty}
     1    0.000    0.000    0.000    0.000 {method 'fill' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 {method 'transpose' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}

LineProfiler

   Timer unit: 1e-06 s

File: /tmp/vb_sklearn/sklearn/manifold/locally_linear.py
Function: fit at line 633
Total time: 0.023031 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   633                                               def fit(self, X, y=None):
   634                                                   """Compute the embedding vectors for data X
   635
   636                                                   Parameters
   637                                                   ----------
   638                                                   X : array-like of shape [n_samples, n_features]
   639                                                       training set.
   640
   641                                                   Returns
   642                                                   -------
   643                                                   self : returns an instance of self.
   644                                                   """
   645         1        23030  23030.0    100.0          self._fit_transform(X)
   646         1            1      1.0      0.0          return self

File: /tmp/vb_sklearn/sklearn/manifold/locally_linear.py
Function: transform at line 663
Total time: 0.013559 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   663                                               def transform(self, X):
   664                                                   """
   665                                                   Transform new points into embedding space.
   666
   667                                                   Parameters
   668                                                   ----------
   669                                                   X : array-like, shape = [n_samples, n_features]
   670
   671                                                   Returns
   672                                                   -------
   673                                                   X_new : array, shape = [n_samples, n_components]
   674
   675                                                   Notes
   676                                                   -----
   677                                                   Because of scaling performed by this method, it is discouraged to use
   678                                                   it together with methods that are not scale-invariant (like SVMs)
   679                                                   """
   680         1           36     36.0      0.3          X = array2d(X)
   681         1            2      2.0      0.0          ind = self.nbrs_.kneighbors(X, n_neighbors=self.n_neighbors,
   682         1          899    899.0      6.6                                      return_distance=False)
   683         1         2346   2346.0     17.3          weights = barycenter_weights(X, self.nbrs_._fit_X[ind],
   684         1         9768   9768.0     72.0                                       reg=self.reg)
   685         1            5      5.0      0.0          X_new = np.empty((X.shape[0], self.n_components))
   686        31           49      1.6      0.4          for i in range(X.shape[0]):
   687        30          453     15.1      3.3              X_new[i] = np.dot(self.embedding_[ind[i]].T, weights[i])
   688         1            1      1.0      0.0          return X_new

LocallyLinearEmbedding-ltsa-arpack-blobs

Benchmark setup

from sklearn.manifold import LocallyLinearEmbedding
from deps import load_data

kwargs = {'method': 'ltsa', 'eigen_solver': 'arpack'}
X, y, X_t, y_t = load_data('blobs')
obj = LocallyLinearEmbedding(**kwargs)

Benchmark statement

obj.fit(X)

Execution time

_images/LocallyLinearEmbedding-ltsa-arpack-blobs-step0-timing.png

Memory usage

_images/LocallyLinearEmbedding-ltsa-arpack-blobs-step0-memory.png

Additional output

cProfile

         12987 function calls in 0.380 seconds

Ordered by: cumulative time

ncalls  tottime  percall  cumtime  percall filename:lineno(function)
     1    0.000    0.000    0.380    0.380 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/vbench/benchmark.py:286(f)
     1    0.000    0.000    0.380    0.380 <f>:1(<module>)
     1    0.000    0.000    0.380    0.380 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:633(fit)
     1    0.000    0.000    0.380    0.380 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:613(_fit_transform)
     1    0.056    0.056    0.378    0.378 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:177(locally_linear_embedding)
     1    0.000    0.000    0.206    0.206 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:106(null_space)
     1    0.000    0.000    0.206    0.206 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:1275(eigsh)
     8    0.031    0.004    0.193    0.024 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:540(iterate)
     7    0.000    0.000    0.162    0.023 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/interface.py:92(matvec)
     7    0.000    0.000    0.162    0.023 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:934(_matvec)
     7    0.161    0.023    0.162    0.023 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/decomp_lu.py:65(lu_solve)
   300    0.042    0.000    0.072    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/decomp.py:196(eigh)
     1    0.000    0.000    0.014    0.014 /tmp/vb_sklearn/sklearn/neighbors/base.py:156(kneighbors)
     1    0.014    0.014    0.014    0.014 {method 'query' of 'sklearn.neighbors.ball_tree.BallTree' objects}
   307    0.007    0.000    0.014    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/lib/function_base.py:526(asarray_chkfinite)
   308    0.005    0.000    0.014    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:60(get_lapack_funcs)
     1    0.000    0.000    0.012    0.012 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:1023(get_OPinv_matvec)
     1    0.000    0.000    0.012    0.012 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:1012(get_inv_matvec)
     1    0.000    0.000    0.012    0.012 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:930(__init__)
     1    0.011    0.011    0.012    0.012 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/decomp_lu.py:15(lu_factor)
   300    0.003    0.000    0.011    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/lib/function_base.py:3211(meshgrid)
   600    0.009    0.000    0.009    0.000 {numpy.core._dotblas.dot}
   300    0.009    0.000    0.009    0.000 {method 'mean' of 'numpy.ndarray' objects}
   308    0.004    0.000    0.007    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:45(find_best_lapack_type)
  1221    0.003    0.000    0.006    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:167(asarray)
   614    0.005    0.000    0.005    0.000 {method 'any' of 'numpy.ndarray' objects}
  1231    0.003    0.000    0.003    0.000 {numpy.core.multiarray.array}
   600    0.003    0.000    0.003    0.000 {method 'repeat' of 'numpy.ndarray' objects}
   300    0.001    0.000    0.003    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/lib/type_check.py:235(iscomplexobj)
   307    0.002    0.000    0.002    0.000 {numpy.core.multiarray.zeros}
   607    0.001    0.000    0.001    0.000 {method 'reshape' of 'numpy.ndarray' objects}
   609    0.001    0.000    0.001    0.000 {getattr}
     2    0.000    0.000    0.001    0.001 /tmp/vb_sklearn/sklearn/neighbors/base.py:578(fit)
     2    0.001    0.001    0.001    0.001 /tmp/vb_sklearn/sklearn/neighbors/base.py:96(_fit)
   315    0.001    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:23(cast_to_lapack_prefix)
   932    0.001    0.000    0.001    0.000 {issubclass}
   628    0.001    0.000    0.001    0.000 {method 'split' of 'str' objects}
     1    0.001    0.001    0.001    0.001 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:580(extract)
   308    0.001    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:449(isfortran)
   309    0.001    0.000    0.001    0.000 {range}
  1215    0.001    0.000    0.001    0.000 {len}
   625    0.000    0.000    0.000    0.000 {method 'append' of 'list' objects}
   308    0.000    0.000    0.000    0.000 {method 'sort' of 'list' objects}
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:23(safe_asarray)
   308    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/misc.py:22(_datacopied)
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:10(assert_all_finite)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:70(atleast2d_or_csr)
     5    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:553(isspmatrix)
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:62(array2d)
     6    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:116(_isinstance)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:387(__init__)
     3    0.000    0.000    0.000    0.000 {method 'sum' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/interface.py:59(__init__)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:96(isshape)
    24    0.000    0.000    0.000    0.000 {isinstance}
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:316(__init__)
     9    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:237(asanyarray)
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/shape_base.py:58(atleast_2d)
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:2116(rank)
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:181(check_random_state)
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/neighbors/unsupervised.py:85(__init__)
     1    0.000    0.000    0.000    0.000 {method 'rand' of 'mtrand.RandomState' objects}
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:1379(sum)
     1    0.000    0.000    0.000    0.000 {_warnings.warn}
     2    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/neighbors/base.py:77(_init_params)
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:81(isintlike)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:124(isdense)
     2    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:111(issequence)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numerictypes.py:733(issubdtype)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/linalg/eigen/arpack/arpack.py:57(_single_precision_cast)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numerictypes.py:665(issubclass_)
     1    0.000    0.000    0.000    0.000 {min}
     1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}

LineProfiler

   Timer unit: 1e-06 s

File: /tmp/vb_sklearn/sklearn/manifold/locally_linear.py
Function: fit at line 633
Total time: 0.41239 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   633                                               def fit(self, X, y=None):
   634                                                   """Compute the embedding vectors for data X
   635
   636                                                   Parameters
   637                                                   ----------
   638                                                   X : array-like of shape [n_samples, n_features]
   639                                                       training set.
   640
   641                                                   Returns
   642                                                   -------
   643                                                   self : returns an instance of self.
   644                                                   """
   645         1       412388 412388.0    100.0          self._fit_transform(X)
   646         1            2      2.0      0.0          return self

File: /tmp/vb_sklearn/sklearn/manifold/locally_linear.py
Function: transform at line 663
Total time: 0 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   663                                               def transform(self, X):
   664                                                   """
   665                                                   Transform new points into embedding space.
   666
   667                                                   Parameters
   668                                                   ----------
   669                                                   X : array-like, shape = [n_samples, n_features]
   670
   671                                                   Returns
   672                                                   -------
   673                                                   X_new : array, shape = [n_samples, n_components]
   674
   675                                                   Notes
   676                                                   -----
   677                                                   Because of scaling performed by this method, it is discouraged to use
   678                                                   it together with methods that are not scale-invariant (like SVMs)
   679                                                   """
   680                                                   X = array2d(X)
   681                                                   ind = self.nbrs_.kneighbors(X, n_neighbors=self.n_neighbors,
   682                                                                               return_distance=False)
   683                                                   weights = barycenter_weights(X, self.nbrs_._fit_X[ind],
   684                                                                                reg=self.reg)
   685                                                   X_new = np.empty((X.shape[0], self.n_components))
   686                                                   for i in range(X.shape[0]):
   687                                                       X_new[i] = np.dot(self.embedding_[ind[i]].T, weights[i])
   688                                                   return X_new

Benchmark statement

obj.transform(X)

Execution time

_images/LocallyLinearEmbedding-ltsa-arpack-blobs-step1-timing.png

Memory usage

_images/LocallyLinearEmbedding-ltsa-arpack-blobs-step1-memory.png

Additional output

cProfile

         12671 function calls in 0.116 seconds

Ordered by: cumulative time

ncalls  tottime  percall  cumtime  percall filename:lineno(function)
     1    0.000    0.000    0.116    0.116 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/vbench/benchmark.py:286(f)
     1    0.000    0.000    0.116    0.116 <f>:1(<module>)
     1    0.008    0.008    0.116    0.116 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:663(transform)
     1    0.025    0.025    0.091    0.091 /tmp/vb_sklearn/sklearn/manifold/locally_linear.py:17(barycenter_weights)
   300    0.011    0.000    0.048    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/basic.py:19(solve)
   300    0.002    0.000    0.023    0.000 {map}
   600    0.010    0.000    0.021    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/lib/function_base.py:526(asarray_chkfinite)
   300    0.004    0.000    0.014    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:60(get_lapack_funcs)
     1    0.000    0.000    0.014    0.014 /tmp/vb_sklearn/sklearn/neighbors/base.py:156(kneighbors)
     1    0.014    0.014    0.014    0.014 {method 'query' of 'sklearn.neighbors.ball_tree.BallTree' objects}
   300    0.004    0.000    0.009    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:45(find_best_lapack_type)
  1200    0.008    0.000    0.008    0.000 {method 'any' of 'numpy.ndarray' objects}
   600    0.008    0.000    0.008    0.000 {numpy.core._dotblas.dot}
   300    0.001    0.000    0.007    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:986(trace)
   300    0.001    0.000    0.005    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/fromnumeric.py:1379(sum)
   905    0.002    0.000    0.004    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:167(asarray)
   300    0.004    0.000    0.004    0.000 {method 'trace' of 'numpy.ndarray' objects}
   301    0.003    0.000    0.003    0.000 {method 'sum' of 'numpy.ndarray' objects}
   600    0.001    0.000    0.003    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/lapack.py:23(cast_to_lapack_prefix)
   908    0.002    0.000    0.002    0.000 {numpy.core.multiarray.array}
  1200    0.001    0.000    0.001    0.000 {issubclass}
   608    0.001    0.000    0.001    0.000 {method 'split' of 'str' objects}
   304    0.001    0.000    0.001    0.000 {isinstance}
   300    0.001    0.000    0.001    0.000 {method 'sort' of 'list' objects}
   300    0.001    0.000    0.001    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:449(isfortran)
   301    0.000    0.000    0.000    0.000 {range}
   903    0.000    0.000    0.000    0.000 {method 'append' of 'list' objects}
   600    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/linalg/misc.py:22(_datacopied)
   300    0.000    0.000    0.000    0.000 {getattr}
   609    0.000    0.000    0.000    0.000 {len}
     3    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:62(array2d)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:70(atleast2d_or_csr)
     1    0.000    0.000    0.000    0.000 /tmp/vb_sklearn/sklearn/utils/validation.py:10(assert_all_finite)
     4    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/base.py:553(isspmatrix)
     4    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/scipy/sparse/sputils.py:116(_isinstance)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/shape_base.py:58(atleast_2d)
     3    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:237(asanyarray)
     1    0.000    0.000    0.000    0.000 /home/slave/virtualenvs/cpython-2.7.2/lib/python2.7/site-packages/numpy/core/numeric.py:1791(ones)
     3    0.000    0.000    0.000    0.000 {numpy.core.multiarray.empty}
     1    0.000    0.000    0.000    0.000 {method 'fill' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 {method 'transpose' of 'numpy.ndarray' objects}
     1    0.000    0.000    0.000    0.000 {method 'disable' of '_lsprof.Profiler' objects}

LineProfiler

   Timer unit: 1e-06 s

File: /tmp/vb_sklearn/sklearn/manifold/locally_linear.py
Function: fit at line 633
Total time: 0.41239 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   633                                               def fit(self, X, y=None):
   634                                                   """Compute the embedding vectors for data X
   635
   636                                                   Parameters
   637                                                   ----------
   638                                                   X : array-like of shape [n_samples, n_features]
   639                                                       training set.
   640
   641                                                   Returns
   642                                                   -------
   643                                                   self : returns an instance of self.
   644                                                   """
   645         1       412388 412388.0    100.0          self._fit_transform(X)
   646         1            2      2.0      0.0          return self

File: /tmp/vb_sklearn/sklearn/manifold/locally_linear.py
Function: transform at line 663
Total time: 0.137744 s

Line #      Hits         Time  Per Hit   % Time  Line Contents
==============================================================
   663                                               def transform(self, X):
   664                                                   """
   665                                                   Transform new points into embedding space.
   666
   667                                                   Parameters
   668                                                   ----------
   669                                                   X : array-like, shape = [n_samples, n_features]
   670
   671                                                   Returns
   672                                                   -------
   673                                                   X_new : array, shape = [n_samples, n_components]
   674
   675                                                   Notes
   676                                                   -----
   677                                                   Because of scaling performed by this method, it is discouraged to use
   678                                                   it together with methods that are not scale-invariant (like SVMs)
   679                                                   """
   680         1           44     44.0      0.0          X = array2d(X)
   681         1            2      2.0      0.0          ind = self.nbrs_.kneighbors(X, n_neighbors=self.n_neighbors,
   682         1         7815   7815.0      5.7                                      return_distance=False)
   683         1         2407   2407.0      1.7          weights = barycenter_weights(X, self.nbrs_._fit_X[ind],
   684         1       123141 123141.0     89.4                                       reg=self.reg)
   685         1            7      7.0      0.0          X_new = np.empty((X.shape[0], self.n_components))
   686       301          389      1.3      0.3          for i in range(X.shape[0]):
   687       300         3938     13.1      2.9              X_new[i] = np.dot(self.embedding_[ind[i]].T, weights[i])
   688         1            1      1.0      0.0          return X_new
Previous
Next