neulab/docprompting-conala huggingface dataset:
sklearn.cluster.cluster_optics_xi(*, reachability, predecessor, ordering, min_samples, min_cluster_size=None, xi=0.05, predecessor_correction=True) [source]
 
Automatically extract clusters according to the Xi-steep method.  Parameters 
 
reachabilityndarray of shape (n_samples,) 

Reachability distances calculated by OPTICS (reachability_)  
predecessorndarray of shape (n_samples,) 

Predecessors calculated by OPTICS.  
orderingndarray of shape (n_samples,) 

OPTICS ordered point indices (ordering_)  
min_samplesint > 1 or float between 0 and 1 

The same as the min_samples given to OPTICS. Up and down steep regions can’t have more then min_samples consecutive non-steep points. Expressed as an absolute number or a fraction of the number of samples (rounded to be at least 2).  
min_cluster_sizeint > 1 or float between 0 and 1, default=None 

Minimum number of samples in an OPTICS cluster, expressed as an absolute number or a fraction of the number of samples (rounded to be at least 2). If None, the value of min_samples is used instead.  
xifloat between 0 and 1, default=0.05 

Determines the minimum steepness on the reachability plot that constitutes a cluster boundary. For example, an upwards point in the reachability plot is defined by the ratio from one point to its successor being at most 1-xi.  
predecessor_correctionbool, default=True 

Correct clusters based on the calculated predecessors.    Returns 
 
labelsndarray of shape (n_samples,) 

The labels assigned to samples. Points which are not included in any cluster are labeled as -1.  
clustersndarray of shape (n_clusters, 2) 

The list of clusters in the form of [start, end] in each row, with all indices inclusive. The clusters are ordered according to (end,
-start) (ascending) so that larger clusters encompassing smaller clusters come after such nested smaller clusters. Since labels does not reflect the hierarchy, usually len(clusters) >
np.unique(labels).
fit(X, y=None, sample_weight=None) [source]
 
Perform DBSCAN clustering from features, or distance matrix.  Parameters 
 
X{array-like, sparse matrix} of shape (n_samples, n_features), or (n_samples, n_samples) 

Training instances to cluster, or distances between instances if metric='precomputed'. If a sparse matrix is provided, it will be converted into a sparse csr_matrix.  
sample_weightarray-like of shape (n_samples,), default=None 

Weight of each sample, such that a sample with a weight of at least min_samples is by itself a core sample; a sample with a negative weight may inhibit its eps-neighbor from being core. Note that weights are absolute, and default to 1.  
yIgnored 

Not used, present here for API consistency by convention.    Returns 
 self
fit_predict(X, y=None, sample_weight=None) [source]
 
Perform DBSCAN clustering from features or distance matrix, and return cluster labels.  Parameters 
 
X{array-like, sparse matrix} of shape (n_samples, n_features), or (n_samples, n_samples) 

Training instances to cluster, or distances between instances if metric='precomputed'. If a sparse matrix is provided, it will be converted into a sparse csr_matrix.  
sample_weightarray-like of shape (n_samples,), default=None 

Weight of each sample, such that a sample with a weight of at least min_samples is by itself a core sample; a sample with a negative weight may inhibit its eps-neighbor from being core. Note that weights are absolute, and default to 1.  
yIgnored 

Not used, present here for API consistency by convention.    Returns 
 
labelsndarray of shape (n_samples,) 

Cluster labels. Noisy samples are given the label -1.
sklearn.cluster.estimate_bandwidth(X, *, quantile=0.3, n_samples=None, random_state=0, n_jobs=None) [source]
 
Estimate the bandwidth to use with the mean-shift algorithm. That this function takes time at least quadratic in n_samples. For large datasets, it’s wise to set that parameter to a small value.  Parameters 
 
Xarray-like of shape (n_samples, n_features) 

Input points.  
quantilefloat, default=0.3 

should be between [0, 1] 0.5 means that the median of all pairwise distances is used.  
n_samplesint, default=None 

The number of samples to use. If not given, all samples are used.  
random_stateint, RandomState instance, default=None 

The generator used to randomly select the samples from input points for bandwidth estimation. Use an int to make the randomness deterministic. See Glossary.  
n_jobsint, default=None 

The number of parallel jobs to run for neighbors search. None means 1 unless in a joblib.parallel_backend context. -1 means using all processors. See Glossary for more details.    Returns 
 
bandwidthfloat 

The bandwidth parameter.
fit(X, y=None, **params) [source]
 
Fit the hierarchical clustering on the data  Parameters 
 
Xarray-like of shape (n_samples, n_features) 

The data  
yIgnored 
  Returns 
 self
property fit_predict  
Fit the hierarchical clustering from features or distance matrix, and return cluster labels.  Parameters 
 
Xarray-like of shape (n_samples, n_features) or (n_samples, n_samples) 

Training instances to cluster, or distances between instances if affinity='precomputed'.  
yIgnored 

Not used, present here for API consistency by convention.    Returns 
 
labelsndarray of shape (n_samples,) 

Cluster labels.
inverse_transform(Xred) [source]
 
Inverse the transformation. Return a vector of size nb_features with the values of Xred assigned to each group of features  Parameters 
 
Xredarray-like of shape (n_samples, n_clusters) or (n_clusters,) 

The values to be assigned to each cluster of samples    Returns 
 
Xndarray of shape (n_samples, n_features) or (n_features,) 

A vector of size n_samples with the values of Xred assigned to each of the cluster of samples.
transform(X) [source]
 
Transform a new matrix using the built clustering  Parameters 
 
Xarray-like of shape (n_samples, n_features) or (n_samples,) 

A M by N array of M observations in N dimensions or a length M array of M one-dimensional observations.    Returns 
 
Yndarray of shape (n_samples, n_clusters) or (n_clusters,) 

The pooled values for each feature cluster.
fit(X, y=None, sample_weight=None) [source]
 
Compute k-means clustering.  Parameters 
 
X{array-like, sparse matrix} of shape (n_samples, n_features) 

Training instances to cluster. It must be noted that the data will be converted to C ordering, which will cause a memory copy if the given data is not C-contiguous. If a sparse matrix is passed, a copy will be made if it’s not in CSR format.  
yIgnored 

Not used, present here for API consistency by convention.  
sample_weightarray-like of shape (n_samples,), default=None 

The weights for each observation in X. If None, all observations are assigned equal weight.  New in version 0.20.     Returns 
 self

Fitted estimator.
fit_predict(X, y=None, sample_weight=None) [source]
 
Compute cluster centers and predict cluster index for each sample. Convenience method; equivalent to calling fit(X) followed by predict(X).  Parameters 
 
X{array-like, sparse matrix} of shape (n_samples, n_features) 

New data to transform.  
yIgnored 

Not used, present here for API consistency by convention.  
sample_weightarray-like of shape (n_samples,), default=None 

The weights for each observation in X. If None, all observations are assigned equal weight.    Returns 
 
labelsndarray of shape (n_samples,) 

Index of the cluster each sample belongs to.
fit_transform(X, y=None, sample_weight=None) [source]
 
Compute clustering and transform X to cluster-distance space. Equivalent to fit(X).transform(X), but more efficiently implemented.  Parameters 
 
X{array-like, sparse matrix} of shape (n_samples, n_features) 

New data to transform.  
yIgnored 

Not used, present here for API consistency by convention.  
sample_weightarray-like of shape (n_samples,), default=None 

The weights for each observation in X. If None, all observations are assigned equal weight.    Returns 
 
X_newndarray of shape (n_samples, n_clusters) 

X transformed in the new space.
predict(X, sample_weight=None) [source]
 
Predict the closest cluster each sample in X belongs to. In the vector quantization literature, cluster_centers_ is called the code book and each value returned by predict is the index of the closest code in the code book.  Parameters 
 
X{array-like, sparse matrix} of shape (n_samples, n_features) 

New data to predict.  
sample_weightarray-like of shape (n_samples,), default=None 

The weights for each observation in X. If None, all observations are assigned equal weight.    Returns 
 
labelsndarray of shape (n_samples,) 

Index of the cluster each sample belongs to.
score(X, y=None, sample_weight=None) [source]
 
Opposite of the value of X on the K-means objective.  Parameters 
 
X{array-like, sparse matrix} of shape (n_samples, n_features) 

New data.  
yIgnored 

Not used, present here for API consistency by convention.  
sample_weightarray-like of shape (n_samples,), default=None 

The weights for each observation in X. If None, all observations are assigned equal weight.    Returns 
 
scorefloat 

Opposite of the value of X on the K-means objective.
transform(X) [source]
 
Transform X to a cluster-distance space. In the new space, each dimension is the distance to the cluster centers. Note that even if X is sparse, the array returned by transform will typically be dense.  Parameters 
 
X{array-like, sparse matrix} of shape (n_samples, n_features) 

New data to transform.    Returns 
 
X_newndarray of shape (n_samples, n_clusters) 

X transformed in the new space.
sklearn.cluster.kmeans_plusplus(X, n_clusters, *, x_squared_norms=None, random_state=None, n_local_trials=None) [source]
 
Init n_clusters seeds according to k-means++  New in version 0.24.   Parameters 
 
X{array-like, sparse matrix} of shape (n_samples, n_features) 

The data to pick seeds from.  
n_clustersint 

The number of centroids to initialize  
x_squared_normsarray-like of shape (n_samples,), default=None 

Squared Euclidean norm of each data point.  
random_stateint or RandomState instance, default=None 

Determines random number generation for centroid initialization. Pass an int for reproducible output across multiple function calls. See Glossary.  
n_local_trialsint, default=None 

The number of seeding trials for each center (except the first), of which the one reducing inertia the most is greedily chosen. Set to None to make the number of trials depend logarithmically on the number of seeds (2+log(k)).    Returns 
 
centersndarray of shape (n_clusters, n_features) 

The inital centers for k-means.  
indicesndarray of shape (n_clusters,) 

The index location of the chosen centers in the data array X. For a given index and center, X[index] = center.     Notes Selects initial cluster centers for k-mean clustering in a smart way to speed up convergence. see: Arthur, D. and Vassilvitskii, S. “k-means++: the advantages of careful seeding”. ACM-SIAM symposium on Discrete algorithms. 2007 Examples >>> from sklearn.cluster import kmeans_plusplus
>>> import numpy as np
>>> X = np.array([[1, 2], [1, 4], [1, 0],
...               [10, 2], [10, 4], [10, 0]])
>>> centers, indices = kmeans_plusplus(X, n_clusters=2, random_state=0)
>>> centers
array([[10,  4],
       [ 1,  0]])
>>> indices
array([4, 2])
fit(X, y=None) [source]
 
Perform clustering.  Parameters 
 
Xarray-like of shape (n_samples, n_features) 

Samples to cluster.  
yIgnored
predict(X) [source]
 
Predict the closest cluster each sample in X belongs to.  Parameters 
 
X{array-like, sparse matrix} of shape (n_samples, n_features) 

New data to predict.    Returns 
 
labelsndarray of shape (n_samples,) 

Index of the cluster each sample belongs to.
sklearn.cluster.mean_shift(X, *, bandwidth=None, seeds=None, bin_seeding=False, min_bin_freq=1, cluster_all=True, max_iter=300, n_jobs=None) [source]
 
Perform mean shift clustering of data using a flat kernel. Read more in the User Guide.  Parameters 
 
Xarray-like of shape (n_samples, n_features) 

Input data.  
bandwidthfloat, default=None 

Kernel bandwidth. If bandwidth is not given, it is determined using a heuristic based on the median of all pairwise distances. This will take quadratic time in the number of samples. The sklearn.cluster.estimate_bandwidth function can be used to do this more efficiently.  
seedsarray-like of shape (n_seeds, n_features) or None 

Point used as initial kernel locations. If None and bin_seeding=False, each data point is used as a seed. If None and bin_seeding=True, see bin_seeding.  
bin_seedingbool, default=False 

If true, initial kernel locations are not locations of all points, but rather the location of the discretized version of points, where points are binned onto a grid whose coarseness corresponds to the bandwidth. Setting this option to True will speed up the algorithm because fewer seeds will be initialized. Ignored if seeds argument is not None.  
min_bin_freqint, default=1 

To speed up the algorithm, accept only those bins with at least min_bin_freq points as seeds.  
cluster_allbool, default=True 

If true, then all points are clustered, even those orphans that are not within any kernel. Orphans are assigned to the nearest kernel. If false, then orphans are given cluster label -1.  
max_iterint, default=300 

Maximum number of iterations, per seed point before the clustering operation terminates (for that seed point), if has not converged yet.  
n_jobsint, default=None 

The number of jobs to use for the computation. This works by computing each of the n_init runs in parallel. None means 1 unless in a joblib.parallel_backend context. -1 means using all processors. See Glossary for more details.  New in version 0.17: Parallel Execution using n_jobs.     Returns 
 
cluster_centersndarray of shape (n_clusters, n_features) 

Coordinates of cluster centers.  
labelsndarray of shape (n_samples,) 

Cluster labels for each point.     Notes For an example, see examples/cluster/plot_mean_shift.py.
fit(X, y=None, sample_weight=None) [source]
 
Compute the centroids on X by chunking it into mini-batches.  Parameters 
 
X{array-like, sparse matrix} of shape (n_samples, n_features) 

Training instances to cluster. It must be noted that the data will be converted to C ordering, which will cause a memory copy if the given data is not C-contiguous.  
yIgnored 

Not used, present here for API consistency by convention.  
sample_weightarray-like of shape (n_samples,), default=None 

The weights for each observation in X. If None, all observations are assigned equal weight (default: None).  New in version 0.20.     Returns 
 self
partial_fit(X, y=None, sample_weight=None) [source]
 
Update k means estimate on a single mini-batch X.  Parameters 
 
Xarray-like of shape (n_samples, n_features) 

Coordinates of the data points to cluster. It must be noted that X will be copied if it is not C-contiguous.  
yIgnored 

Not used, present here for API consistency by convention.  
sample_weightarray-like of shape (n_samples,), default=None 

The weights for each observation in X. If None, all observations are assigned equal weight (default: None).    Returns 
 self
predict(X, sample_weight=None) [source]
 
Predict the closest cluster each sample in X belongs to. In the vector quantization literature, cluster_centers_ is called the code book and each value returned by predict is the index of the closest code in the code book.  Parameters 
 
X{array-like, sparse matrix} of shape (n_samples, n_features) 

New data to predict.  
sample_weightarray-like of shape (n_samples,), default=None 

The weights for each observation in X. If None, all observations are assigned equal weight (default: None).    Returns 
 
labelsndarray of shape (n_samples,) 

Index of the cluster each sample belongs to.
fit(X, y=None) [source]
 
Perform OPTICS clustering. Extracts an ordered list of points and reachability distances, and performs initial clustering using max_eps distance specified at OPTICS object instantiation.  Parameters 
 
Xndarray of shape (n_samples, n_features), or (n_samples, n_samples) if metric=’precomputed’ 

A feature array, or array of distances between samples if metric=’precomputed’.  
yignored 

Ignored.    Returns 
 
selfinstance of OPTICS 

The instance.
fit(X, y=None) [source]
 
Creates a biclustering for X.  Parameters 
 
Xarray-like of shape (n_samples, n_features) 

yIgnored
fit(X, y=None) [source]
 
Perform spectral clustering from features, or affinity matrix.  Parameters 
 
X{array-like, sparse matrix} of shape (n_samples, n_features), or array-like of shape (n_samples, n_samples) 

Training instances to cluster, or similarities / affinities between instances if affinity='precomputed'. If a sparse matrix is provided in a format other than csr_matrix, csc_matrix, or coo_matrix, it will be converted into a sparse csr_matrix.  
yIgnored 

Not used, present here for API consistency by convention.    Returns 
 self
fit_predict(X, y=None) [source]
 
Perform spectral clustering from features, or affinity matrix, and return cluster labels.  Parameters 
 
X{array-like, sparse matrix} of shape (n_samples, n_features), or array-like of shape (n_samples, n_samples) 

Training instances to cluster, or similarities / affinities between instances if affinity='precomputed'. If a sparse matrix is provided in a format other than csr_matrix, csc_matrix, or coo_matrix, it will be converted into a sparse csr_matrix.  
yIgnored 

Not used, present here for API consistency by convention.    Returns 
 
labelsndarray of shape (n_samples,) 

Cluster labels.
sklearn.cluster.ward_tree(X, *, connectivity=None, n_clusters=None, return_distance=False) [source]
 
Ward clustering based on a Feature matrix. Recursively merges the pair of clusters that minimally increases within-cluster variance. The inertia matrix uses a Heapq-based representation. This is the structured version, that takes into account some topological structure between samples. Read more in the User Guide.  Parameters 
 
Xarray-like of shape (n_samples, n_features) 

feature matrix representing n_samples samples to be clustered  
connectivitysparse matrix, default=None 

connectivity matrix. Defines for each sample the neighboring samples following a given structure of the data. The matrix is assumed to be symmetric and only the upper triangular half is used. Default is None, i.e, the Ward algorithm is unstructured.  
n_clustersint, default=None 

Stop early the construction of the tree at n_clusters. This is useful to decrease computation time if the number of clusters is not small compared to the number of samples. In this case, the complete tree is not computed, thus the ‘children’ output is of limited use, and the ‘parents’ output should rather be used. This option is valid only when specifying a connectivity matrix.  
return_distancebool, default=None 

If True, return the distance between the clusters.    Returns 
 
childrenndarray of shape (n_nodes-1, 2) 

The children of each non-leaf node. Values less than n_samples correspond to leaves of the tree which are the original samples. A node i greater than or equal to n_samples is a non-leaf node and has children children_[i - n_samples]. Alternatively at the i-th iteration, children[i][0] and children[i][1] are merged to form node n_samples + i  
n_connected_componentsint 

The number of connected components in the graph.  
n_leavesint 

The number of leaves in the tree  
parentsndarray of shape (n_nodes,) or None 

The parent of each node. Only returned when a connectivity matrix is specified, elsewhere ‘None’ is returned.  
distancesndarray of shape (n_nodes-1,) 

Only returned if return_distance is set to True (for compatibility). The distances between the centers of the nodes. distances[i] corresponds to a weighted euclidean distance between the nodes children[i, 1] and children[i, 2]. If the nodes refer to leaves of the tree, then distances[i] is their unweighted euclidean distance. Distances are updated in the following way (from scipy.hierarchy.linkage): The new entry \(d(u,v)\) is computed as follows,  \[d(u,v) = \sqrt{\frac{|v|+|s|} {T}d(v,s)^2 + \frac{|v|+|t|} {T}d(v,t)^2 - \frac{|v|} {T}d(s,t)^2}\] where \(u\) is the newly joined cluster consisting of clusters \(s\) and \(t\), \(v\) is an unused cluster in the forest, \(T=|v|+|s|+|t|\), and \(|*|\) is the cardinality of its argument. This is also known as the incremental algorithm.
fit(X, y=None) [source]
 
Fit all transformers using X.  Parameters 
 
X{array-like, dataframe} of shape (n_samples, n_features) 

Input data, of which specified subsets are used to fit the transformers.  
yarray-like of shape (n_samples,…), default=None 

Targets for supervised learning.    Returns 
 
selfColumnTransformer 

This estimator
fit_transform(X, y=None) [source]
 
Fit all transformers, transform the data and concatenate results.  Parameters 
 
X{array-like, dataframe} of shape (n_samples, n_features) 

Input data, of which specified subsets are used to fit the transformers.  
yarray-like of shape (n_samples,), default=None 

Targets for supervised learning.    Returns 
 
X_t{array-like, sparse matrix} of shape (n_samples, sum_n_components) 

hstack of results of transformers. sum_n_components is the sum of n_components (output dimension) over transformers. If any result is a sparse matrix, everything will be converted to sparse matrices.
get_feature_names() [source]
 
Get feature names from all transformers.  Returns 
 
feature_nameslist of strings 

Names of the features produced by transform.
get_params(deep=True) [source]
 
Get parameters for this estimator. Returns the parameters given in the constructor as well as the estimators contained within the transformers of the ColumnTransformer.  Parameters 
 
deepbool, default=True 

If True, will return the parameters for this estimator and contained subobjects that are estimators.    Returns 
 
paramsdict 

Parameter names mapped to their values.
property named_transformers_  
Access the fitted transformer by name. Read-only attribute to access any transformer by given name. Keys are transformer names and values are the fitted transformer objects.
set_params(**kwargs) [source]
 
Set the parameters of this estimator. Valid parameter keys can be listed with get_params(). Note that you can directly set the parameters of the estimators contained in transformers of ColumnTransformer.  Returns 
 self
transform(X) [source]
 
Transform X separately by each transformer, concatenate results.  Parameters 
 
X{array-like, dataframe} of shape (n_samples, n_features) 

The data to be transformed by subset.    Returns 
 
X_t{array-like, sparse matrix} of shape (n_samples, sum_n_components) 

hstack of results of transformers. sum_n_components is the sum of n_components (output dimension) over transformers. If any result is a sparse matrix, everything will be converted to sparse matrices.