neulab/docprompting-conala huggingface dataset:
sklearn.metrics.mean_squared_error(y_true, y_pred, *, sample_weight=None, multioutput='uniform_average', squared=True) [source]
 
Mean squared error regression loss. Read more in the User Guide.  Parameters 
 
y_truearray-like of shape (n_samples,) or (n_samples, n_outputs) 

Ground truth (correct) target values.  
y_predarray-like of shape (n_samples,) or (n_samples, n_outputs) 

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

Sample weights.  
multioutput{‘raw_values’, ‘uniform_average’} or array-like of shape (n_outputs,), default=’uniform_average’ 

Defines aggregating of multiple output values. Array-like value defines weights used to average errors.  ‘raw_values’ :

Returns a full set of errors in case of multioutput input.  ‘uniform_average’ :

Errors of all outputs are averaged with uniform weight.    
squaredbool, default=True 

If True returns MSE value, if False returns RMSE value.    Returns 
 
lossfloat or ndarray of floats 

A non-negative floating point value (the best value is 0.0), or an array of floating point values, one for each individual target.     Examples >>> from sklearn.metrics import mean_squared_error
>>> y_true = [3, -0.5, 2, 7]
>>> y_pred = [2.5, 0.0, 2, 8]
>>> mean_squared_error(y_true, y_pred)
0.375
>>> y_true = [3, -0.5, 2, 7]
>>> y_pred = [2.5, 0.0, 2, 8]
>>> mean_squared_error(y_true, y_pred, squared=False)
0.612...
>>> y_true = [[0.5, 1],[-1, 1],[7, -6]]
>>> y_pred = [[0, 2],[-1, 2],[8, -5]]
>>> mean_squared_error(y_true, y_pred)
0.708...
>>> mean_squared_error(y_true, y_pred, squared=False)
0.822...
>>> mean_squared_error(y_true, y_pred, multioutput='raw_values')
array([0.41666667, 1.        ])
>>> mean_squared_error(y_true, y_pred, multioutput=[0.3, 0.7])
0.825...
sklearn.metrics.mean_squared_log_error(y_true, y_pred, *, sample_weight=None, multioutput='uniform_average') [source]
 
Mean squared logarithmic error regression loss. Read more in the User Guide.  Parameters 
 
y_truearray-like of shape (n_samples,) or (n_samples, n_outputs) 

Ground truth (correct) target values.  
y_predarray-like of shape (n_samples,) or (n_samples, n_outputs) 

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

Sample weights.  
multioutput{‘raw_values’, ‘uniform_average’} or array-like of shape (n_outputs,), default=’uniform_average’ 

Defines aggregating of multiple output values. Array-like value defines weights used to average errors.  ‘raw_values’ :

Returns a full set of errors when the input is of multioutput format.  ‘uniform_average’ :

Errors of all outputs are averaged with uniform weight.      Returns 
 
lossfloat or ndarray of floats 

A non-negative floating point value (the best value is 0.0), or an array of floating point values, one for each individual target.     Examples >>> from sklearn.metrics import mean_squared_log_error
>>> y_true = [3, 5, 2.5, 7]
>>> y_pred = [2.5, 5, 4, 8]
>>> mean_squared_log_error(y_true, y_pred)
0.039...
>>> y_true = [[0.5, 1], [1, 2], [7, 6]]
>>> y_pred = [[0.5, 2], [1, 2.5], [8, 8]]
>>> mean_squared_log_error(y_true, y_pred)
0.044...
>>> mean_squared_log_error(y_true, y_pred, multioutput='raw_values')
array([0.00462428, 0.08377444])
>>> mean_squared_log_error(y_true, y_pred, multioutput=[0.3, 0.7])
0.060...
sklearn.metrics.mean_tweedie_deviance(y_true, y_pred, *, sample_weight=None, power=0) [source]
 
Mean Tweedie deviance regression loss. Read more in the User Guide.  Parameters 
 
y_truearray-like of shape (n_samples,) 

Ground truth (correct) target values.  
y_predarray-like of shape (n_samples,) 

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

Sample weights.  
powerfloat, default=0 

Tweedie power parameter. Either power <= 0 or power >= 1. The higher p the less weight is given to extreme deviations between true and predicted targets.  power < 0: Extreme stable distribution. Requires: y_pred > 0. power = 0 : Normal distribution, output corresponds to mean_squared_error. y_true and y_pred can be any real numbers. power = 1 : Poisson distribution. Requires: y_true >= 0 and y_pred > 0. 1 < p < 2 : Compound Poisson distribution. Requires: y_true >= 0 and y_pred > 0. power = 2 : Gamma distribution. Requires: y_true > 0 and y_pred > 0. power = 3 : Inverse Gaussian distribution. Requires: y_true > 0 and y_pred > 0. otherwise : Positive stable distribution. Requires: y_true > 0 and y_pred > 0.     Returns 
 
lossfloat 

A non-negative floating point value (the best value is 0.0).     Examples >>> from sklearn.metrics import mean_tweedie_deviance
>>> y_true = [2, 0, 1, 4]
>>> y_pred = [0.5, 0.5, 2., 2.]
>>> mean_tweedie_deviance(y_true, y_pred, power=1)
1.4260...
sklearn.metrics.median_absolute_error(y_true, y_pred, *, multioutput='uniform_average', sample_weight=None) [source]
 
Median absolute error regression loss. Median absolute error output is non-negative floating point. The best value is 0.0. Read more in the User Guide.  Parameters 
 
y_truearray-like of shape = (n_samples) or (n_samples, n_outputs) 

Ground truth (correct) target values.  
y_predarray-like of shape = (n_samples) or (n_samples, n_outputs) 

Estimated target values.  
multioutput{‘raw_values’, ‘uniform_average’} or array-like of shape (n_outputs,), default=’uniform_average’ 

Defines aggregating of multiple output values. Array-like value defines weights used to average errors.  ‘raw_values’ :

Returns a full set of errors in case of multioutput input.  ‘uniform_average’ :

Errors of all outputs are averaged with uniform weight.    
sample_weightarray-like of shape (n_samples,), default=None 

Sample weights.  New in version 0.24.     Returns 
 
lossfloat or ndarray of floats 

If multioutput is ‘raw_values’, then mean absolute error is returned for each output separately. If multioutput is ‘uniform_average’ or an ndarray of weights, then the weighted average of all output errors is returned.     Examples >>> from sklearn.metrics import median_absolute_error
>>> y_true = [3, -0.5, 2, 7]
>>> y_pred = [2.5, 0.0, 2, 8]
>>> median_absolute_error(y_true, y_pred)
0.5
>>> y_true = [[0.5, 1], [-1, 1], [7, -6]]
>>> y_pred = [[0, 2], [-1, 2], [8, -5]]
>>> median_absolute_error(y_true, y_pred)
0.75
>>> median_absolute_error(y_true, y_pred, multioutput='raw_values')
array([0.5, 1. ])
>>> median_absolute_error(y_true, y_pred, multioutput=[0.3, 0.7])
0.85
sklearn.metrics.multilabel_confusion_matrix(y_true, y_pred, *, sample_weight=None, labels=None, samplewise=False) [source]
 
Compute a confusion matrix for each class or sample.  New in version 0.21.  Compute class-wise (default) or sample-wise (samplewise=True) multilabel confusion matrix to evaluate the accuracy of a classification, and output confusion matrices for each class or sample. In multilabel confusion matrix \(MCM\), the count of true negatives is \(MCM_{:,0,0}\), false negatives is \(MCM_{:,1,0}\), true positives is \(MCM_{:,1,1}\) and false positives is \(MCM_{:,0,1}\). Multiclass data will be treated as if binarized under a one-vs-rest transformation. Returned confusion matrices will be in the order of sorted unique labels in the union of (y_true, y_pred). Read more in the User Guide.  Parameters 
 
y_true{array-like, sparse matrix} of shape (n_samples, n_outputs) or (n_samples,) 

Ground truth (correct) target values.  
y_pred{array-like, sparse matrix} of shape (n_samples, n_outputs) or (n_samples,) 

Estimated targets as returned by a classifier.  
sample_weightarray-like of shape (n_samples,), default=None 

Sample weights.  
labelsarray-like of shape (n_classes,), default=None 

A list of classes or column indices to select some (or to force inclusion of classes absent from the data).  
samplewisebool, default=False 

In the multilabel case, this calculates a confusion matrix per sample.    Returns 
 
multi_confusionndarray of shape (n_outputs, 2, 2) 

A 2x2 confusion matrix corresponding to each output in the input. When calculating class-wise multi_confusion (default), then n_outputs = n_labels; when calculating sample-wise multi_confusion (samplewise=True), n_outputs = n_samples. If labels is defined, the results will be returned in the order specified in labels, otherwise the results will be returned in sorted order by default.      See also  
confusion_matrix

  Notes The multilabel_confusion_matrix calculates class-wise or sample-wise multilabel confusion matrices, and in multiclass tasks, labels are binarized under a one-vs-rest way; while confusion_matrix calculates one confusion matrix for confusion between every two classes. Examples Multilabel-indicator case: >>> import numpy as np
>>> from sklearn.metrics import multilabel_confusion_matrix
>>> y_true = np.array([[1, 0, 1],
...                    [0, 1, 0]])
>>> y_pred = np.array([[1, 0, 0],
...                    [0, 1, 1]])
>>> multilabel_confusion_matrix(y_true, y_pred)
array([[[1, 0],
        [0, 1]],

       [[1, 0],
        [0, 1]],

       [[0, 1],
        [1, 0]]])
 Multiclass case: >>> y_true = ["cat", "ant", "cat", "cat", "ant", "bird"]
>>> y_pred = ["ant", "ant", "cat", "cat", "ant", "cat"]
>>> multilabel_confusion_matrix(y_true, y_pred,
...                             labels=["ant", "bird", "cat"])
array([[[3, 1],
        [0, 2]],

       [[5, 0],
        [1, 0]],

       [[2, 1],
        [1, 2]]])
sklearn.metrics.mutual_info_score(labels_true, labels_pred, *, contingency=None) [source]
 
Mutual Information between two clusterings. The Mutual Information is a measure of the similarity between two labels of the same data. Where \(|U_i|\) is the number of the samples in cluster \(U_i\) and \(|V_j|\) is the number of the samples in cluster \(V_j\), the Mutual Information between clusterings \(U\) and \(V\) is given as:  \[MI(U,V)=\sum_{i=1}^{|U|} \sum_{j=1}^{|V|} \frac{|U_i\cap V_j|}{N} \log\frac{N|U_i \cap V_j|}{|U_i||V_j|}\] This metric is independent of the absolute values of the labels: a permutation of the class or cluster label values won’t change the score value in any way. This metric is furthermore symmetric: switching label_true with label_pred will return the same score value. This can be useful to measure the agreement of two independent label assignments strategies on the same dataset when the real ground truth is not known. Read more in the User Guide.  Parameters 
 
labels_trueint array, shape = [n_samples] 

A clustering of the data into disjoint subsets.  
labels_predint array-like of shape (n_samples,) 

A clustering of the data into disjoint subsets.  
contingency{ndarray, sparse matrix} of shape (n_classes_true, n_classes_pred), default=None 

A contingency matrix given by the contingency_matrix function. If value is None, it will be computed, otherwise the given value is used, with labels_true and labels_pred ignored.    Returns 
 
mifloat 

Mutual information, a non-negative value      See also  
adjusted_mutual_info_score


Adjusted against chance Mutual Information.  
normalized_mutual_info_score


Normalized Mutual Information.    Notes The logarithm used is the natural logarithm (base-e).
sklearn.metrics.normalized_mutual_info_score(labels_true, labels_pred, *, average_method='arithmetic') [source]
 
Normalized Mutual Information between two clusterings. Normalized Mutual Information (NMI) is a normalization of the Mutual Information (MI) score to scale the results between 0 (no mutual information) and 1 (perfect correlation). In this function, mutual information is normalized by some generalized mean of H(labels_true) and H(labels_pred)), defined by the average_method. This measure is not adjusted for chance. Therefore adjusted_mutual_info_score might be preferred. This metric is independent of the absolute values of the labels: a permutation of the class or cluster label values won’t change the score value in any way. This metric is furthermore symmetric: switching label_true with label_pred will return the same score value. This can be useful to measure the agreement of two independent label assignments strategies on the same dataset when the real ground truth is not known. Read more in the User Guide.  Parameters 
 
labels_trueint array, shape = [n_samples] 

A clustering of the data into disjoint subsets.  
labels_predint array-like of shape (n_samples,) 

A clustering of the data into disjoint subsets.  
average_methodstr, default=’arithmetic’ 

How to compute the normalizer in the denominator. Possible options are ‘min’, ‘geometric’, ‘arithmetic’, and ‘max’.  New in version 0.20.   Changed in version 0.22: The default value of average_method changed from ‘geometric’ to ‘arithmetic’.     Returns 
 
nmifloat 

score between 0.0 and 1.0. 1.0 stands for perfectly complete labeling      See also  
v_measure_score


V-Measure (NMI with arithmetic mean option).  
adjusted_rand_score


Adjusted Rand Index.  
adjusted_mutual_info_score


Adjusted Mutual Information (adjusted against chance).    Examples Perfect labelings are both homogeneous and complete, hence have score 1.0: >>> from sklearn.metrics.cluster import normalized_mutual_info_score
>>> normalized_mutual_info_score([0, 0, 1, 1], [0, 0, 1, 1])
... 
1.0
>>> normalized_mutual_info_score([0, 0, 1, 1], [1, 1, 0, 0])
... 
1.0
 If classes members are completely split across different clusters, the assignment is totally in-complete, hence the NMI is null: >>> normalized_mutual_info_score([0, 0, 0, 0], [0, 1, 2, 3])
... 
0.0
sklearn.metrics.pairwise.additive_chi2_kernel(X, Y=None) [source]
 
Computes the additive chi-squared kernel between observations in X and Y. The chi-squared kernel is computed between each pair of rows in X and Y. X and Y have to be non-negative. This kernel is most commonly applied to histograms. The chi-squared kernel is given by: k(x, y) = -Sum [(x - y)^2 / (x + y)]
 It can be interpreted as a weighted difference per entry. Read more in the User Guide.  Parameters 
 
Xarray-like of shape (n_samples_X, n_features) 

Yndarray of shape (n_samples_Y, n_features), default=None 
  Returns 
 
kernel_matrixndarray of shape (n_samples_X, n_samples_Y) 
    See also  
chi2_kernel


The exponentiated version of the kernel, which is usually preferable.  
sklearn.kernel_approximation.AdditiveChi2Sampler


A Fourier approximation to this kernel.    Notes As the negative of a distance, this kernel is only conditionally positive definite. References  Zhang, J. and Marszalek, M. and Lazebnik, S. and Schmid, C. Local features and kernels for classification of texture and object categories: A comprehensive study International Journal of Computer Vision 2007 https://research.microsoft.com/en-us/um/people/manik/projects/trade-off/papers/ZhangIJCV06.pdf
sklearn.metrics.pairwise.chi2_kernel(X, Y=None, gamma=1.0) [source]
 
Computes the exponential chi-squared kernel X and Y. The chi-squared kernel is computed between each pair of rows in X and Y. X and Y have to be non-negative. This kernel is most commonly applied to histograms. The chi-squared kernel is given by: k(x, y) = exp(-gamma Sum [(x - y)^2 / (x + y)])
 It can be interpreted as a weighted difference per entry. Read more in the User Guide.  Parameters 
 
Xarray-like of shape (n_samples_X, n_features) 

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

gammafloat, default=1. 

Scaling parameter of the chi2 kernel.    Returns 
 
kernel_matrixndarray of shape (n_samples_X, n_samples_Y) 
    See also  
additive_chi2_kernel


The additive version of this kernel.  
sklearn.kernel_approximation.AdditiveChi2Sampler


A Fourier approximation to the additive version of this kernel.    References  Zhang, J. and Marszalek, M. and Lazebnik, S. and Schmid, C. Local features and kernels for classification of texture and object categories: A comprehensive study International Journal of Computer Vision 2007 https://research.microsoft.com/en-us/um/people/manik/projects/trade-off/papers/ZhangIJCV06.pdf
sklearn.metrics.pairwise.cosine_distances(X, Y=None) [source]
 
Compute cosine distance between samples in X and Y. Cosine distance is defined as 1.0 minus the cosine similarity. Read more in the User Guide.  Parameters 
 
X{array-like, sparse matrix} of shape (n_samples_X, n_features) 

Matrix X.  
Y{array-like, sparse matrix} of shape (n_samples_Y, n_features), default=None 

Matrix Y.    Returns 
 
distance matrixndarray of shape (n_samples_X, n_samples_Y) 
    See also  
cosine_similarity


scipy.spatial.distance.cosine


Dense matrices only.
sklearn.metrics.pairwise.cosine_similarity(X, Y=None, dense_output=True) [source]
 
Compute cosine similarity between samples in X and Y. Cosine similarity, or the cosine kernel, computes similarity as the normalized dot product of X and Y: K(X, Y) = <X, Y> / (||X||*||Y||) On L2-normalized data, this function is equivalent to linear_kernel. Read more in the User Guide.  Parameters 
 
X{ndarray, sparse matrix} of shape (n_samples_X, n_features) 

Input data.  
Y{ndarray, sparse matrix} of shape (n_samples_Y, n_features), default=None 

Input data. If None, the output will be the pairwise similarities between all samples in X.  
dense_outputbool, default=True 

Whether to return dense output even when the input is sparse. If False, the output is sparse if both input arrays are sparse.  New in version 0.17: parameter dense_output for dense output.     Returns 
 
kernel matrixndarray of shape (n_samples_X, n_samples_Y)
sklearn.metrics.pairwise.distance_metrics() [source]
 
Valid metrics for pairwise_distances. This function simply returns the valid pairwise distance metrics. It exists to allow for a description of the mapping for each of the valid strings. The valid distance metrics, and the function they map to, are:   
metric Function   
‘cityblock’ metrics.pairwise.manhattan_distances  
‘cosine’ metrics.pairwise.cosine_distances  
‘euclidean’ metrics.pairwise.euclidean_distances  
‘haversine’ metrics.pairwise.haversine_distances  
‘l1’ metrics.pairwise.manhattan_distances  
‘l2’ metrics.pairwise.euclidean_distances  
‘manhattan’ metrics.pairwise.manhattan_distances  
‘nan_euclidean’ metrics.pairwise.nan_euclidean_distances   Read more in the User Guide.
sklearn.metrics.pairwise.euclidean_distances(X, Y=None, *, Y_norm_squared=None, squared=False, X_norm_squared=None) [source]
 
Considering the rows of X (and Y=X) as vectors, compute the distance matrix between each pair of vectors. For efficiency reasons, the euclidean distance between a pair of row vector x and y is computed as: dist(x, y) = sqrt(dot(x, x) - 2 * dot(x, y) + dot(y, y))
 This formulation has two advantages over other ways of computing distances. First, it is computationally efficient when dealing with sparse data. Second, if one argument varies but the other remains unchanged, then dot(x, x) and/or dot(y, y) can be pre-computed. However, this is not the most precise way of doing this computation, because this equation potentially suffers from “catastrophic cancellation”. Also, the distance matrix returned by this function may not be exactly symmetric as required by, e.g., scipy.spatial.distance functions. Read more in the User Guide.  Parameters 
 
X{array-like, sparse matrix} of shape (n_samples_X, n_features) 

Y{array-like, sparse matrix} of shape (n_samples_Y, n_features), default=None 

Y_norm_squaredarray-like of shape (n_samples_Y,), default=None 

Pre-computed dot-products of vectors in Y (e.g., (Y**2).sum(axis=1)) May be ignored in some cases, see the note below.  
squaredbool, default=False 

Return squared Euclidean distances.  
X_norm_squaredarray-like of shape (n_samples,), default=None 

Pre-computed dot-products of vectors in X (e.g., (X**2).sum(axis=1)) May be ignored in some cases, see the note below.    Returns 
 
distancesndarray of shape (n_samples_X, n_samples_Y) 
    See also  
paired_distances


Distances betweens pairs of elements of X and Y.    Notes To achieve better accuracy, X_norm_squared and Y_norm_squared may be unused if they are passed as float32. Examples >>> from sklearn.metrics.pairwise import euclidean_distances
>>> X = [[0, 1], [1, 1]]
>>> # distance between rows of X
>>> euclidean_distances(X, X)
array([[0., 1.],
       [1., 0.]])
>>> # get distance to origin
>>> euclidean_distances(X, [[0, 0]])
array([[1.        ],
       [1.41421356]])
sklearn.metrics.pairwise.haversine_distances(X, Y=None) [source]
 
Compute the Haversine distance between samples in X and Y. The Haversine (or great circle) distance is the angular distance between two points on the surface of a sphere. The first coordinate of each point is assumed to be the latitude, the second is the longitude, given in radians. The dimension of the data must be 2.  \[D(x, y) = 2\arcsin[\sqrt{\sin^2((x1 - y1) / 2) + \cos(x1)\cos(y1)\sin^2((x2 - y2) / 2)}]\]  Parameters 
 
Xarray-like of shape (n_samples_X, 2) 

Yarray-like of shape (n_samples_Y, 2), default=None 
  Returns 
 
distancendarray of shape (n_samples_X, n_samples_Y) 
   Notes As the Earth is nearly spherical, the haversine formula provides a good approximation of the distance between two points of the Earth surface, with a less than 1% error on average. Examples We want to calculate the distance between the Ezeiza Airport (Buenos Aires, Argentina) and the Charles de Gaulle Airport (Paris, France). >>> from sklearn.metrics.pairwise import haversine_distances
>>> from math import radians
>>> bsas = [-34.83333, -58.5166646]
>>> paris = [49.0083899664, 2.53844117956]
>>> bsas_in_radians = [radians(_) for _ in bsas]
>>> paris_in_radians = [radians(_) for _ in paris]
>>> result = haversine_distances([bsas_in_radians, paris_in_radians])
>>> result * 6371000/1000  # multiply by Earth radius to get kilometers
array([[    0.        , 11099.54035582],
       [11099.54035582,     0.        ]])
sklearn.metrics.pairwise.kernel_metrics() [source]
 
Valid metrics for pairwise_kernels. This function simply returns the valid pairwise distance metrics. It exists, however, to allow for a verbose description of the mapping for each of the valid strings.  The valid distance metrics, and the function they map to, are:

  
metric Function   
‘additive_chi2’ sklearn.pairwise.additive_chi2_kernel  
‘chi2’ sklearn.pairwise.chi2_kernel  
‘linear’ sklearn.pairwise.linear_kernel  
‘poly’ sklearn.pairwise.polynomial_kernel  
‘polynomial’ sklearn.pairwise.polynomial_kernel  
‘rbf’ sklearn.pairwise.rbf_kernel  
‘laplacian’ sklearn.pairwise.laplacian_kernel  
‘sigmoid’ sklearn.pairwise.sigmoid_kernel  
‘cosine’ sklearn.pairwise.cosine_similarity     Read more in the User Guide.
sklearn.metrics.pairwise.laplacian_kernel(X, Y=None, gamma=None) [source]
 
Compute the laplacian kernel between X and Y. The laplacian kernel is defined as: K(x, y) = exp(-gamma ||x-y||_1)
 for each pair of rows x in X and y in Y. Read more in the User Guide.  New in version 0.17.   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.linear_kernel(X, Y=None, dense_output=True) [source]
 
Compute the linear kernel between X and 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 

dense_outputbool, default=True 

Whether to return dense output even when the input is sparse. If False, the output is sparse if both input arrays are sparse.  New in version 0.20.     Returns 
 
Gram matrixndarray of shape (n_samples_X, n_samples_Y)