
    Ug-w                     |   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 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% 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)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_fittedMbP?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/surfInsights/venv3-11/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    r3   n_jobsF)return_distanceNr1   r   )r$   )
r   fit_fit_Xn_samples_fit_
kneighborsr>   r%   aranger	   ravel)	r.   r3   r1   rB   knnr2   r7   dataindptrs	            r=   barycenter_kneighbors_graphrN   S   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Xr?   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      
   rO   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_solverrX   max_iterrandom_staterZ   eigen_valueseigen_vectorseindexs               r=   
null_spacerm   }   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rS   standard-C6?-q=)	r1   rf   rX   rg   methodhessian_tolmodified_tolrh   rB   c          	         t          |dz   |          }|                    |            |j        } | j        \  }}||k    rt	          d          ||k    rt	          d||fz            |dk    }|dk    rt          ||||          }|r7t          |j        d|j        i|z
  }|j        |z  	                                }	n|j        |z  |j        z
  |z
  
                                }|j        d d |j        d	         dz   xx         dz  cc<   	n2|d
k    rc||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<   t          j        ||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<   |rt7          |          }n|dk    r)||k     rt	          d          |                    | |dz   d          }|d d dd f         }t          j        |||f          }"t9          ||          }#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@                    }.tC          |$d          }/|/d d dd f         |/d d d df         z  dz
  }0t#          |          D ]%}t          j"        |0|d d df         |-          |.|<   &|.||#z
  z  }.t          j        ||ft          j                  }t#          |          D ]}|.|         }1|"|d d ||1z
  d f         }2t          j#        $                    |2                    d	                    t          j%        |1          z  }3t          j&        |1|3          t          j        |2j        t          j        |                    z
  }4t          j#        $                    |4          }5|5|	k     r|4d	z  }4n|4|5z  }4|2dt          j'        t          j        |2|4          |4          z  z
  d|3z
  |+|d d d f         z  z   }6t          j        ||         ||                   \  } }!|| |!fxx         t          j        |6|6j                  z  cc<   |6                    d          }7||||         fxx         |7z  cc<   |||         |fxx         |7z  cc<   |||fxx         |1z  cc<   |rt7          |          }n|dk    r|                    | |dz   d          }|d d dd f         }t          j        ||f          }||k    }t#          |          D ];}| ||                  }8|8|8                    d	          z  }8|rt'          |8d          d	         }9n<t          j        |8|8j                  }t+          |          d         d d d d df         }9t          j        ||dz   f          }|9d 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         dz  cc<   =tQ          ||d||||
          S )Nr    rA   z>output dimension must be less than or equal to input dimensionzHExpected n_neighbors <= n_samples,  but n_samples = %d, n_neighbors = %drV   rn   )r3   r1   rB   formatr   hessianr   z^for method='hessian', n_neighbors must be greater than [n_components * (n_components + 3) / 2]Fr3   rC   r   )full_matricesmodifiedz1modified LLE requires n_neighbors >= n_componentsTr   ltsag      ?)re   rf   rX   rg   rh   ))r   rE   rF   r$   r_   rN   r
   ru   r*   tocsrr[   r,   rH   r%   r&   float64zerosrangemeanr   r)   r   r   r-   whererb   meshgridr	   min	transposer'   medianr#   r   searchsortedlinalgnormsqrtfullouterrm   );r.   r3   n_componentsr1   rf   rX   rg   rq   rr   rs   rh   rB   nbrsNd_inM_sparseWrc   dp	neighborsYiuse_svdr6   GiUCijrd   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Xir5   GiGiTs;                                                              r=   _locally_linear_embeddingr      s    aGGGDHHQKKKAgGAtdL
 
 	
 aV+
 
 	

 w&H'ks6
 
 
  	+QW.QX..2Aq!!AAq13"++--AF$$agaj1n$%%%*%%%%	9		\A-.!3,+++:   OO;?E $ 
 
	 aaae$	X{A$4r$9:"*MMM111a4HaV2:...$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/ 	1A	:		%%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;$$ HaV2:...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lAo')adGGGsNGGGG 	1A	6		OO;?E $ 
 
	 aaae$	HaV$q 	/ 	/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()))Q.))))	!!   r?   z
array-likeleftclosed>   rS   rV   rO   >   r{   rv   rz   rn   rh   r.   r3   r   r1   rf   rX   rg   rq   rr   rs   rh   rB   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 %
!!!!   r?   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   >   rS   rV   rO   >   r{   rv   rz   rn   >   rS   brutekd_tree	ball_treerh   )r3   r   r1   rf   rX   rg   rq   rr   rs   neighbors_algorithmrh   rB   _parameter_constraints   r   r   rS   rP   rQ   rn   ro   rp   c                    || _         || _        || _        || _        || _        || _        || _        || _        |	| _        || _	        |
| _
        || _        d S N)r3   r   r1   rf   rX   rg   rq   rr   rs   rh   r   rB   )selfr3   r   r1   rf   rX   rg   rq   rr   rs   r   rh   rB   s                r=   __init__zLocallyLinearEmbedding.__init__  sc      '(( &((#6 r?   c                    t          | j        | j        | j                  | _        t          | j                  }|                     |t                    }| j        	                    |           t          | j        | j        | j        | j        | j        | j        | j        | j        | j        || j        | j                  \  | _        | _        | j        j        d         | _        d S )N)r3   	algorithmrB   r   )r.   r3   r   rf   rX   rg   rq   rr   rs   rh   r1   rB   r    )r   r3   r   rB   nbrs_r   rh   _validate_datafloatrE   r   r   rf   rX   rg   rq   rr   rs   r1   
embedding_reconstruction_error_r$   _n_features_out)r   r.   rh   s      r=   _fit_transformz%LocallyLinearEmbedding._fit_transform  s    %(.;
 
 

 *$*;<<//
q6Oj(**];(*%;7
 7
 7
33  $4Q7r?   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   r.   ys      r=   rE   zLocallyLinearEmbedding.fit+  s    " 	Ar?   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r?   c                    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)resetrw   rD   r   )r   r   r   rH   r3   r>   rF   r1   r%   r&   r$   r   r   r)   r   r*   )r   r.   r7   weightsX_newr6   s         r=   	transformz LocallyLinearEmbedding.transformS  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r?   r   )__name__
__module____qualname____doc__r   r   r   r   r   dict__annotations__r   r   r   rE   r   r    r?   r=   r   r   [  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&    r?   r   )r   )r   N)r    rO   rP   rQ   N),r   numbersr   r   numpyr%   scipy.linalgr   r   r   r   scipy.sparser	   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>   rN   rm   r   r   r   r   r?   r=   <module>r      s     # " " " " " " "     - - - - - - - - - - - - ( ( ( ( ( ( ( ( % % % % % %              ) ( ( ( ( ( 3 3 3 3 3 3 3 3 + + + + + + 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r?   