# scipy 1.18.1 (BSD-3-Clause), harvested by tools/harvest_corpus.py
=== input

    Cluster observation data using a given metric.

    Clusters the original observations in the n-by-m data
    matrix X (n observations in m dimensions), using the euclidean
    distance metric to calculate distances between original observations,
    performs hierarchical clustering using the single linkage algorithm,
    and forms flat clusters using the inconsistency method with `t` as the
    cut-off threshold.

    A 1-D array ``T`` of length ``n`` is returned. ``T[i]`` is
    the index of the flat cluster to which the original observation ``i``
    belongs.

    Parameters
    ----------
    X : (N, M) ndarray
        N by M data matrix with N observations in M dimensions.
    t : scalar
        For criteria 'inconsistent', 'distance' or 'monocrit',
         this is the threshold to apply when forming flat clusters.
        For 'maxclust' or 'maxclust_monocrit' criteria,
         this would be max number of clusters requested.
    criterion : str, optional
        Specifies the criterion for forming flat clusters. Valid
        values are 'inconsistent' (default), 'distance', or 'maxclust'
        cluster formation algorithms. See `fcluster` for descriptions.
    metric : str or function, optional
        The distance metric for calculating pairwise distances. See
        ``distance.pdist`` for descriptions and linkage to verify
        compatibility with the linkage method.
    depth : int, optional
        The maximum depth for the inconsistency calculation. See
        `inconsistent` for more information.
    method : str, optional
        The linkage method to use (single, complete, average,
        weighted, median centroid, ward). See `linkage` for more
        information. Default is "single".
    R : ndarray, optional
        The inconsistency matrix. It will be computed if necessary
        if it is not passed.

    Returns
    -------
    fclusterdata : ndarray
        A vector of length n. T[i] is the flat cluster number to
        which original observation i belongs.

    See Also
    --------
    scipy.spatial.distance.pdist : pairwise distance metrics

    Notes
    -----
    This function is similar to the MATLAB function ``clusterdata``.

    Examples
    --------
    >>> from scipy.cluster.hierarchy import fclusterdata

    This is a convenience method that abstracts all the steps to perform in a
    typical SciPy's hierarchical clustering workflow.

    * Transform the input data into a condensed matrix with
      `scipy.spatial.distance.pdist`.

    * Apply a clustering method.

    * Obtain flat clusters at a user defined distance threshold ``t`` using
      `scipy.cluster.hierarchy.fcluster`.

    >>> X = [[0, 0], [0, 1], [1, 0],
    ...      [0, 4], [0, 3], [1, 4],
    ...      [4, 0], [3, 0], [4, 1],
    ...      [4, 4], [3, 4], [4, 3]]

    >>> fclusterdata(X, t=1)
    array([3, 3, 3, 4, 4, 4, 2, 2, 2, 1, 1, 1], dtype=int32)

    The output here (for the dataset ``X``, distance threshold ``t``, and the
    default settings) is four clusters with three data points each.

    
=== parse numpydoc
short_description: 'Cluster observation data using a given metric.'
long_description: |
  Clusters the original observations in the n-by-m data
  matrix X (n observations in m dimensions), using the euclidean
  distance metric to calculate distances between original observations,
  performs hierarchical clustering using the single linkage algorithm,
  and forms flat clusters using the inconsistency method with `t` as the
  cut-off threshold.
  
  A 1-D array ``T`` of length ``n`` is returned. ``T[i]`` is
  the index of the flat cluster to which the original observation ``i``
  belongs.
blank_after_short_description: True
blank_after_long_description: True
style: numpydoc
- DocstringParam
  description: 'N by M data matrix with N observations in M dimensions.'
  kind: param
  key: 'param'
  arg_name: 'X'
  type_name: '(N, M) ndarray'
  is_optional: False
- DocstringParam
  description: |
    For criteria 'inconsistent', 'distance' or 'monocrit',
     this is the threshold to apply when forming flat clusters.
    For 'maxclust' or 'maxclust_monocrit' criteria,
     this would be max number of clusters requested.
  kind: param
  key: 'param'
  arg_name: 't'
  type_name: 'scalar'
  is_optional: False
- DocstringParam
  description: |
    Specifies the criterion for forming flat clusters. Valid
    values are 'inconsistent' (default), 'distance', or 'maxclust'
    cluster formation algorithms. See `fcluster` for descriptions.
  kind: param
  key: 'param'
  arg_name: 'criterion'
  type_name: 'str'
  is_optional: True
  raw_type_name: 'str, optional'
- DocstringParam
  description: |
    The distance metric for calculating pairwise distances. See
    ``distance.pdist`` for descriptions and linkage to verify
    compatibility with the linkage method.
  kind: param
  key: 'param'
  arg_name: 'metric'
  type_name: 'str or function'
  is_optional: True
  raw_type_name: 'str or function, optional'
- DocstringParam
  description: |
    The maximum depth for the inconsistency calculation. See
    `inconsistent` for more information.
  kind: param
  key: 'param'
  arg_name: 'depth'
  type_name: 'int'
  is_optional: True
  raw_type_name: 'int, optional'
- DocstringParam
  description: |
    The linkage method to use (single, complete, average,
    weighted, median centroid, ward). See `linkage` for more
    information. Default is "single".
  kind: param
  key: 'param'
  arg_name: 'method'
  type_name: 'str'
  is_optional: True
  default: '"single"'
  raw_type_name: 'str, optional'
- DocstringParam
  description: |
    The inconsistency matrix. It will be computed if necessary
    if it is not passed.
  kind: param
  key: 'param'
  arg_name: 'R'
  type_name: 'ndarray'
  is_optional: True
  raw_type_name: 'ndarray, optional'
- DocstringReturns
  description: |
    A vector of length n. T[i] is the flat cluster number to
    which original observation i belongs.
  kind: returns
  key: 'returns'
  type_name: 'ndarray'
  is_generator: False
  return_name: 'fclusterdata'
- DocstringMeta
  description: 'scipy.spatial.distance.pdist : pairwise distance metrics'
  kind: text
  key: 'see_also'
  title: 'See Also'
- DocstringMeta
  description: 'This function is similar to the MATLAB function ``clusterdata``.'
  kind: text
  key: 'notes'
  title: 'Notes'
- DocstringExample
  kind: examples
  key: 'examples'
  snippet: '>>> from scipy.cluster.hierarchy import fclusterdata'
- DocstringExample
  description: |
    This is a convenience method that abstracts all the steps to perform in a
    typical SciPy's hierarchical clustering workflow.
    
    * Transform the input data into a condensed matrix with
      `scipy.spatial.distance.pdist`.
    
    * Apply a clustering method.
    
    * Obtain flat clusters at a user defined distance threshold ``t`` using
      `scipy.cluster.hierarchy.fcluster`.
  kind: examples
  key: 'examples'
  snippet: |
    >>> X = [[0, 0], [0, 1], [1, 0],
    ...      [0, 4], [0, 3], [1, 4],
    ...      [4, 0], [3, 0], [4, 1],
    ...      [4, 4], [3, 4], [4, 3]]
- DocstringExample
  kind: examples
  key: 'examples'
  snippet: |
    >>> fclusterdata(X, t=1)
    array([3, 3, 3, 4, 4, 4, 2, 2, 2, 1, 1, 1], dtype=int32)
- DocstringExample
  description: |
    The output here (for the dataset ``X``, distance threshold ``t``, and the
    default settings) is four clusters with three data points each.
  kind: examples
  key: 'examples'
=== detect
numpydoc
=== compose numpydoc
Cluster observation data using a given metric.

Clusters the original observations in the n-by-m data
matrix X (n observations in m dimensions), using the euclidean
distance metric to calculate distances between original observations,
performs hierarchical clustering using the single linkage algorithm,
and forms flat clusters using the inconsistency method with `t` as the
cut-off threshold.

A 1-D array ``T`` of length ``n`` is returned. ``T[i]`` is
the index of the flat cluster to which the original observation ``i``
belongs.

Parameters
----------
X : (N, M) ndarray
    N by M data matrix with N observations in M dimensions.
t : scalar
    For criteria 'inconsistent', 'distance' or 'monocrit',
     this is the threshold to apply when forming flat clusters.
    For 'maxclust' or 'maxclust_monocrit' criteria,
     this would be max number of clusters requested.
criterion : str, optional
    Specifies the criterion for forming flat clusters. Valid
    values are 'inconsistent' (default), 'distance', or 'maxclust'
    cluster formation algorithms. See `fcluster` for descriptions.
metric : str or function, optional
    The distance metric for calculating pairwise distances. See
    ``distance.pdist`` for descriptions and linkage to verify
    compatibility with the linkage method.
depth : int, optional
    The maximum depth for the inconsistency calculation. See
    `inconsistent` for more information.
method : str, optional
    The linkage method to use (single, complete, average,
    weighted, median centroid, ward). See `linkage` for more
    information. Default is "single".
R : ndarray, optional
    The inconsistency matrix. It will be computed if necessary
    if it is not passed.

Returns
-------
fclusterdata : ndarray
    A vector of length n. T[i] is the flat cluster number to
    which original observation i belongs.

See Also
--------
scipy.spatial.distance.pdist : pairwise distance metrics

Notes
-----
This function is similar to the MATLAB function ``clusterdata``.

Examples
--------
>>> from scipy.cluster.hierarchy import fclusterdata

This is a convenience method that abstracts all the steps to perform in a
typical SciPy's hierarchical clustering workflow.

* Transform the input data into a condensed matrix with
  `scipy.spatial.distance.pdist`.

* Apply a clustering method.

* Obtain flat clusters at a user defined distance threshold ``t`` using
  `scipy.cluster.hierarchy.fcluster`.

>>> X = [[0, 0], [0, 1], [1, 0],
...      [0, 4], [0, 3], [1, 4],
...      [4, 0], [3, 0], [4, 1],
...      [4, 4], [3, 4], [4, 3]]
>>> fclusterdata(X, t=1)
array([3, 3, 3, 4, 4, 4, 2, 2, 2, 1, 1, 1], dtype=int32)

The output here (for the dataset ``X``, distance threshold ``t``, and the
default settings) is four clusters with three data points each.
