
    0PhOw                        d Z ddlmZmZ ddlZddlmZmZm	Z	m
Z
 ddlmZmZmZ ddlmZ ddlmZmZmZmZmZ dd	lmZ dd
lmZmZ ddlmZ ddlmZm Z m!Z! ddl"m#Z# ddl$m%Z%m&Z&m'Z' d)dZ(d*dZ)	 d+dZ*dddddddddd	dZ+ e!deg eeddd          g eeddd          g eeddd          g e h d           g eeddd          g eeddd          g e h d!          g eeddd          g eeddd          gd"gdegd#d$%          dddddddddd	d&            Z, G d' d(eeee          Z-dS ),zLocally Linear Embedding    )IntegralRealN)eighqrsolvesvd)
csr_matrixeye
lil_matrix)eigsh   )BaseEstimatorClassNamePrefixFeaturesOutMixinTransformerMixin_fit_context_UnstableArchMixin)NearestNeighbors)check_arraycheck_random_state)_init_arpack_v0)Interval
StrOptionsvalidate_params)stable_cumsum)FLOAT_DTYPEScheck_is_fittedvalidate_dataMbP?c                    t          | t                    } t          |t                    }t          |t                    }|j        \  }}| j        d         |k    sJ t	          j        ||f| j                  }t	          j        || j                  }t          |          D ]\  }}	||	         }
|
| |         z
  }t	          j	        ||j
                  }t	          j        |          }|dk    r||z  }n|}|j        dd|dz   xx         |z  cc<   t          ||d          }|t	          j        |          z  ||ddf<   |S )a  Compute barycenter weights of X from Y along the first axis

    We estimate the weights to assign to each point in Y[indices] to recover
    the point X[i]. The barycenter weights sum to 1.

    Parameters
    ----------
    X : array-like, shape (n_samples, n_dim)

    Y : array-like, shape (n_samples, n_dim)

    indices : array-like, shape (n_samples, n_dim)
            Indices of the points in Y used to compute the barycenter

    reg : float, default=1e-3
        Amount of regularization to add for the problem to be
        well-posed in the case of n_neighbors > n_dim

    Returns
    -------
    B : array-like, shape (n_samples, n_neighbors)

    Notes
    -----
    See developers note for more information.
    dtyper   N   pos)assume_a)r   r   intshapenpemptyr!   ones	enumeratedotTtraceflatr   sum)XYindicesreg	n_samplesn_neighborsBviindACGr-   Rws                   `/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/sklearn/manifold/_locally_linear.pybarycenter_weightsr@      s[   6 	A\***AA\***A'---G$]I{71:""""
)[)999A
17+++A G$$    3cF!HF1acNN199eAAA	!!+/!"""a'"""!Q'''bfQii-!QQQ$H    c                    t          |dz   |                              |           }|j        } |j        }|                    | d          ddddf         }t          | | ||          }t          j        d||z  dz   |          }t          |	                                |	                                |f||f          S )	a-  Computes the barycenter weighted graph of k-Neighbors for points in X

    Parameters
    ----------
    X : {array-like, NearestNeighbors}
        Sample data, shape = (n_samples, n_features), in the form of a
        numpy array or a NearestNeighbors object.

    n_neighbors : int
        Number of neighbors for each sample.

    reg : float, default=1e-3
        Amount of regularization when solving the least-squares
        problem. Only relevant if mode='barycenter'. If None, use the
        default.

    n_jobs : int or None, default=None
        The number of parallel jobs to run for neighbors search.
        ``None`` means 1 unless in a :obj:`joblib.parallel_backend` context.
        ``-1`` means using all processors. See :term:`Glossary <n_jobs>`
        for more details.

    Returns
    -------
    A : sparse matrix in CSR format, shape = [n_samples, n_samples]
        A[i, j] is assigned the weight of edge that connects i to j.

    See Also
    --------
    sklearn.neighbors.kneighbors_graph
    sklearn.neighbors.radius_neighbors_graph
    r"   r5   n_jobsF)return_distanceNr3   r   r&   )
r   fit_fit_Xn_samples_fit_
kneighborsr@   r'   aranger	   ravel)	r0   r5   r3   rD   knnr4   r9   dataindptrs	            r?   barycenter_kneighbors_graphrQ   R   s    B {Qv
F
F
F
J
J1
M
MC
A"I
..E.
2
2111abb5
9CaCS111DYq)k1A5{CCFtzz||SYY[[&9)YAWXXXXrA   r"   arpackư>d   c                    |dk    r| j         d         dk    r||z   dk     rd}nd}|dk    rt          | j         d         |          }	 t          | ||z   d|||          \  }}	n%# t          $ r}
t	          d	|
z            |
d
}
~
ww xY w|	d
d
|d
f         t          j        ||d
                   fS |dk    rt          | d          r|                                 } t          | |||z   dz
  fd          \  }}	t          j
        t          j        |                    }|	d
d
|f         t          j        |          fS t	          d|z            )a0  
    Find the null space of a matrix M.

    Parameters
    ----------
    M : {array, matrix, sparse matrix, LinearOperator}
        Input covariance matrix: should be symmetric positive semi-definite

    k : int
        Number of eigenvalues/vectors to return

    k_skip : int, default=1
        Number of low eigenvalues to skip.

    eigen_solver : {'auto', 'arpack', 'dense'}, default='arpack'
        auto : algorithm will attempt to choose the best method for input data
        arpack : use arnoldi iteration in shift-invert mode.
                    For this method, M may be a dense matrix, sparse matrix,
                    or general linear operator.
                    Warning: ARPACK can be unstable for some problems.  It is
                    best to try several random seeds in order to check results.
        dense  : use standard dense matrix operations for the eigenvalue
                    decomposition.  For this method, M must be an array
                    or matrix type.  This method should be avoided for
                    large problems.

    tol : float, default=1e-6
        Tolerance for 'arpack' method.
        Not used if eigen_solver=='dense'.

    max_iter : int, default=100
        Maximum number of iterations for 'arpack' method.
        Not used if eigen_solver=='dense'

    random_state : int, RandomState instance, default=None
        Determines the random number generator when ``solver`` == 'arpack'.
        Pass an int for reproducible results across multiple function calls.
        See :term:`Glossary <random_state>`.
    autor      
   rR   denseg        )sigmatolmaxiterv0a	  Error in determining null-space with ARPACK. Error message: '%s'. Note that eigen_solver='arpack' can fail when the weight matrix is singular or otherwise ill-behaved. In that case, eigen_solver='dense' is recommended. See online documentation for more information.Ntoarrayr"   T)subset_by_indexoverwrite_azUnrecognized eigen_solver '%s')r&   r   r   RuntimeError
ValueErrorr'   r/   hasattrr^   r   argsortabs)Mkk_skipeigen_solverr[   max_iterrandom_stater]   eigen_valueseigen_vectorseindexs               r?   
null_spacerp   |   s   T v71:F
R#LL"LxQWQZ66	*/1v:Sc8+ + +'L--  	 	 	6 9:	:  	 QQQZ("&fgg1F*G*GGG		 	 1i   			A&*F
Q7T'
 '
 '
#m 
26,//00QQQX&|(<(<<<9LHIIIs   A$ $
B.BBrV   standard-C6?-q=)	r3   ri   r[   rj   methodhessian_tolmodified_tolrk   rD   c          	         t          |dz   |          }|                    |            |j        } | j        \  }}||k    rt	          d          ||k    rt	          d||fz            |dk    }|rt
          nt          j        }|dk    rt          ||||          }|r%t          |j        d|j
        i|z
  }|j        |z  }	nd|j        |z  |j        z
  |z
                                  }|j        d d |j        d	         dz   xx         dz  cc<   	n|d
k    rI||dz   z  dz  }|||z   k    rt	          d          |                    | |dz   d          }|d d dd f         }t          j        |d|z   |z   ft          j                  }d|d d d	f<    |||ft          j                  }||k    }t#          |          D ]}| ||                  }||                    d	          z  }|rt'          |d	          d	         }n<t          j        ||j                  }t+          |          d         d d d d df         }|d d d |f         |d d dd|z   f<   d|z   }t#          |          D ]9}|d d ||dz   f         |d d ||f         z  |d d |||z   |z
  f<   |||z
  z  }:t-          |          \  }}|d d |dz   d f         }|                    d	          } d| t          j        t3          |           |k               <   || z  }t          j        ||         ||                   \  }!}"||!|"fxx         t          j        ||j                  z  cc<   n|dk    r||k     rt	          d          |                    | |dz   d          }|d d dd f         }t          j        |||f          }#t7          ||          }$t          j        ||$g          }%||k    }|rJt#          |          D ]4}| ||                  | |         z
  }&t'          |&d          \  |#|<   |%|<   }'5|%dz  }%nut#          |          D ]e}| ||                  | |         z
  }&t          j        |&|&j                  }(t+          |(          \  })}*|)d d d         |%|<   |*d d d d df         |#|<   fd|%                    d          z  }t          j        |#                    d	dd          t          j        |                    }+|+d d d |$fxx         |%|d d d f         z   z  cc<   |+d d |$d fxx         |d d d f         z  cc<   t          j        ||f          },t#          |          D ]&}t          j        |#|         |+|                   |,|<   '|,|,                    d          d d d f         z  },|%d d |d f                             d          |%d d d |f                             d          z  }-t          j        |-          }.t          j        |t>                    }/tA          |%d          }0|0d d dd f         |0d d d df         z  dz
  }1t#          |          D ]%}t          j!        |1|d d df         |.          |/|<   &|/||$z
  z  }/ |||ft          j                  }t#          |          D ]}|/|         }2|#|d d ||2z
  d f         }3t          j"        #                    |3                    d	                    t          j$        |2          z  }4t          j%        |2|4          t          j        |3j        t          j        |                    z
  }5t          j"        #                    |5          }6|6|	k     r|5d	z  }5n|5|6z  }5|3dt          j&        t          j        |3|5          |5          z  z
  d|4z
  |,|d d d f         z  z   }7t          j        ||         ||                   \  }!}"||!|"fxx         t          j        |7|7j                  z  cc<   |7                    d          }8||||         fxx         |8z  cc<   |||         |gfxx         |8z  cc<   |||fxx         |2z  cc<   n|dk    r|                    | |dz   d          }|d d dd f         } |||ft          j                  }||k    }t#          |          D ]N}| ||                  }9|9|9                    d	          z  }9|rt'          |9d          d	         }:n<t          j        |9|9j                  }t+          |          d         d d d d df         }:t          j        ||dz   f          }|:d d d |f         |d d dd f<   dt          j$        |          z  |d d d	f<   t          j        ||j                  };t          j        ||         ||                   \  }!}"||!|"fxx         |;z  cc<   |||         ||         fxx         t          j        |          z  cc<   P|r|'                                }tQ          ||d||||
          S )Nr"   rC   z>output dimension must be less than or equal to input dimensionzHExpected n_neighbors <= n_samples,  but n_samples = %d, n_neighbors = %drY   rq   )r5   r3   rD   formatr   hessianr   z^for method='hessian', n_neighbors must be greater than [n_components * (n_components + 3) / 2]Fr5   rE   r    )full_matricesmodifiedz1modified LLE requires n_neighbors >= n_componentsTr   ltsag      ?rG   )rh   ri   r[   rj   rk   ))r   rH   rI   r&   rb   r   r'   zerosrQ   r
   rx   r,   r^   r.   rK   r(   float64rangemeanr   r+   r   r   r/   wherere   meshgridmin	transposer)   medianr%   r   searchsortedlinalgnormsqrtfulloutertocsrrp   )<r0   r5   n_componentsr3   ri   r[   rj   rt   ru   rv   rk   rD   nbrsNd_inM_sparseM_container_constructorWrf   dp	neighborsYiuse_svdr8   GiUCijrg   Qr=   r>   Snbrs_xnbrs_yVnevevalsX_nbrs_C_nbrsevivitmpw_regrhoetas_rangeevals_cumsum	eta_ranges_iVialpha_ihnorm_hWiWi_sum1Xir7   GiGiTs<                                                               r?   _locally_linear_embeddingr      s    aGGGDHHQKKKAgGAtdL
 
 	
 aV+
 
 	

 w&H,4Bjj"('ks6
 
 
  	+QW.QX..2AaAAq13"++--AF$$agaj1n$%%%*%%%%	9		\A-.!3,+++:   OO;?E $ 
 
	 aaae$	X{A$4r$9:"*MMM111a4##QF"*===$q 	0 	0A9Q<B"''!**B  )!,,,Q/VB%%HHQK44R4(*+AAA}},<*=Bqqq!a,&&&'L A<(( & &23AAAq1q5yL/Aaaa<FWDX2X111a!l*Q.../\A%%b66DAq!!!\A%'''(AaA01Abhs1vv+,,-FA[1y|DDNFFffn13/7	0: 
:		%%PQQQOO;?E $ 
 
	 aaae$	
 Hak233$$$!S"" $ 	#1XX D D9Q<1Q4/$'d$C$C$C!!eAhaKEE1XX # #9Q<1Q4/11v,,Rttt9a!!!TTrT'{!
 UYYq\\!fQ[[Aq))27;+?+?@@AAAttGAAAtG,,AAAsttGAAAtG$![)**q 	, 	,AvadCF++E!HH1aaag&& AAA|}}$%))!,,uQQQ5E/F/J/J1/M/MMinn
 (1C((($UA.. BCC(<3B3+??!C	q 	B 	BA1ddd7);SAAGAJJ;$$ $#QF"*===q $	 $	A!*C 1aaas*,,,-BinnRVVAYY//"'#,,>G
 W%%rtRW[5I5I(J(JJAY^^A&&F$$QV a"(26"a==!4444GuQPQPQPQSWZGX7XXB  [1y|DDNFFffnBD!1!11ffQiiGa1o')ilQC   G+   adGGGsNGGGGI$	L 
6		OO;?E $ 
 
	 aaae$	##QF"*===$q 	H 	HA9Q<B"''!**B  )$///2VB%%HHQK44R4(;q(89::B!!!]l]*+Bqqq!""uIRW[111Bqqq!tHF2rt$$E[1y|DDNFFffn&ilIaL()))RW;-G-G-GG)))) GGII	!!   rA   z
array-likeleftclosed>   rV   rY   rR   >   r~   ry   r}   rq   rk   r0   r5   r   r3   ri   r[   rj   rt   ru   rv   rk   rD   Tprefer_skip_nested_validationc                8    t          | |||||||||	|
|          S )a  Perform a Locally Linear Embedding analysis on the data.

    Read more in the :ref:`User Guide <locally_linear_embedding>`.

    Parameters
    ----------
    X : {array-like, NearestNeighbors}
        Sample data, shape = (n_samples, n_features), in the form of a
        numpy array or a NearestNeighbors object.

    n_neighbors : int
        Number of neighbors to consider for each point.

    n_components : int
        Number of coordinates for the manifold.

    reg : float, default=1e-3
        Regularization constant, multiplies the trace of the local covariance
        matrix of the distances.

    eigen_solver : {'auto', 'arpack', 'dense'}, default='auto'
        auto : algorithm will attempt to choose the best method for input data

        arpack : use arnoldi iteration in shift-invert mode.
                    For this method, M may be a dense matrix, sparse matrix,
                    or general linear operator.
                    Warning: ARPACK can be unstable for some problems.  It is
                    best to try several random seeds in order to check results.

        dense  : use standard dense matrix operations for the eigenvalue
                    decomposition.  For this method, M must be an array
                    or matrix type.  This method should be avoided for
                    large problems.

    tol : float, default=1e-6
        Tolerance for 'arpack' method
        Not used if eigen_solver=='dense'.

    max_iter : int, default=100
        Maximum number of iterations for the arpack solver.

    method : {'standard', 'hessian', 'modified', 'ltsa'}, default='standard'
        standard : use the standard locally linear embedding algorithm.
                   see reference [1]_
        hessian  : use the Hessian eigenmap method.  This method requires
                   n_neighbors > n_components * (1 + (n_components + 1) / 2.
                   see reference [2]_
        modified : use the modified locally linear embedding algorithm.
                   see reference [3]_
        ltsa     : use local tangent space alignment algorithm
                   see reference [4]_

    hessian_tol : float, default=1e-4
        Tolerance for Hessian eigenmapping method.
        Only used if method == 'hessian'.

    modified_tol : float, default=1e-12
        Tolerance for modified LLE method.
        Only used if method == 'modified'.

    random_state : int, RandomState instance, default=None
        Determines the random number generator when ``solver`` == 'arpack'.
        Pass an int for reproducible results across multiple function calls.
        See :term:`Glossary <random_state>`.

    n_jobs : int or None, default=None
        The number of parallel jobs to run for neighbors search.
        ``None`` means 1 unless in a :obj:`joblib.parallel_backend` context.
        ``-1`` means using all processors. See :term:`Glossary <n_jobs>`
        for more details.

    Returns
    -------
    Y : ndarray of shape (n_samples, n_components)
        Embedding vectors.

    squared_error : float
        Reconstruction error for the embedding vectors. Equivalent to
        ``norm(Y - W Y, 'fro')**2``, where W are the reconstruction weights.

    References
    ----------

    .. [1] Roweis, S. & Saul, L. Nonlinear dimensionality reduction
        by locally linear embedding.  Science 290:2323 (2000).
    .. [2] Donoho, D. & Grimes, C. Hessian eigenmaps: Locally
        linear embedding techniques for high-dimensional data.
        Proc Natl Acad Sci U S A.  100:5591 (2003).
    .. [3] `Zhang, Z. & Wang, J. MLLE: Modified Locally Linear
        Embedding Using Multiple Weights.
        <https://citeseerx.ist.psu.edu/doc_view/pid/0b060fdbd92cbcc66b383bcaa9ba5e5e624d7ee3>`_
    .. [4] Zhang, Z. & Zha, H. Principal manifolds and nonlinear
        dimensionality reduction via tangent space alignment.
        Journal of Shanghai Univ.  8:406 (2004)

    Examples
    --------
    >>> from sklearn.datasets import load_digits
    >>> from sklearn.manifold import locally_linear_embedding
    >>> X, _ = load_digits(return_X_y=True)
    >>> X.shape
    (1797, 64)
    >>> embedding, _ = locally_linear_embedding(X[:100],n_neighbors=5, n_components=2)
    >>> embedding.shape
    (100, 2)
    r   )r   r   s               r?   locally_linear_embeddingr     s@    T %
!!!!   rA   c                      e Zd ZU dZ eeddd          g eeddd          g eeddd          g eh d          g eeddd          g eeddd          g eh d          g eeddd          g eeddd          g eh d	          gd
gdegdZe	e
d<   ddddddddddddddZd Z ed          dd            Z ed          dd            Zd ZdS )LocallyLinearEmbeddinga  Locally Linear Embedding.

    Read more in the :ref:`User Guide <locally_linear_embedding>`.

    Parameters
    ----------
    n_neighbors : int, default=5
        Number of neighbors to consider for each point.

    n_components : int, default=2
        Number of coordinates for the manifold.

    reg : float, default=1e-3
        Regularization constant, multiplies the trace of the local covariance
        matrix of the distances.

    eigen_solver : {'auto', 'arpack', 'dense'}, default='auto'
        The solver used to compute the eigenvectors. The available options are:

        - `'auto'` : algorithm will attempt to choose the best method for input
          data.
        - `'arpack'` : use arnoldi iteration in shift-invert mode. For this
          method, M may be a dense matrix, sparse matrix, or general linear
          operator.
        - `'dense'`  : use standard dense matrix operations for the eigenvalue
          decomposition. For this method, M must be an array or matrix type.
          This method should be avoided for large problems.

        .. warning::
           ARPACK can be unstable for some problems.  It is best to try several
           random seeds in order to check results.

    tol : float, default=1e-6
        Tolerance for 'arpack' method
        Not used if eigen_solver=='dense'.

    max_iter : int, default=100
        Maximum number of iterations for the arpack solver.
        Not used if eigen_solver=='dense'.

    method : {'standard', 'hessian', 'modified', 'ltsa'}, default='standard'
        - `standard`: use the standard locally linear embedding algorithm. see
          reference [1]_
        - `hessian`: use the Hessian eigenmap method. This method requires
          ``n_neighbors > n_components * (1 + (n_components + 1) / 2``. see
          reference [2]_
        - `modified`: use the modified locally linear embedding algorithm.
          see reference [3]_
        - `ltsa`: use local tangent space alignment algorithm. see
          reference [4]_

    hessian_tol : float, default=1e-4
        Tolerance for Hessian eigenmapping method.
        Only used if ``method == 'hessian'``.

    modified_tol : float, default=1e-12
        Tolerance for modified LLE method.
        Only used if ``method == 'modified'``.

    neighbors_algorithm : {'auto', 'brute', 'kd_tree', 'ball_tree'},                           default='auto'
        Algorithm to use for nearest neighbors search, passed to
        :class:`~sklearn.neighbors.NearestNeighbors` instance.

    random_state : int, RandomState instance, default=None
        Determines the random number generator when
        ``eigen_solver`` == 'arpack'. Pass an int for reproducible results
        across multiple function calls. See :term:`Glossary <random_state>`.

    n_jobs : int or None, default=None
        The number of parallel jobs to run.
        ``None`` means 1 unless in a :obj:`joblib.parallel_backend` context.
        ``-1`` means using all processors. See :term:`Glossary <n_jobs>`
        for more details.

    Attributes
    ----------
    embedding_ : array-like, shape [n_samples, n_components]
        Stores the embedding vectors

    reconstruction_error_ : float
        Reconstruction error associated with `embedding_`

    n_features_in_ : int
        Number of features seen during :term:`fit`.

        .. versionadded:: 0.24

    feature_names_in_ : ndarray of shape (`n_features_in_`,)
        Names of features seen during :term:`fit`. Defined only when `X`
        has feature names that are all strings.

        .. versionadded:: 1.0

    nbrs_ : NearestNeighbors object
        Stores nearest neighbors instance, including BallTree or KDtree
        if applicable.

    See Also
    --------
    SpectralEmbedding : Spectral embedding for non-linear dimensionality
        reduction.
    TSNE : Distributed Stochastic Neighbor Embedding.

    References
    ----------

    .. [1] Roweis, S. & Saul, L. Nonlinear dimensionality reduction
        by locally linear embedding.  Science 290:2323 (2000).
    .. [2] Donoho, D. & Grimes, C. Hessian eigenmaps: Locally
        linear embedding techniques for high-dimensional data.
        Proc Natl Acad Sci U S A.  100:5591 (2003).
    .. [3] `Zhang, Z. & Wang, J. MLLE: Modified Locally Linear
        Embedding Using Multiple Weights.
        <https://citeseerx.ist.psu.edu/doc_view/pid/0b060fdbd92cbcc66b383bcaa9ba5e5e624d7ee3>`_
    .. [4] Zhang, Z. & Zha, H. Principal manifolds and nonlinear
        dimensionality reduction via tangent space alignment.
        Journal of Shanghai Univ.  8:406 (2004)

    Examples
    --------
    >>> from sklearn.datasets import load_digits
    >>> from sklearn.manifold import LocallyLinearEmbedding
    >>> X, _ = load_digits(return_X_y=True)
    >>> X.shape
    (1797, 64)
    >>> embedding = LocallyLinearEmbedding(n_components=2)
    >>> X_transformed = embedding.fit_transform(X[:100])
    >>> X_transformed.shape
    (100, 2)
    r"   Nr   r   r   >   rV   rY   rR   >   r~   ry   r}   rq   >   rV   brutekd_tree	ball_treerk   )r5   r   r3   ri   r[   rj   rt   ru   rv   neighbors_algorithmrk   rD   _parameter_constraints   r   r   rV   rS   rT   rq   rr   rs   c                    || _         || _        || _        || _        || _        || _        || _        || _        |	| _        || _	        |
| _
        || _        d S N)r5   r   r3   ri   r[   rj   rt   ru   rv   rk   r   rD   )selfr5   r   r3   ri   r[   rj   rt   ru   rv   r   rk   rD   s                r?   __init__zLocallyLinearEmbedding.__init__  sc      '(( &((#6 rA   c                    t          | j        | j        | j                  | _        t          | j                  }t          | |t                    }| j        	                    |           t          | j        | j        | j        | j        | j        | j        | j        | j        | j        || j        | j                  \  | _        | _        | j        j        d         | _        d S )N)r5   	algorithmrD   r    )r0   r5   r   ri   r[   rj   rt   ru   rv   rk   r3   rD   r"   )r   r5   r   rD   nbrs_r   rk   r   floatrH   r   r   ri   r[   rj   rt   ru   rv   r3   
embedding_reconstruction_error_r&   _n_features_out)r   r0   rk   s      r?   _fit_transformz%LocallyLinearEmbedding._fit_transform  s    %(.;
 
 

 *$*;<<$///
q6Oj(**];(*%;7
 7
 7
33  $4Q7rA   Tr   c                 0    |                      |           | S )ay  Compute the embedding vectors for data X.

        Parameters
        ----------
        X : array-like of shape (n_samples, n_features)
            Training set.

        y : Ignored
            Not used, present here for API consistency by convention.

        Returns
        -------
        self : object
            Fitted `LocallyLinearEmbedding` class instance.
        )r   r   r0   ys      r?   rH   zLocallyLinearEmbedding.fit*  s    " 	ArA   c                 :    |                      |           | j        S )a  Compute the embedding vectors for data X and transform X.

        Parameters
        ----------
        X : array-like of shape (n_samples, n_features)
            Training set.

        y : Ignored
            Not used, present here for API consistency by convention.

        Returns
        -------
        X_new : array-like, shape (n_samples, n_components)
            Returns the instance itself.
        )r   r   r   s      r?   fit_transformz$LocallyLinearEmbedding.fit_transform>  s     " 	ArA   c                    t          |            t          | |d          }| j                            || j        d          }t          || j        j        || j                  }t          j	        |j
        d         | j        f          }t          |j
        d                   D ]6}t          j        | j        ||                  j        ||                   ||<   7|S )a  
        Transform new points into embedding space.

        Parameters
        ----------
        X : array-like of shape (n_samples, n_features)
            Training set.

        Returns
        -------
        X_new : ndarray of shape (n_samples, n_components)
            Returns the instance itself.

        Notes
        -----
        Because of scaling performed by this method, it is discouraged to use
        it together with methods that are not scale-invariant (like SVMs).
        F)resetrz   rF   r   )r   r   r   rK   r5   r@   rI   r3   r'   r(   r&   r   r   r+   r   r,   )r   r0   r9   weightsX_newr8   s         r?   	transformz LocallyLinearEmbedding.transformR  s    & 	$///j##4+U $ 
 
 %Q
(93DHMMM!'!*d&7899qwqz"" 	E 	EAvdoc!f57DDE!HHrA   r   )__name__
__module____qualname____doc__r   r   r   r   r   dict__annotations__r   r   r   rH   r   r    rA   r?   r   r   Z  s        B BJ !1d6BBBC!(AtFCCCDq$v6667#$?$?$?@@Aq$v6667Xh4???@:IIIJJK q$v>>>?!$4???@ *
+T+T+T U UV'("$ $D   $ "    :8 8 84 \555   65& \555   65&    rA   r   )r   )r   N)r"   rR   rS   rT   N).r   numbersr   r   numpyr'   scipy.linalgr   r   r   r   scipy.sparser	   r
   r   scipy.sparse.linalgr   baser   r   r   r   r   r   r   utilsr   r   utils._arpackr   utils._param_validationr   r   r   utils.extmathr   utils.validationr   r   r   r@   rQ   rp   r   r   r   r   rA   r?   <module>r      s    
 # " " " " " " "     - - - - - - - - - - - - 4 4 4 4 4 4 4 4 4 4 % % % % % %              ) ( ( ( ( ( 3 3 3 3 3 3 3 3 + + + + + + K K K K K K K K K K ) ) ) ) ) ) K K K K K K K K K K3 3 3 3l'Y 'Y 'Y 'YV QUIJ IJ IJ IJb 	u u u u up ,- 1d6BBBC!(AtFCCCDq$v6667#$?$?$?@@Aq$v6667Xh4???@:IIIJJK q$v>>>?!$4???@'("  #'  , 	F F F F# "FRU U U U U#	U U U U UrA   