
    Mpjx                         S r SSKJrJr  SSKrSSKJrJrJ	r	J
r
  SSKJrJr  SSKJr  SSKJrJrJrJrJr  SSKJr  SS	KJrJr  SS
KJr  SSKJrJrJ r   SSK!J"r"  SSK#J$r$J%r%  SSK&J'r'J(r(J)r)  S(S jr*S)S jr+ S*S jr,SSSSSSSSSS.	S jr-\ " S\/\" \SSSS9/\" \SSSS9/\" \SSSS9/\" 1 Sk5      /\" \SSSS9/\" \SSSS9/\" 1 S k5      /\" \SSSS9/\" \SSSS9/S!/S\/S".S#S$9SSSSSSSSSS.	S% j5       r. " S& S'\\\\5      r/g)+zLocally Linear Embedding    )IntegralRealN)eighqrsolvesvd)	csr_array	lil_array)eigsh)BaseEstimatorClassNamePrefixFeaturesOutMixinTransformerMixin_fit_context_UnstableArchMixin)NearestNeighbors)check_arraycheck_random_state)_init_arpack_v0)Interval
StrOptionsvalidate_params)_align_api_if_sparse)SCIPY_VERSION_BELOW_1_15_sparse_eye_array)FLOAT_DTYPEScheck_is_fittedvalidate_dataMbP?c                 l   [        U [        S9n [        U[        S9n[        U[        S9nUR                  u  pEU R                  S   U:X  d   e[        R
                  " XE4U R                  S9n[        R                  " XPR                  S9n[        U5       H  u  pX   n
XU   -
  n[        R                  " XR                  5      n[        R                  " U5      nUS:  a  X=-  nOUnUR                  SSUS-   2==   U-  ss'   [        XSS9nU[        R                  " U5      -  XhSS24'   M     U$ )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/pdf-tiff/venv/lib/python3.13/site-packages/sklearn/manifold/_locally_linear.pybarycenter_weightsr@      s   6 	A\*AA\*A'-G$]]I771:"""
))9A
77+A G$F!HFF1ccN19AA	!+/!"a'"!'bffQi-Q$ % H    c                 T   [        US-   US9R                  U 5      nUR                  n UR                  nUR	                  U SS9SS2SS24   n[        X XbS9n[        R                  " SXQ-  S-   U5      n[        UR                  5       UR                  5       U4XU4S9n	[        U	5      $ )	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	   ravelr   )
r0   r5   r3   rD   knnr4   r9   dataindptrcsrs
             r?   barycenter_kneighbors_graphrR   S   s    B {Qv
F
J
J1
MC

A""I
..E.
21ab5
9CaC1DYYq)1A5{CF
TZZ\399;7	?U
VC$$rA   r"   ư>d   c           	      Z   US:X  a   U R                   S   S:  a  X-   S:  a  SnOSnUS:X  aN  [        U R                   S   U5      n [        XU-   SXEUS9u  pU	S
S
2US
24   [
        R                  " XS
 5      4$ US:X  a}  [        U S5      (       a  U R                  5       n [        XX-   S-
  4SS9u  p[
        R                  " [
        R                  " U5      5      nU	S
S
2U4   [
        R                  " U5      4$ [	        SU-  5      e! [         a  n
[	        S	U
-  5      U
eS
n
A
ff = f)a  
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      
   arpack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_spacerq   ~   sG   T v771:
R#L"LxQWWQZ6	*/v:Sc+'L QZ("&&g1F*GGG		 1i  		A&*
Q7T'
# 

266,/0QX&|(<<<9LHII'  	6 9:	: 	s   D 
D*D%%D*rV   standard-C6?-q=)	r3   rj   r\   rk   methodhessian_tolmodified_tolrl   rD   c          
         [        US-   US9nUR                  U 5        UR                  n U R                  u  pX.:  a  [	        S5      eX:  a  [	        SX4-  5      eUS:g  nU(       a  [
        O[        R                  nUS:X  a  [        XX;S9nU(       a>  [        UR                  UR                  UR                  S.6U-
  nUR                  U-  nGOUR                  U-  UR                  -
  U-
  R                  5       nUR                  S S UR                  S	   S-   2==   S-  ss'   GOyUS
:X  Ga  X"S-   -  S-  nXU-   ::  a  [	        S5      eUR                  XS-   SS9nUS S 2SS 24   n[        R                   " USU-   U-   4[        R"                  S9nSUS S 2S	4'   U" X4[        R"                  S9nX:  n[%        U5       GHr  nU UU      nUUR'                  S	5      -  nU(       a  [)        US	S9S	   nO9[        R*                  " UUR                  5      n[-        U5      S   S S 2S S S24   nUS S 2S U24   US S 2SSU-   24'   SU-   n[%        U5       H4  nUS S 2UUS-   24   US S 2UU24   -  US S 2UUU-   U-
  24'   UUU-
  -  nM6     [/        U5      u  nnUS S 2US-   S 24   nUR1                  S	5      n SU [        R2                  " [5        U 5      U:  5      '   UU -  n[        R6                  " UU   UU   5      u  n!n"UU!U"4==   [        R*                  " UUR                  5      -  ss'   GMu     GOeUS:X  Ga  X:  a  [	        S5      eUR                  XS-   SS9nUS S 2SS 24   n[        R                  " XU45      n#[9        X5      n$[        R                  " UU$/5      n%X:  nU(       a:  [%        U5       H%  nU UU      U U   -
  n&[)        U&SS9u  U#U'   U%U'   n'M'     U%S-  n%Oi[%        U5       HZ  nU UU      U U   -
  n&[        R*                  " U&U&R                  5      n([-        U(5      u  n)n*U)S S S2   U%U'   U*S S 2S S S24   U#U'   M\     SU%R1                  S5      -  n[        R*                  " U#R;                  S	SS5      [        R<                  " U5      5      n+U+S S 2S U$24==   U%US S 2S 4   -   -  ss'   U+S S 2U$S 24==   US S 2S 4   -  ss'   [        R                  " X45      n,[%        U5       H#  n[        R*                  " U#U   U+U   5      U,U'   M%     U,U,R1                  S5      S S 2S 4   -  n,U%S S 2US 24   R1                  S5      U%S S 2S U24   R1                  S5      -  n-[        R>                  " U-5      n.[        R                  " U[@        S9n/[        RB                  " U%S5      n0U0S S 2SS 24   U0S S 2S S24   -  S-
  n1[%        U5       H%  n[        RD                  " U1US S S24   U.5      U/U'   M'     U/UU$-
  -  n/U" X4[        R"                  S9n[%        U5       GH  nU/U   n2U#US S 2UU2-
  S 24   n3[        RF                  RI                  U3R1                  S	5      5      [        RJ                  " U25      -  n4[        RL                  " U2U45      [        R*                  " U3R                  [        R<                  " U5      5      -
  n5[        RF                  RI                  U55      n6U6U	:  a  U5S	-  n5OU5U6-  n5U3S[        RN                  " [        R*                  " U3U55      U55      -  -
  SU4-
  U,US S 2S 4   -  -   n7[        R6                  " UU   UU   5      u  n!n"UU!U"4==   [        R*                  " U7U7R                  5      -  ss'   U7R1                  S5      n8[P        (       a'  UU/UU   4==   U8-  ss'   UUU   U/4==   U8-  ss'   O$UUUU   4==   U8-  ss'   UUU   U4==   U8-  ss'   UUU4==   U2-  ss'   GM     GOUS:X  Ga{  UR                  XS-   SS9nUS S 2SS 24   nU" X4[        R"                  S9nX:  n[%        U5       GH3  nU UU      n9U9U9R'                  S	5      -  n9U(       a  [)        U9SS9S	   n:O9[        R*                  " U9U9R                  5      n[-        U5      S   S S 2S S S24   n:[        R                  " XS-   45      nU:S S 2S U24   US S 2SS 24'   S[        RJ                  " U5      -  US S 2S	4'   [        R*                  " UUR                  5      n;[        R6                  " UU   UU   5      u  n!n"UU!U"4==   U;-  ss'   UUU   UU   4==   [        R<                  " US9-  ss'   GM6     U(       a  [S        WRU                  5       5      n[W        WUSUUUU
S9$ )Nr"   rC   z>output dimension must be less than or equal to input dimensionzFExpected n_neighbors < n_samples, but n_samples = %d, n_neighbors = %drZ   rr   )r5   r3   rD   )formatr!   r   hessian   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   )ri   rj   r\   rk   rl   ),r   rH   rI   r&   rc   r
   r'   zerosrR   r   ry   r!   r,   r_   r.   rK   r(   float64rangemeanr   r+   r   r   r/   whererf   meshgridmin	transposer)   medianr%   cumsumsearchsortedlinalgnormsqrtfullouterr   r   tocsrrq   )<r0   r5   n_componentsr3   rj   r\   rk   ru   rv   rw   rl   rD   nbrsNd_inM_sparseM_container_constructorWrg   dp	neighborsYiuse_svdr8   GiUCijrh   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GDHHQKAggGAL
 	
 T
 	

 w&H+3i's
 !177188177KaOAaAq133"++-AFF$aggaj1n$%*%	9	A-.!3++:  OO?E $ 
	 ae$	XX{A$4r$9:"**M1a4#QF"**=$qA9Q<B"''!*B !,Q/VVB%HQK4R4(*+A}},<*=Bq!a,&&&'L A<(23Aq1q5yL/Aa<FWDX2X1a!l*Q.../\A%% ) b6DAq!\A%''(AaA01Abhhs1v+,-FA[[1y|DNFFffn133/7 : 
:	%PQQOO?E $ 
	 ae$	
 HHak23$$!S" $1X9Q<1Q4/$'d$C!!eAh  aKE1X9Q<1Q4/1v,Rtt9a!TrT'{!  UYYq\!ffQ[[Aq)277;+?@AttGAtG,,AstGAtG$!)*qAvvadCF+E!H 1ag&& A|}$%))!,uQ5E/F/J/J1/MMiin
 ((1C(yy* BC(<3B3+??!C	qA1dd7);SAGAJ ;$$ $QF"**=qA!*C 1as*,,-BiinnRVVAY/"''#,>G
 W%rttRWW[5I(JJAYY^^A&F$QV a"((266"a=!444GuQPQSWZGX7XXB  [[1y|DNFFffnBDD!11ffQiG''1#y|#$/$)A,#$/$!Yq\/"g-")A,/"g-"adGsNGQ T 
6	OO?E $ 
	 ae$	#QF"**=$qA9Q<B"''!*B $/2VVB%HQK4R4(;q(89:B!]l]*+Bq!"uIRWW[11Bq!tHFF2rtt$E[[1y|DNFFffn&ilIaL()RWW;-GG)) ,  +	!! rA   z
array-likeleftclosed>   rV   rZ   rY   >   r   rz   r   rr   rl   r0   r5   r   r3   rj   r\   rk   ru   rv   rw   rl   rD   Tprefer_skip_nested_validationc                *    [        U UUUUUUUUU	U
US9$ )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     s6    T %
!!!! rA   c                   V   \ rS rSr% Sr\" \SSSS9/\" \SSSS9/\" \SSSS9/\" 1 Sk5      /\" \SSSS9/\" \SSSS9/\" 1 S	k5      /\" \SSSS9/\" \SSSS9/\" 1 S
k5      /S/S\/S.r	\
\S'   SSSSSSSSSSSSS.S jrS r\" SS9SS j5       r\" SS9SS j5       rS rSrg) LocallyLinearEmbeddingi`  a  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   rZ   rY   >   r   rz   r   rr   >   rV   brutekd_tree	ball_treerl   )r5   r   r3   rj   r\   rk   ru   rv   rw   neighbors_algorithmrl   rD   _parameter_constraints   r{   r   rV   rS   rT   rr   rs   rt   c                    Xl         X l        X0l        X@l        XPl        X`l        Xpl        Xl        Xl        Xl	        Xl
        Xl        g N)r5   r   r3   rj   r\   rk   ru   rv   rw   rl   r   rD   )selfr5   r   r3   rj   r\   rk   ru   rv   rw   r   rl   rD   s                r?   __init__LocallyLinearEmbedding.__init__  sG      '(( &((#6 rA   c                 6   [        U R                  U R                  U R                  S9U l        [        U R                  5      n[        X[        S9nU R                  R                  U5        [        U R                  U R                  U R                  U R                  U R                  U R                  U R                  U R                   U R"                  UU R$                  U R                  S9u  U l        U l        U R&                  R*                  S   U l        g )N)r5   	algorithmrD   r    )r0   r5   r   rj   r\   rk   ru   rv   rw   rl   r3   rD   r"   )r   r5   r   rD   nbrs_r   rl   r   floatrH   r   r   rj   r\   rk   ru   rv   rw   r3   
embedding_reconstruction_error_r&   _n_features_out)r   r0   rl   s      r?   _fit_transform%LocallyLinearEmbedding._fit_transform  s    %((..;;

 *$*;*;<$/

q6Ojj((****]];;((**%;;7
33  $44Q7rA   Tr   c                 (    U R                  U5        U $ )a!  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   LocallyLinearEmbedding.fit0  s    " 	ArA   c                 <    U R                  U5        U R                  $ )aD  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_transform$LocallyLinearEmbedding.fit_transformD  s    " 	ArA   c                    [        U 5        [        XSS9nU R                  R                  XR                  SS9n[        XR                  R                  X R                  S9n[        R                  " UR                  S   U R                  45      n[        UR                  S   5       H7  n[        R                  " U R                  X%      R                  X5   5      XE'   M9     U$ )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)resetr|   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?   	transform LocallyLinearEmbedding.transformX  s    & 	$/jj##++U $ 
 %Q

(9(93HHM!''!*d&7&789qwwqz"Avvdoocf577DEH #rA   )r   rj   r   rv   rk   ru   rw   r   rD   r5   r   r   rl   r   r3   r\   r   )__name__
__module____qualname____firstlineno____doc__r   r   r   r   r   dict__annotations__r   r   r   rH   r   r   __static_attributes__ rA   r?   r   r   `  s*   BJ !1d6BC!(AtFCDq$v67#$?@Aq$v67h4?@IJK q$v>?!$4?@ *+T UV'("$D $ ":84 5 6& 5 6&rA   r   )r   )r   N)r"   rY   rS   rT   N)0r   numbersr   r   numpyr'   scipy.linalgr   r   r   r   scipy.sparser	   r
   scipy.sparse.linalgr   sklearn.baser   r   r   r   r   sklearn.neighborsr   sklearn.utilsr   r   sklearn.utils._arpackr   sklearn.utils._param_validationr   r   r   sklearn.utils._sparser   sklearn.utils.fixesr   r   sklearn.utils.validationr   r   r   r@   rR   rq   r   r   r   r   rA   r?   <module>r      s   
 #  - - - %  / 9 1 Q Q 6 K Q Q3l(%X QUIJb 	yx ,- 1d6BC!(AtFCDq$v67#$?@Aq$v67h4?@IJK q$v>?!$4?@'(" #', 	F#"FRU#	UrA   