neulab/docprompting-conala huggingface dataset:
sklearn.metrics.zero_one_loss  
sklearn.metrics.zero_one_loss(y_true, y_pred, *, normalize=True, sample_weight=None) [source]
 
Zero-one classification loss. If normalize is True, return the fraction of misclassifications (float), else it returns the number of misclassifications (int). The best performance is 0. 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 misclassifications. Otherwise, return the fraction of misclassifications.  
sample_weightarray-like of shape (n_samples,), default=None 

Sample weights.    Returns 
 
lossfloat or int, 

If normalize == True, return the fraction of misclassifications (float), else it returns the number of misclassifications (int).      See also  
accuracy_score, hamming_loss, jaccard_score

  Notes In multilabel classification, the zero_one_loss function corresponds to the subset zero-one loss: for each sample, the entire set of labels must be correctly predicted, otherwise the loss for that sample is equal to one. Examples >>> from sklearn.metrics import zero_one_loss
>>> y_pred = [1, 2, 3, 4]
>>> y_true = [2, 2, 3, 4]
>>> zero_one_loss(y_true, y_pred)
0.25
>>> zero_one_loss(y_true, y_pred, normalize=False)
1
 In the multilabel case with binary label indicators: >>> import numpy as np
>>> zero_one_loss(np.array([[0, 1], [1, 1]]), np.ones((2, 2)))
0.5
 
 Examples using sklearn.metrics.zero_one_loss
 
  Discrete versus Real AdaBoost
sklearn.model_selection.check_cv  
sklearn.model_selection.check_cv(cv=5, y=None, *, classifier=False) [source]
 
Input checker utility for building a cross-validator  Parameters 
 
cvint, cross-validation generator or an iterable, default=None 

Determines the cross-validation splitting strategy. Possible inputs for cv are: - None, to use the default 5-fold cross validation, - integer, to specify the number of folds. - CV splitter, - An iterable yielding (train, test) splits as arrays of indices. For integer/None inputs, if classifier is True and y is either binary or multiclass, StratifiedKFold is used. In all other cases, KFold is used. Refer User Guide for the various cross-validation strategies that can be used here.  Changed in version 0.22: cv default value changed from 3-fold to 5-fold.   
yarray-like, default=None 

The target variable for supervised learning problems.  
classifierbool, default=False 

Whether the task is a classification task, in which case stratified KFold will be used.    Returns 
 
checked_cva cross-validator instance. 

The return value is a cross-validator which generates the train/test splits via the split method.
sklearn.neighbors.kneighbors_graph  
sklearn.neighbors.kneighbors_graph(X, n_neighbors, *, mode='connectivity', metric='minkowski', p=2, metric_params=None, include_self=False, n_jobs=None) [source]
 
Computes the (weighted) graph of k-Neighbors for points in X Read more in the User Guide.  Parameters 
 
Xarray-like of shape (n_samples, n_features) or BallTree 

Sample data, in the form of a numpy array or a precomputed BallTree.  
n_neighborsint 

Number of neighbors for each sample.  
mode{‘connectivity’, ‘distance’}, default=’connectivity’ 

Type of returned matrix: ‘connectivity’ will return the connectivity matrix with ones and zeros, and ‘distance’ will return the distances between neighbors according to the given metric.  
metricstr, default=’minkowski’ 

The distance metric used to calculate the k-Neighbors for each sample point. The DistanceMetric class gives a list of available metrics. The default distance is ‘euclidean’ (‘minkowski’ metric with the p param equal to 2.)  
pint, default=2 

Power parameter for the Minkowski metric. When p = 1, this is equivalent to using manhattan_distance (l1), and euclidean_distance (l2) for p = 2. For arbitrary p, minkowski_distance (l_p) is used.  
metric_paramsdict, default=None 

additional keyword arguments for the metric function.  
include_selfbool or ‘auto’, default=False 

Whether or not to mark each sample as the first nearest neighbor to itself. If ‘auto’, then True is used for mode=’connectivity’ and False for mode=’distance’.  
n_jobsint, default=None 

The number of parallel jobs to run for neighbors search. None means 1 unless in a joblib.parallel_backend context. -1 means using all processors. See Glossary for more details.    Returns 
 
Asparse matrix of shape (n_samples, n_samples) 

Graph where A[i, j] is assigned the weight of edge that connects i to j. The matrix is of CSR format.      See also  
radius_neighbors_graph

  Examples >>> X = [[0], [3], [1]]
>>> from sklearn.neighbors import kneighbors_graph
>>> A = kneighbors_graph(X, 2, mode='connectivity', include_self=True)
>>> A.toarray()
array([[1., 0., 1.],
       [0., 1., 1.],
       [1., 0., 1.]])
 
 Examples using sklearn.neighbors.kneighbors_graph
 
  Agglomerative clustering with and without structure  

  Hierarchical clustering: structured vs unstructured ward  

  Comparing different clustering algorithms on toy datasets
sklearn.neighbors.radius_neighbors_graph  
sklearn.neighbors.radius_neighbors_graph(X, radius, *, mode='connectivity', metric='minkowski', p=2, metric_params=None, include_self=False, n_jobs=None) [source]
 
Computes the (weighted) graph of Neighbors for points in X Neighborhoods are restricted the points at a distance lower than radius. Read more in the User Guide.  Parameters 
 
Xarray-like of shape (n_samples, n_features) or BallTree 

Sample data, in the form of a numpy array or a precomputed BallTree.  
radiusfloat 

Radius of neighborhoods.  
mode{‘connectivity’, ‘distance’}, default=’connectivity’ 

Type of returned matrix: ‘connectivity’ will return the connectivity matrix with ones and zeros, and ‘distance’ will return the distances between neighbors according to the given metric.  
metricstr, default=’minkowski’ 

The distance metric used to calculate the neighbors within a given radius for each sample point. The DistanceMetric class gives a list of available metrics. The default distance is ‘euclidean’ (‘minkowski’ metric with the param equal to 2.)  
pint, default=2 

Power parameter for the Minkowski metric. When p = 1, this is equivalent to using manhattan_distance (l1), and euclidean_distance (l2) for p = 2. For arbitrary p, minkowski_distance (l_p) is used.  
metric_paramsdict, default=None 

additional keyword arguments for the metric function.  
include_selfbool or ‘auto’, default=False 

Whether or not to mark each sample as the first nearest neighbor to itself. If ‘auto’, then True is used for mode=’connectivity’ and False for mode=’distance’.  
n_jobsint, default=None 

The number of parallel jobs to run for neighbors search. None means 1 unless in a joblib.parallel_backend context. -1 means using all processors. See Glossary for more details.    Returns 
 
Asparse matrix of shape (n_samples, n_samples) 

Graph where A[i, j] is assigned the weight of edge that connects i to j. The matrix is of CSR format.      See also  
kneighbors_graph

  Examples >>> X = [[0], [3], [1]]
>>> from sklearn.neighbors import radius_neighbors_graph
>>> A = radius_neighbors_graph(X, 1.5, mode='connectivity',
...                            include_self=True)
>>> A.toarray()
array([[1., 0., 1.],
       [0., 1., 0.],
       [1., 0., 1.]])
sklearn.pipeline.make_pipeline  
sklearn.pipeline.make_pipeline(*steps, memory=None, verbose=False) [source]
 
Construct a Pipeline from the given estimators. This is a shorthand for the Pipeline constructor; it does not require, and does not permit, naming the estimators. Instead, their names will be set to the lowercase of their types automatically.  Parameters 
 
*stepslist of estimators. 

memorystr or object with the joblib.Memory interface, default=None 

Used to cache the fitted transformers of the pipeline. By default, no caching is performed. If a string is given, it is the path to the caching directory. Enabling caching triggers a clone of the transformers before fitting. Therefore, the transformer instance given to the pipeline cannot be inspected directly. Use the attribute named_steps or steps to inspect estimators within the pipeline. Caching the transformers is advantageous when fitting is time consuming.  
verbosebool, default=False 

If True, the time elapsed while fitting each step will be printed as it is completed.    Returns 
 
pPipeline 
    See also  
Pipeline


Class for creating a pipeline of transforms with a final estimator.    Examples >>> from sklearn.naive_bayes import GaussianNB
>>> from sklearn.preprocessing import StandardScaler
>>> make_pipeline(StandardScaler(), GaussianNB(priors=None))
Pipeline(steps=[('standardscaler', StandardScaler()),
                ('gaussiannb', GaussianNB())])
 
 Examples using sklearn.pipeline.make_pipeline
 
  Release Highlights for scikit-learn 0.23  

  Release Highlights for scikit-learn 0.24  

  Release Highlights for scikit-learn 0.22  

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

  Principal Component Regression vs Partial Least Squares Regression  

  Feature transformations with ensembles of trees  

  Categorical Feature Support in Gradient Boosting  

  Combine predictors using stacking  

  Pipeline Anova SVM  

  Univariate Feature Selection  

  Polynomial interpolation  

  Robust linear estimator fitting  

  Poisson regression and non-normal loss  

  Tweedie regression on insurance claims  

  Partial Dependence and Individual Conditional Expectation Plots  

  Common pitfalls in interpretation of coefficients of linear models  

  Scalable learning with polynomial kernel aproximation  

  Visualizations with Display Objects  

  Advanced Plotting With Partial Dependence  

  Imputing missing values with variants of IterativeImputer  

  Imputing missing values before building an estimator  

  Detection error tradeoff (DET) curve  

  Dimensionality Reduction with Neighborhood Components Analysis  

  Approximate nearest neighbors in TSNE  

  Varying regularization in Multi-layer Perceptron  

  Importance of Feature Scaling  

  Feature discretization  

  Clustering text documents using k-means
sklearn.pipeline.make_union  
sklearn.pipeline.make_union(*transformers, n_jobs=None, verbose=False) [source]
 
Construct a FeatureUnion from the given transformers. This is a shorthand for the FeatureUnion constructor; it does not require, and does not permit, naming the transformers. Instead, they will be given names automatically based on their types. It also does not allow weighting.  Parameters 
 
*transformerslist of estimators 

n_jobsint, default=None 

Number of jobs to run in parallel. None means 1 unless in a joblib.parallel_backend context. -1 means using all processors. See Glossary for more details.  Changed in version v0.20: n_jobs default changed from 1 to None   
verbosebool, default=False 

If True, the time elapsed while fitting each transformer will be printed as it is completed.    Returns 
 
fFeatureUnion 
    See also  
FeatureUnion


Class for concatenating the results of multiple transformer objects.    Examples >>> from sklearn.decomposition import PCA, TruncatedSVD
>>> from sklearn.pipeline import make_union
>>> make_union(PCA(), TruncatedSVD())
 FeatureUnion(transformer_list=[('pca', PCA()),
                               ('truncatedsvd', TruncatedSVD())])
sklearn.preprocessing.add_dummy_feature  
sklearn.preprocessing.add_dummy_feature(X, value=1.0) [source]
 
Augment dataset with an additional dummy feature. This is useful for fitting an intercept term with implementations which cannot otherwise fit it directly.  Parameters 
 
X{array-like, sparse matrix} of shape (n_samples, n_features) 

Data.  
valuefloat 

Value to use for the dummy feature.    Returns 
 
X{ndarray, sparse matrix} of shape (n_samples, n_features + 1) 

Same data with dummy feature added as first column.     Examples >>> from sklearn.preprocessing import add_dummy_feature
>>> add_dummy_feature([[0, 1], [1, 0]])
array([[1., 0., 1.],
       [1., 1., 0.]])
sklearn.preprocessing.binarize  
sklearn.preprocessing.binarize(X, *, threshold=0.0, copy=True) [source]
 
Boolean thresholding of array-like or scipy.sparse matrix. Read more in the User Guide.  Parameters 
 
X{array-like, sparse matrix} of shape (n_samples, n_features) 

The data to binarize, element by element. scipy.sparse matrices should be in CSR or CSC format to avoid an un-necessary copy.  
thresholdfloat, default=0.0 

Feature values below or equal to this are replaced by 0, above it by 1. Threshold may not be less than 0 for operations on sparse matrices.  
copybool, default=True 

set to False to perform inplace binarization and avoid a copy (if the input is already a numpy array or a scipy.sparse CSR / CSC matrix and if axis is 1).    Returns 
 
X_tr{ndarray, sparse matrix} of shape (n_samples, n_features) 

The transformed data.      See also  
Binarizer


Performs binarization using the Transformer API (e.g. as part of a preprocessing Pipeline).
sklearn.preprocessing.label_binarize  
sklearn.preprocessing.label_binarize(y, *, classes, neg_label=0, pos_label=1, sparse_output=False) [source]
 
Binarize labels in a one-vs-all fashion. Several regression and binary classification algorithms are available in scikit-learn. A simple way to extend these algorithms to the multi-class classification case is to use the so-called one-vs-all scheme. This function makes it possible to compute this transformation for a fixed set of class labels known ahead of time.  Parameters 
 
yarray-like 

Sequence of integer labels or multilabel data to encode.  
classesarray-like of shape (n_classes,) 

Uniquely holds the label for each class.  
neg_labelint, default=0 

Value with which negative labels must be encoded.  
pos_labelint, default=1 

Value with which positive labels must be encoded.  
sparse_outputbool, default=False, 

Set to true if output binary array is desired in CSR sparse format.    Returns 
 
Y{ndarray, sparse matrix} of shape (n_samples, n_classes) 

Shape will be (n_samples, 1) for binary problems. Sparse matrix will be of CSR format.      See also  
LabelBinarizer


Class used to wrap the functionality of label_binarize and allow for fitting to classes independently of the transform operation.    Examples >>> from sklearn.preprocessing import label_binarize
>>> label_binarize([1, 6], classes=[1, 2, 4, 6])
array([[1, 0, 0, 0],
       [0, 0, 0, 1]])
 The class ordering is preserved: >>> label_binarize([1, 6], classes=[1, 6, 4, 2])
array([[1, 0, 0, 0],
       [0, 1, 0, 0]])
 Binary targets transform to a column vector >>> label_binarize(['yes', 'no', 'no', 'yes'], classes=['no', 'yes'])
array([[1],
       [0],
       [0],
       [1]])
 
 Examples using sklearn.preprocessing.label_binarize
 
  Receiver Operating Characteristic (ROC)  

  Precision-Recall
sklearn.preprocessing.maxabs_scale  
sklearn.preprocessing.maxabs_scale(X, *, axis=0, copy=True) [source]
 
Scale each feature to the [-1, 1] range without breaking the sparsity. This estimator scales each feature individually such that the maximal absolute value of each feature in the training set will be 1.0. This scaler can also be applied to sparse CSR or CSC matrices.  Parameters 
 
X{array-like, sparse matrix} of shape (n_samples, n_features) 

The data.  
axisint, default=0 

axis used to scale along. If 0, independently scale each feature, otherwise (if 1) scale each sample.  
copybool, default=True 

Set to False to perform inplace scaling and avoid a copy (if the input is already a numpy array).    Returns 
 
X_tr{ndarray, sparse matrix} of shape (n_samples, n_features) 

The transformed data.    Warning Risk of data leak Do not use maxabs_scale unless you know what you are doing. A common mistake is to apply it to the entire data before splitting into training and test sets. This will bias the model evaluation because information would have leaked from the test set to the training set. In general, we recommend using MaxAbsScaler within a Pipeline in order to prevent most risks of data leaking: pipe = make_pipeline(MaxAbsScaler(), LogisticRegression()).     See also  
MaxAbsScaler


Performs scaling to the [-1, 1] range using the Transformer API (e.g. as part of a preprocessing Pipeline).    Notes NaNs are treated as missing values: disregarded to compute the statistics, and maintained during the data transformation. For a comparison of the different scalers, transformers, and normalizers, see examples/preprocessing/plot_all_scaling.py.
sklearn.preprocessing.minmax_scale  
sklearn.preprocessing.minmax_scale(X, feature_range=0, 1, *, axis=0, copy=True) [source]
 
Transform features by scaling each feature to a given range. This estimator scales and translates each feature individually such that it is in the given range on the training set, i.e. between zero and one. The transformation is given by (when axis=0): X_std = (X - X.min(axis=0)) / (X.max(axis=0) - X.min(axis=0))
X_scaled = X_std * (max - min) + min
 where min, max = feature_range. The transformation is calculated as (when axis=0): X_scaled = scale * X + min - X.min(axis=0) * scale
where scale = (max - min) / (X.max(axis=0) - X.min(axis=0))
 This transformation is often used as an alternative to zero mean, unit variance scaling. Read more in the User Guide.  New in version 0.17: minmax_scale function interface to MinMaxScaler.   Parameters 
 
Xarray-like of shape (n_samples, n_features) 

The data.  
feature_rangetuple (min, max), default=(0, 1) 

Desired range of transformed data.  
axisint, default=0 

Axis used to scale along. If 0, independently scale each feature, otherwise (if 1) scale each sample.  
copybool, default=True 

Set to False to perform inplace scaling and avoid a copy (if the input is already a numpy array).    Returns 
 
X_trndarray of shape (n_samples, n_features) 

The transformed data.    Warning Risk of data leak Do not use minmax_scale unless you know what you are doing. A common mistake is to apply it to the entire data before splitting into training and test sets. This will bias the model evaluation because information would have leaked from the test set to the training set. In general, we recommend using MinMaxScaler within a Pipeline in order to prevent most risks of data leaking: pipe = make_pipeline(MinMaxScaler(), LogisticRegression()).     See also  
MinMaxScaler


Performs scaling to a given range using the Transformer API (e.g. as part of a preprocessing Pipeline).    Notes For a comparison of the different scalers, transformers, and normalizers, see examples/preprocessing/plot_all_scaling.py. 
 Examples using sklearn.preprocessing.minmax_scale
 
  Compare the effect of different scalers on data with outliers
sklearn.preprocessing.normalize  
sklearn.preprocessing.normalize(X, norm='l2', *, axis=1, copy=True, return_norm=False) [source]
 
Scale input vectors individually to unit norm (vector length). Read more in the User Guide.  Parameters 
 
X{array-like, sparse matrix} of shape (n_samples, n_features) 

The data to normalize, element by element. scipy.sparse matrices should be in CSR format to avoid an un-necessary copy.  
norm{‘l1’, ‘l2’, ‘max’}, default=’l2’ 

The norm to use to normalize each non zero sample (or each non-zero feature if axis is 0).  
axis{0, 1}, default=1 

axis used to normalize the data along. If 1, independently normalize each sample, otherwise (if 0) normalize each feature.  
copybool, default=True 

set to False to perform inplace row normalization and avoid a copy (if the input is already a numpy array or a scipy.sparse CSR matrix and if axis is 1).  
return_normbool, default=False 

whether to return the computed norms    Returns 
 
X{ndarray, sparse matrix} of shape (n_samples, n_features) 

Normalized input X.  
normsndarray of shape (n_samples, ) if axis=1 else (n_features, ) 

An array of norms along given axis for X. When X is sparse, a NotImplementedError will be raised for norm ‘l1’ or ‘l2’.      See also  
Normalizer


Performs normalization using the Transformer API (e.g. as part of a preprocessing Pipeline).    Notes For a comparison of the different scalers, transformers, and normalizers, see examples/preprocessing/plot_all_scaling.py.
sklearn.preprocessing.power_transform  
sklearn.preprocessing.power_transform(X, method='yeo-johnson', *, standardize=True, copy=True) [source]
 
Power transforms are a family of parametric, monotonic transformations that are applied to make data more Gaussian-like. This is useful for modeling issues related to heteroscedasticity (non-constant variance), or other situations where normality is desired. Currently, power_transform supports the Box-Cox transform and the Yeo-Johnson transform. The optimal parameter for stabilizing variance and minimizing skewness is estimated through maximum likelihood. Box-Cox requires input data to be strictly positive, while Yeo-Johnson supports both positive or negative data. By default, zero-mean, unit-variance normalization is applied to the transformed data. Read more in the User Guide.  Parameters 
 
Xarray-like of shape (n_samples, n_features) 

The data to be transformed using a power transformation.  
method{‘yeo-johnson’, ‘box-cox’}, default=’yeo-johnson’ 

The power transform method. Available methods are:  ‘yeo-johnson’ [1], works with positive and negative values ‘box-cox’ [2], only works with strictly positive values   Changed in version 0.23: The default value of the method parameter changed from ‘box-cox’ to ‘yeo-johnson’ in 0.23.   
standardizebool, default=True 

Set to True to apply zero-mean, unit-variance normalization to the transformed output.  
copybool, default=True 

Set to False to perform inplace computation during transformation.    Returns 
 
X_transndarray of shape (n_samples, n_features) 

The transformed data.      See also  
PowerTransformer


Equivalent transformation with the Transformer API (e.g. as part of a preprocessing Pipeline).  
quantile_transform


Maps data to a standard normal distribution with the parameter output_distribution='normal'.    Notes NaNs are treated as missing values: disregarded in fit, and maintained in transform. For a comparison of the different scalers, transformers, and normalizers, see examples/preprocessing/plot_all_scaling.py. References  
1  
I.K. Yeo and R.A. Johnson, “A new family of power transformations to improve normality or symmetry.” Biometrika, 87(4), pp.954-959, (2000).  
2  
G.E.P. Box and D.R. Cox, “An Analysis of Transformations”, Journal of the Royal Statistical Society B, 26, 211-252 (1964).   Examples >>> import numpy as np
>>> from sklearn.preprocessing import power_transform
>>> data = [[1, 2], [3, 2], [4, 5]]
>>> print(power_transform(data, method='box-cox'))
[[-1.332... -0.707...]
 [ 0.256... -0.707...]
 [ 1.076...  1.414...]]
  Warning Risk of data leak. Do not use power_transform unless you know what you are doing. A common mistake is to apply it to the entire data before splitting into training and test sets. This will bias the model evaluation because information would have leaked from the test set to the training set. In general, we recommend using PowerTransformer within a Pipeline in order to prevent most risks of data leaking, e.g.: pipe = make_pipeline(PowerTransformer(),
LogisticRegression()).