neulab/docprompting-conala huggingface dataset:
sklearn.isotonic.isotonic_regression  
sklearn.isotonic.isotonic_regression(y, *, sample_weight=None, y_min=None, y_max=None, increasing=True) [source]
 
Solve the isotonic regression model. Read more in the User Guide.  Parameters 
 
yarray-like of shape (n_samples,) 

The data.  
sample_weightarray-like of shape (n_samples,), default=None 

Weights on each point of the regression. If None, weight is set to 1 (equal weights).  
y_minfloat, default=None 

Lower bound on the lowest predicted value (the minimum value may still be higher). If not set, defaults to -inf.  
y_maxfloat, default=None 

Upper bound on the highest predicted value (the maximum may still be lower). If not set, defaults to +inf.  
increasingbool, default=True 

Whether to compute y_ is increasing (if set to True) or decreasing (if set to False)    Returns 
 
y_list of floats 

Isotonic fit of y.     References “Active set algorithms for isotonic regression; A unifying framework” by Michael J. Best and Nilotpal Chakravarti, section 3.
sklearn.linear_model.orthogonal_mp  
sklearn.linear_model.orthogonal_mp(X, y, *, n_nonzero_coefs=None, tol=None, precompute=False, copy_X=True, return_path=False, return_n_iter=False) [source]
 
Orthogonal Matching Pursuit (OMP). Solves n_targets Orthogonal Matching Pursuit problems. An instance of the problem has the form: When parametrized by the number of non-zero coefficients using n_nonzero_coefs: argmin ||y - Xgamma||^2 subject to ||gamma||_0 <= n_{nonzero coefs} When parametrized by error using the parameter tol: argmin ||gamma||_0 subject to ||y - Xgamma||^2 <= tol Read more in the User Guide.  Parameters 
 
Xndarray of shape (n_samples, n_features) 

Input data. Columns are assumed to have unit norm.  
yndarray of shape (n_samples,) or (n_samples, n_targets) 

Input targets.  
n_nonzero_coefsint, default=None 

Desired number of non-zero entries in the solution. If None (by default) this value is set to 10% of n_features.  
tolfloat, default=None 

Maximum norm of the residual. If not None, overrides n_nonzero_coefs.  
precompute‘auto’ or bool, default=False 

Whether to perform precomputations. Improves performance when n_targets or n_samples is very large.  
copy_Xbool, default=True 

Whether the design matrix X must be copied by the algorithm. A false value is only helpful if X is already Fortran-ordered, otherwise a copy is made anyway.  
return_pathbool, default=False 

Whether to return every value of the nonzero coefficients along the forward path. Useful for cross-validation.  
return_n_iterbool, default=False 

Whether or not to return the number of iterations.    Returns 
 
coefndarray of shape (n_features,) or (n_features, n_targets) 

Coefficients of the OMP solution. If return_path=True, this contains the whole coefficient path. In this case its shape is (n_features, n_features) or (n_features, n_targets, n_features) and iterating over the last axis yields coefficients in increasing order of active features.  
n_itersarray-like or int 

Number of active features across every target. Returned only if return_n_iter is set to True.      See also  
OrthogonalMatchingPursuit


orthogonal_mp_gram


lars_path


sklearn.decomposition.sparse_encode

  Notes Orthogonal matching pursuit was introduced in S. Mallat, Z. Zhang, Matching pursuits with time-frequency dictionaries, IEEE Transactions on Signal Processing, Vol. 41, No. 12. (December 1993), pp. 3397-3415. (http://blanche.polytechnique.fr/~mallat/papiers/MallatPursuit93.pdf) This implementation is based on Rubinstein, R., Zibulevsky, M. and Elad, M., Efficient Implementation of the K-SVD Algorithm using Batch Orthogonal Matching Pursuit Technical Report - CS Technion, April 2008. https://www.cs.technion.ac.il/~ronrubin/Publications/KSVD-OMP-v2.pdf
sklearn.linear_model.orthogonal_mp_gram  
sklearn.linear_model.orthogonal_mp_gram(Gram, Xy, *, n_nonzero_coefs=None, tol=None, norms_squared=None, copy_Gram=True, copy_Xy=True, return_path=False, return_n_iter=False) [source]
 
Gram Orthogonal Matching Pursuit (OMP). Solves n_targets Orthogonal Matching Pursuit problems using only the Gram matrix X.T * X and the product X.T * y. Read more in the User Guide.  Parameters 
 
Gramndarray of shape (n_features, n_features) 

Gram matrix of the input data: X.T * X.  
Xyndarray of shape (n_features,) or (n_features, n_targets) 

Input targets multiplied by X: X.T * y.  
n_nonzero_coefsint, default=None 

Desired number of non-zero entries in the solution. If None (by default) this value is set to 10% of n_features.  
tolfloat, default=None 

Maximum norm of the residual. If not None, overrides n_nonzero_coefs.  
norms_squaredarray-like of shape (n_targets,), default=None 

Squared L2 norms of the lines of y. Required if tol is not None.  
copy_Grambool, default=True 

Whether the gram matrix must be copied by the algorithm. A false value is only helpful if it is already Fortran-ordered, otherwise a copy is made anyway.  
copy_Xybool, default=True 

Whether the covariance vector Xy must be copied by the algorithm. If False, it may be overwritten.  
return_pathbool, default=False 

Whether to return every value of the nonzero coefficients along the forward path. Useful for cross-validation.  
return_n_iterbool, default=False 

Whether or not to return the number of iterations.    Returns 
 
coefndarray of shape (n_features,) or (n_features, n_targets) 

Coefficients of the OMP solution. If return_path=True, this contains the whole coefficient path. In this case its shape is (n_features, n_features) or (n_features, n_targets, n_features) and iterating over the last axis yields coefficients in increasing order of active features.  
n_itersarray-like or int 

Number of active features across every target. Returned only if return_n_iter is set to True.      See also  
OrthogonalMatchingPursuit


orthogonal_mp


lars_path


sklearn.decomposition.sparse_encode

  Notes Orthogonal matching pursuit was introduced in G. Mallat, Z. Zhang, Matching pursuits with time-frequency dictionaries, IEEE Transactions on Signal Processing, Vol. 41, No. 12. (December 1993), pp. 3397-3415. (http://blanche.polytechnique.fr/~mallat/papiers/MallatPursuit93.pdf) This implementation is based on Rubinstein, R., Zibulevsky, M. and Elad, M., Efficient Implementation of the K-SVD Algorithm using Batch Orthogonal Matching Pursuit Technical Report - CS Technion, April 2008. https://www.cs.technion.ac.il/~ronrubin/Publications/KSVD-OMP-v2.pdf
sklearn.manifold.spectral_embedding  
sklearn.manifold.spectral_embedding(adjacency, *, n_components=8, eigen_solver=None, random_state=None, eigen_tol=0.0, norm_laplacian=True, drop_first=True) [source]
 
Project the sample on the first eigenvectors of the graph Laplacian. The adjacency matrix is used to compute a normalized graph Laplacian whose spectrum (especially the eigenvectors associated to the smallest eigenvalues) has an interpretation in terms of minimal number of cuts necessary to split the graph into comparably sized components. This embedding can also ‘work’ even if the adjacency variable is not strictly the adjacency matrix of a graph but more generally an affinity or similarity matrix between samples (for instance the heat kernel of a euclidean distance matrix or a k-NN matrix). However care must taken to always make the affinity matrix symmetric so that the eigenvector decomposition works as expected. Note : Laplacian Eigenmaps is the actual algorithm implemented here. Read more in the User Guide.  Parameters 
 
adjacency{array-like, sparse graph} of shape (n_samples, n_samples) 

The adjacency matrix of the graph to embed.  
n_componentsint, default=8 

The dimension of the projection subspace.  
eigen_solver{‘arpack’, ‘lobpcg’, ‘amg’}, default=None 

The eigenvalue decomposition strategy to use. AMG requires pyamg to be installed. It can be faster on very large, sparse problems, but may also lead to instabilities. If None, then 'arpack' is used.  
random_stateint, RandomState instance or None, default=None 

Determines the random number generator used for the initialization of the lobpcg eigenvectors decomposition when solver == ‘amg’. Pass an int for reproducible results across multiple function calls. See :term: Glossary <random_state>.  
eigen_tolfloat, default=0.0 

Stopping criterion for eigendecomposition of the Laplacian matrix when using arpack eigen_solver.  
norm_laplacianbool, default=True 

If True, then compute normalized Laplacian.  
drop_firstbool, default=True 

Whether to drop the first eigenvector. For spectral embedding, this should be True as the first eigenvector should be constant vector for connected graph, but for spectral clustering, this should be kept as False to retain the first eigenvector.    Returns 
 
embeddingndarray of shape (n_samples, n_components) 

The reduced samples.     Notes Spectral Embedding (Laplacian Eigenmaps) is most useful when the graph has one connected component. If there graph has many components, the first few eigenvectors will simply uncover the connected components of the graph. References  https://en.wikipedia.org/wiki/LOBPCG Toward the Optimal Preconditioned Eigensolver: Locally Optimal Block Preconditioned Conjugate Gradient Method Andrew V. Knyazev https://doi.org/10.1137%2FS1064827500366124
sklearn.manifold.trustworthiness  
sklearn.manifold.trustworthiness(X, X_embedded, *, n_neighbors=5, metric='euclidean') [source]
 
Expresses to what extent the local structure is retained. The trustworthiness is within [0, 1]. It is defined as  \[T(k) = 1 - \frac{2}{nk (2n - 3k - 1)} \sum^n_{i=1} \sum_{j \in \mathcal{N}_{i}^{k}} \max(0, (r(i, j) - k))\] where for each sample i, \(\mathcal{N}_{i}^{k}\) are its k nearest neighbors in the output space, and every sample j is its \(r(i, j)\)-th nearest neighbor in the input space. In other words, any unexpected nearest neighbors in the output space are penalised in proportion to their rank in the input space.  “Neighborhood Preservation in Nonlinear Projection Methods: An Experimental Study” J. Venna, S. Kaski “Learning a Parametric Embedding by Preserving Local Structure” L.J.P. van der Maaten   Parameters 
 
Xndarray of shape (n_samples, n_features) or (n_samples, n_samples) 

If the metric is ‘precomputed’ X must be a square distance matrix. Otherwise it contains a sample per row.  
X_embeddedndarray of shape (n_samples, n_components) 

Embedding of the training data in low-dimensional space.  
n_neighborsint, default=5 

Number of neighbors k that will be considered.  
metricstr or callable, default=’euclidean’ 

Which metric to use for computing pairwise distances between samples from the original input space. If metric is ‘precomputed’, X must be a matrix of pairwise distances or squared distances. Otherwise, see the documentation of argument metric in sklearn.pairwise.pairwise_distances for a list of available metrics.  New in version 0.20.     Returns 
 
trustworthinessfloat 

Trustworthiness of the low-dimensional embedding.
sklearn.metrics.accuracy_score  
sklearn.metrics.accuracy_score(y_true, y_pred, *, normalize=True, sample_weight=None) [source]
 
Accuracy classification score. In multilabel classification, this function computes subset accuracy: the set of labels predicted for a sample must exactly match the corresponding set of labels in y_true. Read more in the User Guide.  Parameters 
 
y_true1d array-like, or label indicator array / sparse matrix 

Ground truth (correct) labels.  
y_pred1d array-like, or label indicator array / sparse matrix 

Predicted labels, as returned by a classifier.  
normalizebool, default=True 

If False, return the number of correctly classified samples. Otherwise, return the fraction of correctly classified samples.  
sample_weightarray-like of shape (n_samples,), default=None 

Sample weights.    Returns 
 
scorefloat 

If normalize == True, return the fraction of correctly classified samples (float), else returns the number of correctly classified samples (int). The best performance is 1 with normalize == True and the number of samples with normalize == False.      See also  
jaccard_score, hamming_loss, zero_one_loss

  Notes In binary and multiclass classification, this function is equal to the jaccard_score function. Examples >>> from sklearn.metrics import accuracy_score
>>> y_pred = [0, 2, 1, 3]
>>> y_true = [0, 1, 2, 3]
>>> accuracy_score(y_true, y_pred)
0.5
>>> accuracy_score(y_true, y_pred, normalize=False)
2
 In the multilabel case with binary label indicators: >>> import numpy as np
>>> accuracy_score(np.array([[0, 1], [1, 1]]), np.ones((2, 2)))
0.5
 
 Examples using sklearn.metrics.accuracy_score
 
  Plot classification probability  

  Multi-class AdaBoosted Decision Trees  

  Probabilistic predictions with Gaussian process classification (GPC)  

  Demonstration of multi-metric evaluation on cross_val_score and GridSearchCV  

  Importance of Feature Scaling  

  Effect of varying threshold for self-training  

  Classification of text documents using sparse features
sklearn.metrics.adjusted_mutual_info_score  
sklearn.metrics.adjusted_mutual_info_score(labels_true, labels_pred, *, average_method='arithmetic') [source]
 
Adjusted Mutual Information between two clusterings. Adjusted Mutual Information (AMI) is an adjustment of the Mutual Information (MI) score to account for chance. It accounts for the fact that the MI is generally higher for two clusterings with a larger number of clusters, regardless of whether there is actually more information shared. For two clusterings \(U\) and \(V\), the AMI is given as: AMI(U, V) = [MI(U, V) - E(MI(U, V))] / [avg(H(U), H(V)) - E(MI(U, V))]
 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. Be mindful that this function is an order of magnitude slower than other metrics, such as the Adjusted Rand Index. 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 ‘max’ to ‘arithmetic’.     Returns 
 ami: float (upperlimited by 1.0)

The AMI returns a value of 1 when the two partitions are identical (ie perfectly matched). Random partitions (independent labellings) have an expected AMI around 0 on average hence can be negative.      See also  
adjusted_rand_score


Adjusted Rand Index.  
mutual_info_score


Mutual Information (not adjusted for chance).    References  
1  
Vinh, Epps, and Bailey, (2010). Information Theoretic Measures for Clusterings Comparison: Variants, Properties, Normalization and Correction for Chance, JMLR  
2  
Wikipedia entry for the Adjusted Mutual Information   Examples Perfect labelings are both homogeneous and complete, hence have score 1.0: >>> from sklearn.metrics.cluster import adjusted_mutual_info_score
>>> adjusted_mutual_info_score([0, 0, 1, 1], [0, 0, 1, 1])
... 
1.0
>>> adjusted_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 AMI is null: >>> adjusted_mutual_info_score([0, 0, 0, 0], [0, 1, 2, 3])
... 
0.0
 
 Examples using sklearn.metrics.adjusted_mutual_info_score
 
  Demo of affinity propagation clustering algorithm  

  Demo of DBSCAN clustering algorithm  

  Adjustment for chance in clustering performance evaluation  

  A demo of K-Means clustering on the handwritten digits data
sklearn.metrics.adjusted_rand_score  
sklearn.metrics.adjusted_rand_score(labels_true, labels_pred) [source]
 
Rand index adjusted for chance. The Rand Index computes a similarity measure between two clusterings by considering all pairs of samples and counting pairs that are assigned in the same or different clusters in the predicted and true clusterings. The raw RI score is then “adjusted for chance” into the ARI score using the following scheme: ARI = (RI - Expected_RI) / (max(RI) - Expected_RI)
 The adjusted Rand index is thus ensured to have a value close to 0.0 for random labeling independently of the number of clusters and samples and exactly 1.0 when the clusterings are identical (up to a permutation). ARI is a symmetric measure: adjusted_rand_score(a, b) == adjusted_rand_score(b, a)
 Read more in the User Guide.  Parameters 
 
labels_trueint array, shape = [n_samples] 

Ground truth class labels to be used as a reference  
labels_predarray-like of shape (n_samples,) 

Cluster labels to evaluate    Returns 
 
ARIfloat 

Similarity score between -1.0 and 1.0. Random labelings have an ARI close to 0.0. 1.0 stands for perfect match.      See also  
adjusted_mutual_info_score


Adjusted Mutual Information.    References  
Hubert1985  
L. Hubert and P. Arabie, Comparing Partitions, Journal of Classification 1985 https://link.springer.com/article/10.1007%2FBF01908075  
Steinley2004  
D. Steinley, Properties of the Hubert-Arabie adjusted Rand index, Psychological Methods 2004  
wk  
https://en.wikipedia.org/wiki/Rand_index#Adjusted_Rand_index   Examples Perfectly matching labelings have a score of 1 even >>> from sklearn.metrics.cluster import adjusted_rand_score
>>> adjusted_rand_score([0, 0, 1, 1], [0, 0, 1, 1])
1.0
>>> adjusted_rand_score([0, 0, 1, 1], [1, 1, 0, 0])
1.0
 Labelings that assign all classes members to the same clusters are complete but may not always be pure, hence penalized: >>> adjusted_rand_score([0, 0, 1, 2], [0, 0, 1, 1])
0.57...
 ARI is symmetric, so labelings that have pure clusters with members coming from the same classes but unnecessary splits are penalized: >>> adjusted_rand_score([0, 0, 1, 1], [0, 0, 1, 2])
0.57...
 If classes members are completely split across different clusters, the assignment is totally incomplete, hence the ARI is very low: >>> adjusted_rand_score([0, 0, 0, 0], [0, 1, 2, 3])
0.0
 
 Examples using sklearn.metrics.adjusted_rand_score
 
  Demo of affinity propagation clustering algorithm  

  Demo of DBSCAN clustering algorithm  

  Adjustment for chance in clustering performance evaluation  

  A demo of K-Means clustering on the handwritten digits data  

  Clustering text documents using k-means
sklearn.metrics.auc  
sklearn.metrics.auc(x, y) [source]
 
Compute Area Under the Curve (AUC) using the trapezoidal rule. This is a general function, given points on a curve. For computing the area under the ROC-curve, see roc_auc_score. For an alternative way to summarize a precision-recall curve, see average_precision_score.  Parameters 
 
xndarray of shape (n,) 

x coordinates. These must be either monotonic increasing or monotonic decreasing.  
yndarray of shape, (n,) 

y coordinates.    Returns 
 
aucfloat 
    See also  
roc_auc_score


Compute the area under the ROC curve.  
average_precision_score


Compute average precision from prediction scores.  
precision_recall_curve


Compute precision-recall pairs for different probability thresholds.    Examples >>> import numpy as np
>>> from sklearn import metrics
>>> y = np.array([1, 1, 2, 2])
>>> pred = np.array([0.1, 0.4, 0.35, 0.8])
>>> fpr, tpr, thresholds = metrics.roc_curve(y, pred, pos_label=2)
>>> metrics.auc(fpr, tpr)
0.75
 
 Examples using sklearn.metrics.auc
 
  Species distribution modeling  

  Poisson regression and non-normal loss  

  Tweedie regression on insurance claims  

  Receiver Operating Characteristic (ROC) with cross validation  

  Receiver Operating Characteristic (ROC)  

  Precision-Recall
sklearn.metrics.average_precision_score  
sklearn.metrics.average_precision_score(y_true, y_score, *, average='macro', pos_label=1, sample_weight=None) [source]
 
Compute average precision (AP) from prediction scores. AP summarizes a precision-recall curve as the weighted mean of precisions achieved at each threshold, with the increase in recall from the previous threshold used as the weight:  \[\text{AP} = \sum_n (R_n - R_{n-1}) P_n\] where \(P_n\) and \(R_n\) are the precision and recall at the nth threshold [1]. This implementation is not interpolated and is different from computing the area under the precision-recall curve with the trapezoidal rule, which uses linear interpolation and can be too optimistic. Note: this implementation is restricted to the binary classification task or multilabel classification task. Read more in the User Guide.  Parameters 
 
y_truendarray of shape (n_samples,) or (n_samples, n_classes) 

True binary labels or binary label indicators.  
y_scorendarray of shape (n_samples,) or (n_samples, n_classes) 

Target scores, can either be probability estimates of the positive class, confidence values, or non-thresholded measure of decisions (as returned by decision_function on some classifiers).  
average{‘micro’, ‘samples’, ‘weighted’, ‘macro’} or None, default=’macro’ 

If None, the scores for each class are returned. Otherwise, this determines the type of averaging performed on the data:  
'micro': 

Calculate metrics globally by considering each element of the label indicator matrix as a label.  
'macro': 

Calculate metrics for each label, and find their unweighted mean. This does not take label imbalance into account.  
'weighted': 

Calculate metrics for each label, and find their average, weighted by support (the number of true instances for each label).  
'samples': 

Calculate metrics for each instance, and find their average.   Will be ignored when y_true is binary.  
pos_labelint or str, default=1 

The label of the positive class. Only applied to binary y_true. For multilabel-indicator y_true, pos_label is fixed to 1.  
sample_weightarray-like of shape (n_samples,), default=None 

Sample weights.    Returns 
 
average_precisionfloat 
    See also  
roc_auc_score


Compute the area under the ROC curve.  
precision_recall_curve


Compute precision-recall pairs for different probability thresholds.    Notes  Changed in version 0.19: Instead of linearly interpolating between operating points, precisions are weighted by the change in recall since the last operating point.  References  
1  
Wikipedia entry for the Average precision   Examples >>> import numpy as np
>>> from sklearn.metrics import average_precision_score
>>> y_true = np.array([0, 0, 1, 1])
>>> y_scores = np.array([0.1, 0.4, 0.35, 0.8])
>>> average_precision_score(y_true, y_scores)
0.83...
 
 Examples using sklearn.metrics.average_precision_score
 
  Precision-Recall