neulab/docprompting-conala huggingface dataset:
sklearn.metrics.pairwise.manhattan_distances(X, Y=None, *, sum_over_features=True) [source]
 
Compute the L1 distances between the vectors in X and Y. With sum_over_features equal to False it returns the componentwise distances. Read more in the User Guide.  Parameters 
 
Xarray-like of shape (n_samples_X, n_features) 

Yarray-like of shape (n_samples_Y, n_features), default=None 

sum_over_featuresbool, default=True 

If True the function returns the pairwise distance matrix else it returns the componentwise L1 pairwise-distances. Not supported for sparse matrix inputs.    Returns 
 
Dndarray of shape (n_samples_X * n_samples_Y, n_features) or (n_samples_X, n_samples_Y) 

If sum_over_features is False shape is (n_samples_X * n_samples_Y, n_features) and D contains the componentwise L1 pairwise-distances (ie. absolute difference), else shape is (n_samples_X, n_samples_Y) and D contains the pairwise L1 distances.     Notes When X and/or Y are CSR sparse matrices and they are not already in canonical format, this function modifies them in-place to make them canonical. Examples >>> from sklearn.metrics.pairwise import manhattan_distances
>>> manhattan_distances([[3]], [[3]])
array([[0.]])
>>> manhattan_distances([[3]], [[2]])
array([[1.]])
>>> manhattan_distances([[2]], [[3]])
array([[1.]])
>>> manhattan_distances([[1, 2], [3, 4]],         [[1, 2], [0, 3]])
array([[0., 2.],
       [4., 4.]])
>>> import numpy as np
>>> X = np.ones((1, 2))
>>> y = np.full((2, 2), 2.)
>>> manhattan_distances(X, y, sum_over_features=False)
array([[1., 1.],
       [1., 1.]])
sklearn.metrics.pairwise.nan_euclidean_distances(X, Y=None, *, squared=False, missing_values=nan, copy=True) [source]
 
Calculate the euclidean distances in the presence of missing values. Compute the euclidean distance between each pair of samples in X and Y, where Y=X is assumed if Y=None. When calculating the distance between a pair of samples, this formulation ignores feature coordinates with a missing value in either sample and scales up the weight of the remaining coordinates: dist(x,y) = sqrt(weight * sq. distance from present coordinates) where, weight = Total # of coordinates / # of present coordinates For example, the distance between [3, na, na, 6] and [1, na, 4, 5] is:  \[\sqrt{\frac{4}{2}((3-1)^2 + (6-5)^2)}\] If all the coordinates are missing or if there are no common present coordinates then NaN is returned for that pair. Read more in the User Guide.  New in version 0.22.   Parameters 
 
Xarray-like of shape=(n_samples_X, n_features) 

Yarray-like of shape=(n_samples_Y, n_features), default=None 

squaredbool, default=False 

Return squared Euclidean distances.  
missing_valuesnp.nan or int, default=np.nan 

Representation of missing value.  
copybool, default=True 

Make and use a deep copy of X and Y (if Y exists).    Returns 
 
distancesndarray of shape (n_samples_X, n_samples_Y) 
    See also  
paired_distances


Distances between pairs of elements of X and Y.    References  John K. Dixon, “Pattern Recognition with Partly Missing Data”, IEEE Transactions on Systems, Man, and Cybernetics, Volume: 9, Issue: 10, pp. 617 - 621, Oct. 1979. http://ieeexplore.ieee.org/abstract/document/4310090/
  Examples >>> from sklearn.metrics.pairwise import nan_euclidean_distances
>>> nan = float("NaN")
>>> X = [[0, 1], [1, nan]]
>>> nan_euclidean_distances(X, X) # distance between rows of X
array([[0.        , 1.41421356],
       [1.41421356, 0.        ]])
 >>> # get distance to origin
>>> nan_euclidean_distances(X, [[0, 0]])
array([[1.        ],
       [1.41421356]])
sklearn.metrics.pairwise.paired_cosine_distances(X, Y) [source]
 
Computes the paired cosine distances between X and Y. Read more in the User Guide.  Parameters 
 
Xarray-like of shape (n_samples, n_features) 

Yarray-like of shape (n_samples, n_features) 
  Returns 
 
distancesndarray of shape (n_samples,) 
   Notes The cosine distance is equivalent to the half the squared euclidean distance if each sample is normalized to unit norm.
sklearn.metrics.pairwise.paired_distances(X, Y, *, metric='euclidean', **kwds) [source]
 
Computes the paired distances between X and Y. Computes the distances between (X[0], Y[0]), (X[1], Y[1]), etc… Read more in the User Guide.  Parameters 
 
Xndarray of shape (n_samples, n_features) 

Array 1 for distance computation.  
Yndarray of shape (n_samples, n_features) 

Array 2 for distance computation.  
metricstr or callable, default=”euclidean” 

The metric to use when calculating distance between instances in a feature array. If metric is a string, it must be one of the options specified in PAIRED_DISTANCES, including “euclidean”, “manhattan”, or “cosine”. Alternatively, if metric is a callable function, it is called on each pair of instances (rows) and the resulting value recorded. The callable should take two arrays from X as input and return a value indicating the distance between them.    Returns 
 
distancesndarray of shape (n_samples,) 
    See also  
pairwise_distances 

Computes the distance between every pair of samples.    Examples >>> from sklearn.metrics.pairwise import paired_distances
>>> X = [[0, 1], [1, 1]]
>>> Y = [[0, 1], [2, 1]]
>>> paired_distances(X, Y)
array([0., 1.])
sklearn.metrics.pairwise.paired_euclidean_distances(X, Y) [source]
 
Computes the paired euclidean distances between X and Y. Read more in the User Guide.  Parameters 
 
Xarray-like of shape (n_samples, n_features) 

Yarray-like of shape (n_samples, n_features) 
  Returns 
 
distancesndarray of shape (n_samples,)
sklearn.metrics.pairwise.paired_manhattan_distances(X, Y) [source]
 
Compute the L1 distances between the vectors in X and Y. Read more in the User Guide.  Parameters 
 
Xarray-like of shape (n_samples, n_features) 

Yarray-like of shape (n_samples, n_features) 
  Returns 
 
distancesndarray of shape (n_samples,)
sklearn.metrics.pairwise.pairwise_kernels(X, Y=None, metric='linear', *, filter_params=False, n_jobs=None, **kwds) [source]
 
Compute the kernel between arrays X and optional array Y. This method takes either a vector array or a kernel matrix, and returns a kernel matrix. If the input is a vector array, the kernels are computed. If the input is a kernel matrix, it is returned instead. This method provides a safe way to take a kernel matrix as input, while preserving compatibility with many other algorithms that take a vector array. If Y is given (default is None), then the returned matrix is the pairwise kernel between the arrays from both X and Y.  Valid values for metric are:

[‘additive_chi2’, ‘chi2’, ‘linear’, ‘poly’, ‘polynomial’, ‘rbf’, ‘laplacian’, ‘sigmoid’, ‘cosine’]   Read more in the User Guide.  Parameters 
 
Xndarray of shape (n_samples_X, n_samples_X) or (n_samples_X, n_features) 

Array of pairwise kernels between samples, or a feature array. The shape of the array should be (n_samples_X, n_samples_X) if metric == “precomputed” and (n_samples_X, n_features) otherwise.  
Yndarray of shape (n_samples_Y, n_features), default=None 

A second feature array only if X has shape (n_samples_X, n_features).  
metricstr or callable, default=”linear” 

The metric to use when calculating kernel between instances in a feature array. If metric is a string, it must be one of the metrics in pairwise.PAIRWISE_KERNEL_FUNCTIONS. If metric is “precomputed”, X is assumed to be a kernel matrix. Alternatively, if metric is a callable function, it is called on each pair of instances (rows) and the resulting value recorded. The callable should take two rows from X as input and return the corresponding kernel value as a single number. This means that callables from sklearn.metrics.pairwise are not allowed, as they operate on matrices, not single samples. Use the string identifying the kernel instead.  
filter_paramsbool, default=False 

Whether to filter invalid parameters or not.  
n_jobsint, default=None 

The number of jobs to use for the computation. This works by breaking down the pairwise matrix into n_jobs even slices and computing them in parallel. None means 1 unless in a joblib.parallel_backend context. -1 means using all processors. See Glossary for more details.  
**kwdsoptional keyword parameters 

Any further parameters are passed directly to the kernel function.    Returns 
 
Kndarray of shape (n_samples_X, n_samples_X) or (n_samples_X, n_samples_Y) 

A kernel matrix K such that K_{i, j} is the kernel between the ith and jth vectors of the given matrix X, if Y is None. If Y is not None, then K_{i, j} is the kernel between the ith array from X and the jth array from Y.     Notes If metric is ‘precomputed’, Y is ignored and X is returned.
sklearn.metrics.pairwise.polynomial_kernel(X, Y=None, degree=3, gamma=None, coef0=1) [source]
 
Compute the polynomial kernel between X and Y: K(X, Y) = (gamma <X, Y> + coef0)^degree
 Read more in the User Guide.  Parameters 
 
Xndarray of shape (n_samples_X, n_features) 

Yndarray of shape (n_samples_Y, n_features), default=None 

degreeint, default=3 

gammafloat, default=None 

If None, defaults to 1.0 / n_features.  
coef0float, default=1 
  Returns 
 
Gram matrixndarray of shape (n_samples_X, n_samples_Y)
sklearn.metrics.pairwise.rbf_kernel(X, Y=None, gamma=None) [source]
 
Compute the rbf (gaussian) kernel between X and Y: K(x, y) = exp(-gamma ||x-y||^2)
 for each pair of rows x in X and y in Y. Read more in the User Guide.  Parameters 
 
Xndarray of shape (n_samples_X, n_features) 

Yndarray of shape (n_samples_Y, n_features), default=None 

gammafloat, default=None 

If None, defaults to 1.0 / n_features.    Returns 
 
kernel_matrixndarray of shape (n_samples_X, n_samples_Y)
sklearn.metrics.pairwise.sigmoid_kernel(X, Y=None, gamma=None, coef0=1) [source]
 
Compute the sigmoid kernel between X and Y: K(X, Y) = tanh(gamma <X, Y> + coef0)
 Read more in the User Guide.  Parameters 
 
Xndarray of shape (n_samples_X, n_features) 

Yndarray of shape (n_samples_Y, n_features), default=None 

gammafloat, default=None 

If None, defaults to 1.0 / n_features.  
coef0float, default=1 
  Returns 
 
Gram matrixndarray of shape (n_samples_X, n_samples_Y)
sklearn.metrics.pairwise_distances_argmin(X, Y, *, axis=1, metric='euclidean', metric_kwargs=None) [source]
 
Compute minimum distances between one point and a set of points. This function computes for each row in X, the index of the row of Y which is closest (according to the specified distance). This is mostly equivalent to calling: pairwise_distances(X, Y=Y, metric=metric).argmin(axis=axis) but uses much less memory, and is faster for large arrays. This function works with dense 2D arrays only.  Parameters 
 
Xarray-like of shape (n_samples_X, n_features) 

Array containing points.  
Yarray-like of shape (n_samples_Y, n_features) 

Arrays containing points.  
axisint, default=1 

Axis along which the argmin and distances are to be computed.  
metricstr or callable, default=”euclidean” 

Metric to use for distance computation. Any metric from scikit-learn or scipy.spatial.distance can be used. If metric is a callable function, it is called on each pair of instances (rows) and the resulting value recorded. The callable should take two arrays as input and return one value indicating the distance between them. This works for Scipy’s metrics, but is less efficient than passing the metric name as a string. Distance matrices are not supported. Valid values for metric are:  from scikit-learn: [‘cityblock’, ‘cosine’, ‘euclidean’, ‘l1’, ‘l2’, ‘manhattan’] from scipy.spatial.distance: [‘braycurtis’, ‘canberra’, ‘chebyshev’, ‘correlation’, ‘dice’, ‘hamming’, ‘jaccard’, ‘kulsinski’, ‘mahalanobis’, ‘minkowski’, ‘rogerstanimoto’, ‘russellrao’, ‘seuclidean’, ‘sokalmichener’, ‘sokalsneath’, ‘sqeuclidean’, ‘yule’]  See the documentation for scipy.spatial.distance for details on these metrics.  
metric_kwargsdict, default=None 

Keyword arguments to pass to specified metric function.    Returns 
 
argminnumpy.ndarray 

Y[argmin[i], :] is the row in Y that is closest to X[i, :].      See also  
sklearn.metrics.pairwise_distances


sklearn.metrics.pairwise_distances_argmin_min
sklearn.metrics.pairwise_distances_argmin_min(X, Y, *, axis=1, metric='euclidean', metric_kwargs=None) [source]
 
Compute minimum distances between one point and a set of points. This function computes for each row in X, the index of the row of Y which is closest (according to the specified distance). The minimal distances are also returned. This is mostly equivalent to calling:  (pairwise_distances(X, Y=Y, metric=metric).argmin(axis=axis),

pairwise_distances(X, Y=Y, metric=metric).min(axis=axis))   but uses much less memory, and is faster for large arrays.  Parameters 
 
X{array-like, sparse matrix} of shape (n_samples_X, n_features) 

Array containing points.  
Y{array-like, sparse matrix} of shape (n_samples_Y, n_features) 

Array containing points.  
axisint, default=1 

Axis along which the argmin and distances are to be computed.  
metricstr or callable, default=’euclidean’ 

Metric to use for distance computation. Any metric from scikit-learn or scipy.spatial.distance can be used. If metric is a callable function, it is called on each pair of instances (rows) and the resulting value recorded. The callable should take two arrays as input and return one value indicating the distance between them. This works for Scipy’s metrics, but is less efficient than passing the metric name as a string. Distance matrices are not supported. Valid values for metric are:  from scikit-learn: [‘cityblock’, ‘cosine’, ‘euclidean’, ‘l1’, ‘l2’, ‘manhattan’] from scipy.spatial.distance: [‘braycurtis’, ‘canberra’, ‘chebyshev’, ‘correlation’, ‘dice’, ‘hamming’, ‘jaccard’, ‘kulsinski’, ‘mahalanobis’, ‘minkowski’, ‘rogerstanimoto’, ‘russellrao’, ‘seuclidean’, ‘sokalmichener’, ‘sokalsneath’, ‘sqeuclidean’, ‘yule’]  See the documentation for scipy.spatial.distance for details on these metrics.  
metric_kwargsdict, default=None 

Keyword arguments to pass to specified metric function.    Returns 
 
argminndarray 

Y[argmin[i], :] is the row in Y that is closest to X[i, :].  
distancesndarray 

distances[i] is the distance between the i-th row in X and the argmin[i]-th row in Y.      See also  
sklearn.metrics.pairwise_distances


sklearn.metrics.pairwise_distances_argmin
sklearn.metrics.plot_confusion_matrix(estimator, X, y_true, *, labels=None, sample_weight=None, normalize=None, display_labels=None, include_values=True, xticks_rotation='horizontal', values_format=None, cmap='viridis', ax=None, colorbar=True) [source]
 
Plot Confusion Matrix. Read more in the User Guide.  Parameters 
 
estimatorestimator instance 

Fitted classifier or a fitted Pipeline in which the last estimator is a classifier.  
X{array-like, sparse matrix} of shape (n_samples, n_features) 

Input values.  
y_truearray-like of shape (n_samples,) 

Target values.  
labelsarray-like of shape (n_classes,), default=None 

List of labels to index the matrix. This may be used to reorder or select a subset of labels. If None is given, those that appear at least once in y_true or y_pred are used in sorted order.  
sample_weightarray-like of shape (n_samples,), default=None 

Sample weights.  
normalize{‘true’, ‘pred’, ‘all’}, default=None 

Normalizes confusion matrix over the true (rows), predicted (columns) conditions or all the population. If None, confusion matrix will not be normalized.  
display_labelsarray-like of shape (n_classes,), default=None 

Target names used for plotting. By default, labels will be used if it is defined, otherwise the unique labels of y_true and y_pred will be used.  
include_valuesbool, default=True 

Includes values in confusion matrix.  
xticks_rotation{‘vertical’, ‘horizontal’} or float, default=’horizontal’ 

Rotation of xtick labels.  
values_formatstr, default=None 

Format specification for values in confusion matrix. If None, the format specification is ‘d’ or ‘.2g’ whichever is shorter.  
cmapstr or matplotlib Colormap, default=’viridis’ 

Colormap recognized by matplotlib.  
axmatplotlib Axes, default=None 

Axes object to plot on. If None, a new figure and axes is created.  
colorbarbool, default=True 

Whether or not to add a colorbar to the plot.  New in version 0.24.     Returns 
 
displayConfusionMatrixDisplay 
    See also  
confusion_matrix


Compute Confusion Matrix to evaluate the accuracy of a classification.  
ConfusionMatrixDisplay


Confusion Matrix visualization.    Examples >>> import matplotlib.pyplot as plt  
>>> from sklearn.datasets import make_classification
>>> from sklearn.metrics import plot_confusion_matrix
>>> from sklearn.model_selection import train_test_split
>>> from sklearn.svm import SVC
>>> X, y = make_classification(random_state=0)
>>> X_train, X_test, y_train, y_test = train_test_split(
...         X, y, random_state=0)
>>> clf = SVC(random_state=0)
>>> clf.fit(X_train, y_train)
SVC(random_state=0)
>>> plot_confusion_matrix(clf, X_test, y_test)  
>>> plt.show()
sklearn.metrics.plot_det_curve(estimator, X, y, *, sample_weight=None, response_method='auto', name=None, ax=None, pos_label=None, **kwargs) [source]
 
Plot detection error tradeoff (DET) curve. Extra keyword arguments will be passed to matplotlib’s plot. Read more in the User Guide.  New in version 0.24.   Parameters 
 
estimatorestimator instance 

Fitted classifier or a fitted Pipeline in which the last estimator is a classifier.  
X{array-like, sparse matrix} of shape (n_samples, n_features) 

Input values.  
yarray-like of shape (n_samples,) 

Target values.  
sample_weightarray-like of shape (n_samples,), default=None 

Sample weights.  
response_method{‘predict_proba’, ‘decision_function’, ‘auto’} default=’auto’ 

Specifies whether to use predict_proba or decision_function as the predicted target response. If set to ‘auto’, predict_proba is tried first and if it does not exist decision_function is tried next.  
namestr, default=None 

Name of DET curve for labeling. If None, use the name of the estimator.  
axmatplotlib axes, default=None 

Axes object to plot on. If None, a new figure and axes is created.  
pos_labelstr or int, default=None 

The label of the positive class. When pos_label=None, if y_true is in {-1, 1} or {0, 1}, pos_label is set to 1, otherwise an error will be raised.    Returns 
 
displayDetCurveDisplay 

Object that stores computed values.      See also  
det_curve


Compute error rates for different probability thresholds.  
DetCurveDisplay


DET curve visualization.  
plot_roc_curve


Plot Receiver operating characteristic (ROC) curve.    Examples >>> import matplotlib.pyplot as plt  
>>> from sklearn import datasets, metrics, model_selection, svm
>>> X, y = datasets.make_classification(random_state=0)
>>> X_train, X_test, y_train, y_test = model_selection.train_test_split(
...     X, y, random_state=0)
>>> clf = svm.SVC(random_state=0)
>>> clf.fit(X_train, y_train)
SVC(random_state=0)
>>> metrics.plot_det_curve(clf, X_test, y_test)  
>>> plt.show()
sklearn.metrics.plot_precision_recall_curve(estimator, X, y, *, sample_weight=None, response_method='auto', name=None, ax=None, pos_label=None, **kwargs) [source]
 
Plot Precision Recall Curve for binary classifiers. Extra keyword arguments will be passed to matplotlib’s plot. Read more in the User Guide.  Parameters 
 
estimatorestimator instance 

Fitted classifier or a fitted Pipeline in which the last estimator is a classifier.  
X{array-like, sparse matrix} of shape (n_samples, n_features) 

Input values.  
yarray-like of shape (n_samples,) 

Binary target values.  
sample_weightarray-like of shape (n_samples,), default=None 

Sample weights.  
response_method{‘predict_proba’, ‘decision_function’, ‘auto’}, default=’auto’ 

Specifies whether to use predict_proba or decision_function as the target response. If set to ‘auto’, predict_proba is tried first and if it does not exist decision_function is tried next.  
namestr, default=None 

Name for labeling curve. If None, the name of the estimator is used.  
axmatplotlib axes, default=None 

Axes object to plot on. If None, a new figure and axes is created.  
pos_labelstr or int, default=None 

The class considered as the positive class when computing the precision and recall metrics. By default, estimators.classes_[1] is considered as the positive class.  New in version 0.24.   
**kwargsdict 

Keyword arguments to be passed to matplotlib’s plot.    Returns 
 
displayPrecisionRecallDisplay 

Object that stores computed values.      See also  
precision_recall_curve


Compute precision-recall pairs for different probability thresholds.  
PrecisionRecallDisplay


Precision Recall visualization.
sklearn.metrics.plot_roc_curve(estimator, X, y, *, sample_weight=None, drop_intermediate=True, response_method='auto', name=None, ax=None, pos_label=None, **kwargs) [source]
 
Plot Receiver operating characteristic (ROC) curve. Extra keyword arguments will be passed to matplotlib’s plot. Read more in the User Guide.  Parameters 
 
estimatorestimator instance 

Fitted classifier or a fitted Pipeline in which the last estimator is a classifier.  
X{array-like, sparse matrix} of shape (n_samples, n_features) 

Input values.  
yarray-like of shape (n_samples,) 

Target values.  
sample_weightarray-like of shape (n_samples,), default=None 

Sample weights.  
drop_intermediateboolean, default=True 

Whether to drop some suboptimal thresholds which would not appear on a plotted ROC curve. This is useful in order to create lighter ROC curves.  
response_method{‘predict_proba’, ‘decision_function’, ‘auto’} default=’auto’ 

Specifies whether to use predict_proba or decision_function as the target response. If set to ‘auto’, predict_proba is tried first and if it does not exist decision_function is tried next.  
namestr, default=None 

Name of ROC Curve for labeling. If None, use the name of the estimator.  
axmatplotlib axes, default=None 

Axes object to plot on. If None, a new figure and axes is created.  
pos_labelstr or int, default=None 

The class considered as the positive class when computing the roc auc metrics. By default, estimators.classes_[1] is considered as the positive class.  New in version 0.24.     Returns 
 
displayRocCurveDisplay 

Object that stores computed values.      See also  
roc_curve


Compute Receiver operating characteristic (ROC) curve.  
RocCurveDisplay


ROC Curve visualization.  
roc_auc_score


Compute the area under the ROC curve.    Examples >>> import matplotlib.pyplot as plt  
>>> from sklearn import datasets, metrics, model_selection, svm
>>> X, y = datasets.make_classification(random_state=0)
>>> X_train, X_test, y_train, y_test = model_selection.train_test_split(
...     X, y, random_state=0)
>>> clf = svm.SVC(random_state=0)
>>> clf.fit(X_train, y_train)
SVC(random_state=0)
>>> metrics.plot_roc_curve(clf, X_test, y_test)  
>>> plt.show()