neulab/docprompting-conala huggingface dataset:
sklearn.metrics.mean_absolute_percentage_error  
sklearn.metrics.mean_absolute_percentage_error(y_true, y_pred, sample_weight=None, multioutput='uniform_average') [source]
 
Mean absolute percentage error regression loss. Note here that we do not represent the output as a percentage in range [0, 100]. Instead, we represent it in range [0, 1/eps]. Read more in the User Guide.  New in version 0.24.   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 

Defines aggregating of multiple output values. Array-like value defines weights used to average errors. If input is list then the shape must be (n_outputs,).  ‘raw_values’ :

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

Errors of all outputs are averaged with uniform weight.      Returns 
 
lossfloat or ndarray of floats in the range [0, 1/eps] 

If multioutput is ‘raw_values’, then mean absolute percentage 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. MAPE output is non-negative floating point. The best value is 0.0. But note the fact that bad predictions can lead to arbitarily large MAPE values, especially if some y_true values are very close to zero. Note that we return a large value instead of inf when y_true is zero.     Examples >>> from sklearn.metrics import mean_absolute_percentage_error
>>> y_true = [3, -0.5, 2, 7]
>>> y_pred = [2.5, 0.0, 2, 8]
>>> mean_absolute_percentage_error(y_true, y_pred)
0.3273...
>>> y_true = [[0.5, 1], [-1, 1], [7, -6]]
>>> y_pred = [[0, 2], [-1, 2], [8, -5]]
>>> mean_absolute_percentage_error(y_true, y_pred)
0.5515...
>>> mean_absolute_percentage_error(y_true, y_pred, multioutput=[0.3, 0.7])
0.6198...
sklearn.metrics.mean_gamma_deviance  
sklearn.metrics.mean_gamma_deviance(y_true, y_pred, *, sample_weight=None) [source]
 
Mean Gamma deviance regression loss. Gamma deviance is equivalent to the Tweedie deviance with the power parameter power=2. It is invariant to scaling of the target variable, and measures relative errors. Read more in the User Guide.  Parameters 
 
y_truearray-like of shape (n_samples,) 

Ground truth (correct) target values. Requires y_true > 0.  
y_predarray-like of shape (n_samples,) 

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

Sample weights.    Returns 
 
lossfloat 

A non-negative floating point value (the best value is 0.0).     Examples >>> from sklearn.metrics import mean_gamma_deviance
>>> y_true = [2, 0.5, 1, 4]
>>> y_pred = [0.5, 0.5, 2., 2.]
>>> mean_gamma_deviance(y_true, y_pred)
1.0568...
sklearn.metrics.mean_poisson_deviance  
sklearn.metrics.mean_poisson_deviance(y_true, y_pred, *, sample_weight=None) [source]
 
Mean Poisson deviance regression loss. Poisson deviance is equivalent to the Tweedie deviance with the power parameter power=1. Read more in the User Guide.  Parameters 
 
y_truearray-like of shape (n_samples,) 

Ground truth (correct) target values. Requires y_true >= 0.  
y_predarray-like of shape (n_samples,) 

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

Sample weights.    Returns 
 
lossfloat 

A non-negative floating point value (the best value is 0.0).     Examples >>> from sklearn.metrics import mean_poisson_deviance
>>> y_true = [2, 0, 1, 4]
>>> y_pred = [0.5, 0.5, 2., 2.]
>>> mean_poisson_deviance(y_true, y_pred)
1.4260...
 
 Examples using sklearn.metrics.mean_poisson_deviance
 
  Poisson regression and non-normal loss
sklearn.metrics.mean_squared_error  
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...
 
 Examples using sklearn.metrics.mean_squared_error
 
  Gradient Boosting regression  

  Model Complexity Influence  

  Plot Ridge coefficients as a function of the L2 regularization  

  Linear Regression Example  

  Robust linear estimator fitting  

  Poisson regression and non-normal loss  

  Tweedie regression on insurance claims
sklearn.metrics.mean_squared_log_error  
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  
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...
 
 Examples using sklearn.metrics.mean_tweedie_deviance
 
  Tweedie regression on insurance claims
sklearn.metrics.median_absolute_error  
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
 
 Examples using sklearn.metrics.median_absolute_error
 
  Common pitfalls in interpretation of coefficients of linear models  

  Effect of transforming the targets in regression model
sklearn.metrics.multilabel_confusion_matrix  
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  
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). 
 Examples using sklearn.metrics.mutual_info_score
 
  Adjustment for chance in clustering performance evaluation
sklearn.metrics.normalized_mutual_info_score  
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  
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  
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  
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  
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  
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.