neulab/docprompting-conala huggingface dataset:
sklearn.utils.resample  
sklearn.utils.resample(*arrays, replace=True, n_samples=None, random_state=None, stratify=None) [source]
 
Resample arrays or sparse matrices in a consistent way. The default strategy implements one step of the bootstrapping procedure.  Parameters 
 
*arrayssequence of array-like of shape (n_samples,) or (n_samples, n_outputs) 

Indexable data-structures can be arrays, lists, dataframes or scipy sparse matrices with consistent first dimension.  
replacebool, default=True 

Implements resampling with replacement. If False, this will implement (sliced) random permutations.  
n_samplesint, default=None 

Number of samples to generate. If left to None this is automatically set to the first dimension of the arrays. If replace is False it should not be larger than the length of arrays.  
random_stateint, RandomState instance or None, default=None 

Determines random number generation for shuffling the data. Pass an int for reproducible results across multiple function calls. See Glossary.  
stratifyarray-like of shape (n_samples,) or (n_samples, n_outputs), default=None 

If not None, data is split in a stratified fashion, using this as the class labels.    Returns 
 
resampled_arrayssequence of array-like of shape (n_samples,) or (n_samples, n_outputs) 

Sequence of resampled copies of the collections. The original arrays are not impacted.      See also  
shuffle

  Examples It is possible to mix sparse and dense arrays in the same run: >>> X = np.array([[1., 0.], [2., 1.], [0., 0.]])
>>> y = np.array([0, 1, 2])

>>> from scipy.sparse import coo_matrix
>>> X_sparse = coo_matrix(X)

>>> from sklearn.utils import resample
>>> X, X_sparse, y = resample(X, X_sparse, y, random_state=0)
>>> X
array([[1., 0.],
       [2., 1.],
       [1., 0.]])

>>> X_sparse
<3x2 sparse matrix of type '<... 'numpy.float64'>'
    with 4 stored elements in Compressed Sparse Row format>

>>> X_sparse.toarray()
array([[1., 0.],
       [2., 1.],
       [1., 0.]])

>>> y
array([0, 1, 0])

>>> resample(y, n_samples=2, random_state=0)
array([0, 1])
 Example using stratification: >>> y = [0, 0, 1, 1, 1, 1, 1, 1, 1]
>>> resample(y, n_samples=5, replace=False, stratify=y,
...          random_state=0)
[1, 1, 1, 0, 1]
sklearn.utils.safe_mask  
sklearn.utils.safe_mask(X, mask) [source]
 
Return a mask which is safe to use on X.  Parameters 
 
X{array-like, sparse matrix} 

Data on which to apply mask.  
maskndarray 

Mask to be used on X.    Returns 
 mask
sklearn.utils.safe_sqr  
sklearn.utils.safe_sqr(X, *, copy=True) [source]
 
Element wise squaring of array-likes and sparse matrices.  Parameters 
 
X{array-like, ndarray, sparse matrix} 

copybool, default=True 

Whether to create a copy of X and operate on it or to perform inplace computation (default behaviour).    Returns 
 
X ** 2element wise square
sklearn.utils.shuffle  
sklearn.utils.shuffle(*arrays, random_state=None, n_samples=None) [source]
 
Shuffle arrays or sparse matrices in a consistent way. This is a convenience alias to resample(*arrays, replace=False) to do random permutations of the collections.  Parameters 
 
*arrayssequence of indexable data-structures 

Indexable data-structures can be arrays, lists, dataframes or scipy sparse matrices with consistent first dimension.  
random_stateint, RandomState instance or None, default=None 

Determines random number generation for shuffling the data. Pass an int for reproducible results across multiple function calls. See Glossary.  
n_samplesint, default=None 

Number of samples to generate. If left to None this is automatically set to the first dimension of the arrays. It should not be larger than the length of arrays.    Returns 
 
shuffled_arrayssequence of indexable data-structures 

Sequence of shuffled copies of the collections. The original arrays are not impacted.      See also  
resample

  Examples It is possible to mix sparse and dense arrays in the same run: >>> X = np.array([[1., 0.], [2., 1.], [0., 0.]])
>>> y = np.array([0, 1, 2])

>>> from scipy.sparse import coo_matrix
>>> X_sparse = coo_matrix(X)

>>> from sklearn.utils import shuffle
>>> X, X_sparse, y = shuffle(X, X_sparse, y, random_state=0)
>>> X
array([[0., 0.],
       [2., 1.],
       [1., 0.]])

>>> X_sparse
<3x2 sparse matrix of type '<... 'numpy.float64'>'
    with 3 stored elements in Compressed Sparse Row format>

>>> X_sparse.toarray()
array([[0., 0.],
       [2., 1.],
       [1., 0.]])

>>> y
array([2, 1, 0])

>>> shuffle(y, n_samples=2, random_state=0)
array([0, 1])
 
 Examples using sklearn.utils.shuffle
 
  Color Quantization using K-Means  

  Empirical evaluation of the impact of k-means initialization  

  Combine predictors using stacking  

  Model Complexity Influence  

  Prediction Latency  

  Early stopping of Stochastic Gradient Descent  

  Approximate nearest neighbors in TSNE  

  Effect of varying threshold for self-training
sklearn.utils.sparsefuncs.incr_mean_variance_axis  
sklearn.utils.sparsefuncs.incr_mean_variance_axis(X, *, axis, last_mean, last_var, last_n, weights=None) [source]
 
Compute incremental mean and variance along an axis on a CSR or CSC matrix. last_mean, last_var are the statistics computed at the last step by this function. Both must be initialized to 0-arrays of the proper size, i.e. the number of features in X. last_n is the number of samples encountered until now.  Parameters 
 
XCSR or CSC sparse matrix of shape (n_samples, n_features) 

Input data.  
axis{0, 1} 

Axis along which the axis should be computed.  
last_meanndarray of shape (n_features,) or (n_samples,), dtype=floating 

Array of means to update with the new data X. Should be of shape (n_features,) if axis=0 or (n_samples,) if axis=1.  
last_varndarray of shape (n_features,) or (n_samples,), dtype=floating 

Array of variances to update with the new data X. Should be of shape (n_features,) if axis=0 or (n_samples,) if axis=1.  
last_nfloat or ndarray of shape (n_features,) or (n_samples,), dtype=floating 

Sum of the weights seen so far, excluding the current weights If not float, it should be of shape (n_samples,) if axis=0 or (n_features,) if axis=1. If float it corresponds to having same weights for all samples (or features).  
weightsndarray of shape (n_samples,) or (n_features,), default=None 

If axis is set to 0 shape is (n_samples,) or if axis is set to 1 shape is (n_features,). If it is set to None, then samples are equally weighted.  New in version 0.24.     Returns 
 
meansndarray of shape (n_features,) or (n_samples,), dtype=floating 

Updated feature-wise means if axis = 0 or sample-wise means if axis = 1.  
variancesndarray of shape (n_features,) or (n_samples,), dtype=floating 

Updated feature-wise variances if axis = 0 or sample-wise variances if axis = 1.  
nndarray of shape (n_features,) or (n_samples,), dtype=integral 

Updated number of seen samples per feature if axis=0 or number of seen features per sample if axis=1. If weights is not None, n is a sum of the weights of the seen samples or features instead of the actual number of seen samples or features.     Notes NaNs are ignored in the algorithm.
sklearn.utils.sparsefuncs.inplace_column_scale  
sklearn.utils.sparsefuncs.inplace_column_scale(X, scale) [source]
 
Inplace column scaling of a CSC/CSR matrix. Scale each feature of the data matrix by multiplying with specific scale provided by the caller assuming a (n_samples, n_features) shape.  Parameters 
 
Xsparse matrix of shape (n_samples, n_features) 

Matrix to normalize using the variance of the features. It should be of CSC or CSR format.  
scalendarray of shape (n_features,), dtype={np.float32, np.float64} 

Array of precomputed feature-wise values to use for scaling.
sklearn.utils.sparsefuncs.inplace_csr_column_scale  
sklearn.utils.sparsefuncs.inplace_csr_column_scale(X, scale) [source]
 
Inplace column scaling of a CSR matrix. Scale each feature of the data matrix by multiplying with specific scale provided by the caller assuming a (n_samples, n_features) shape.  Parameters 
 
Xsparse matrix of shape (n_samples, n_features) 

Matrix to normalize using the variance of the features. It should be of CSR format.  
scalendarray of shape (n_features,), dtype={np.float32, np.float64} 

Array of precomputed feature-wise values to use for scaling.
sklearn.utils.sparsefuncs.inplace_row_scale  
sklearn.utils.sparsefuncs.inplace_row_scale(X, scale) [source]
 
Inplace row scaling of a CSR or CSC matrix. Scale each row of the data matrix by multiplying with specific scale provided by the caller assuming a (n_samples, n_features) shape.  Parameters 
 
Xsparse matrix of shape (n_samples, n_features) 

Matrix to be scaled. It should be of CSR or CSC format.  
scalendarray of shape (n_features,), dtype={np.float32, np.float64} 

Array of precomputed sample-wise values to use for scaling.
sklearn.utils.sparsefuncs.inplace_swap_column  
sklearn.utils.sparsefuncs.inplace_swap_column(X, m, n) [source]
 
Swaps two columns of a CSC/CSR matrix in-place.  Parameters 
 
Xsparse matrix of shape (n_samples, n_features) 

Matrix whose two columns are to be swapped. It should be of CSR or CSC format.  
mint 

Index of the column of X to be swapped.  
nint 

Index of the column of X to be swapped.
sklearn.utils.sparsefuncs.inplace_swap_row  
sklearn.utils.sparsefuncs.inplace_swap_row(X, m, n) [source]
 
Swaps two rows of a CSC/CSR matrix in-place.  Parameters 
 
Xsparse matrix of shape (n_samples, n_features) 

Matrix whose two rows are to be swapped. It should be of CSR or CSC format.  
mint 

Index of the row of X to be swapped.  
nint 

Index of the row of X to be swapped.
sklearn.utils.sparsefuncs.mean_variance_axis  
sklearn.utils.sparsefuncs.mean_variance_axis(X, axis, weights=None, return_sum_weights=False) [source]
 
Compute mean and variance along an axis on a CSR or CSC matrix.  Parameters 
 
Xsparse matrix of shape (n_samples, n_features) 

Input data. It can be of CSR or CSC format.  
axis{0, 1} 

Axis along which the axis should be computed.  
weightsndarray of shape (n_samples,) or (n_features,), default=None 

if axis is set to 0 shape is (n_samples,) or if axis is set to 1 shape is (n_features,). If it is set to None, then samples are equally weighted.  New in version 0.24.   
return_sum_weightsbool, default=False 

If True, returns the sum of weights seen for each feature if axis=0 or each sample if axis=1.  New in version 0.24.     Returns 
 
meansndarray of shape (n_features,), dtype=floating 

Feature-wise means.  
variancesndarray of shape (n_features,), dtype=floating 

Feature-wise variances.  
sum_weightsndarray of shape (n_features,), dtype=floating 

Returned if return_sum_weights is True.
sklearn.utils.sparsefuncs_fast.inplace_csr_row_normalize_l1  
sklearn.utils.sparsefuncs_fast.inplace_csr_row_normalize_l1()  
Inplace row normalize using the l1 norm
sklearn.utils.sparsefuncs_fast.inplace_csr_row_normalize_l2  
sklearn.utils.sparsefuncs_fast.inplace_csr_row_normalize_l2()  
Inplace row normalize using the l2 norm
sklearn.utils.validation.check_is_fitted  
sklearn.utils.validation.check_is_fitted(estimator, attributes=None, *, msg=None, all_or_any=<built-in function all>) [source]
 
Perform is_fitted validation for estimator. Checks if the estimator is fitted by verifying the presence of fitted attributes (ending with a trailing underscore) and otherwise raises a NotFittedError with the given message. This utility is meant to be used internally by estimators themselves, typically in their own predict / transform methods.  Parameters 
 
estimatorestimator instance 

estimator instance for which the check is performed.  
attributesstr, list or tuple of str, default=None 

Attribute name(s) given as string or a list/tuple of strings Eg.: ["coef_", "estimator_", ...], "coef_" If None, estimator is considered fitted if there exist an attribute that ends with a underscore and does not start with double underscore.  
msgstr, default=None 

The default error message is, “This %(name)s instance is not fitted yet. Call ‘fit’ with appropriate arguments before using this estimator.” For custom messages if “%(name)s” is present in the message string, it is substituted for the estimator name. Eg. : “Estimator, %(name)s, must be fitted before sparsifying”.  
all_or_anycallable, {all, any}, default=all 

Specify whether all or any of the given attributes must exist.    Returns 
 None
  Raises 
 NotFittedError

If the attributes are not found.
sklearn.utils.validation.check_memory  
sklearn.utils.validation.check_memory(memory) [source]
 
Check that memory is joblib.Memory-like. joblib.Memory-like means that memory can be converted into a joblib.Memory instance (typically a str denoting the location) or has the same interface (has a cache method).  Parameters 
 
memoryNone, str or object with the joblib.Memory interface 
  Returns 
 
memoryobject with the joblib.Memory interface 
  Raises 
 ValueError

If memory is not joblib.Memory-like.
sklearn.utils.validation.check_symmetric  
sklearn.utils.validation.check_symmetric(array, *, tol=1e-10, raise_warning=True, raise_exception=False) [source]
 
Make sure that array is 2D, square and symmetric. If the array is not symmetric, then a symmetrized version is returned. Optionally, a warning or exception is raised if the matrix is not symmetric.  Parameters 
 
array{ndarray, sparse matrix} 

Input object to check / convert. Must be two-dimensional and square, otherwise a ValueError will be raised.  
tolfloat, default=1e-10 

Absolute tolerance for equivalence of arrays. Default = 1E-10.  
raise_warningbool, default=True 

If True then raise a warning if conversion is required.  
raise_exceptionbool, default=False 

If True then raise an exception if array is not symmetric.    Returns 
 
array_sym{ndarray, sparse matrix} 

Symmetrized version of the input array, i.e. the average of array and array.transpose(). If sparse, then duplicate entries are first summed and zeros are eliminated.
sklearn.utils.validation.column_or_1d  
sklearn.utils.validation.column_or_1d(y, *, warn=False) [source]
 
Ravel column or 1d numpy array, else raises an error.  Parameters 
 
yarray-like 

warnbool, default=False 

To control display of warnings.    Returns 
 
yndarray
sklearn.utils.validation.has_fit_parameter  
sklearn.utils.validation.has_fit_parameter(estimator, parameter) [source]
 
Checks whether the estimator’s fit method supports the given parameter.  Parameters 
 
estimatorobject 

An estimator to inspect.  
parameterstr 

The searched parameter.    Returns 
 is_parameter: bool

Whether the parameter was found to be a named parameter of the estimator’s fit method.     Examples >>> from sklearn.svm import SVC
>>> has_fit_parameter(SVC(), "sample_weight")
True
sklearn.utils._safe_indexing  
sklearn.utils._safe_indexing(X, indices, *, axis=0) [source]
 
Return rows, items or columns of X using indices.  Warning This utility is documented, but private. This means that backward compatibility might be broken without any deprecation cycle.   Parameters 
 
Xarray-like, sparse-matrix, list, pandas.DataFrame, pandas.Series 

Data from which to sample rows, items or columns. list are only supported when axis=0.  
indicesbool, int, str, slice, array-like 

 If axis=0, boolean and integer array-like, integer slice, and scalar integer are supported. 
 
If axis=1: 

 to select a single column, indices can be of int type for all X types and str only for dataframe. The selected subset will be 1D, unless X is a sparse matrix in which case it will be 2D. to select multiples columns, indices can be one of the following: list, array, slice. The type used in these containers can be one of the following: int, ‘bool’ and str. However, str is only supported when X is a dataframe. The selected subset will be 2D.       
axisint, default=0 

The axis along which X will be subsampled. axis=0 will select rows while axis=1 will select columns.    Returns 
 subset

Subset of X on axis 0 or 1.     Notes CSR, CSC, and LIL sparse matrices are supported. COO sparse matrices are not supported.
sklearn.svm.l1_min_c(X, y, *, loss='squared_hinge', fit_intercept=True, intercept_scaling=1.0) [source]
 
Return the lowest bound for C such that for C in (l1_min_C, infinity) the model is guaranteed not to be empty. This applies to l1 penalized classifiers, such as LinearSVC with penalty=’l1’ and linear_model.LogisticRegression with penalty=’l1’. This value is valid if class_weight parameter in fit() is not set.  Parameters 
 
X{array-like, sparse matrix} of shape (n_samples, n_features) 

Training vector, where n_samples in the number of samples and n_features is the number of features.  
yarray-like of shape (n_samples,) 

Target vector relative to X.  
loss{‘squared_hinge’, ‘log’}, default=’squared_hinge’ 

Specifies the loss function. With ‘squared_hinge’ it is the squared hinge loss (a.k.a. L2 loss). With ‘log’ it is the loss of logistic regression models.  
fit_interceptbool, default=True 

Specifies if the intercept should be fitted by the model. It must match the fit() method parameter.  
intercept_scalingfloat, default=1.0 

when fit_intercept is True, instance vector x becomes [x, intercept_scaling], i.e. a “synthetic” feature with constant value equals to intercept_scaling is appended to the instance vector. It must match the fit() method parameter.    Returns 
 
l1_min_cfloat 

minimum value for C
fit(X, y, sample_weight=None) [source]
 
Fit the model according to the given training data.  Parameters 
 
X{array-like, sparse matrix} of shape (n_samples, n_features) 

Training vector, where n_samples in the number of samples and n_features is the number of features.  
yarray-like of shape (n_samples,) 

Target vector relative to X.  
sample_weightarray-like of shape (n_samples,), default=None 

Array of weights that are assigned to individual samples. If not provided, then each sample is given unit weight.  New in version 0.18.     Returns 
 
selfobject 

An instance of the estimator.
fit(X, y, sample_weight=None) [source]
 
Fit the model according to the given training data.  Parameters 
 
X{array-like, sparse matrix} of shape (n_samples, n_features) 

Training vector, where n_samples in the number of samples and n_features is the number of features.  
yarray-like of shape (n_samples,) 

Target vector relative to X  
sample_weightarray-like of shape (n_samples,), default=None 

Array of weights that are assigned to individual samples. If not provided, then each sample is given unit weight.  New in version 0.18.     Returns 
 
selfobject 

An instance of the estimator.
decision_function(X) [source]
 
Evaluates the decision function for the samples in X.  Parameters 
 
Xarray-like of shape (n_samples, n_features) 
  Returns 
 
Xndarray of shape (n_samples, n_classes * (n_classes-1) / 2) 

Returns the decision function of the sample for each class in the model. If decision_function_shape=’ovr’, the shape is (n_samples, n_classes).     Notes If decision_function_shape=’ovo’, the function values are proportional to the distance of the samples X to the separating hyperplane. If the exact distances are required, divide the function values by the norm of the weight vector (coef_). See also this question for further details. If decision_function_shape=’ovr’, the decision function is a monotonic transformation of ovo decision function.
fit(X, y, sample_weight=None) [source]
 
Fit the SVM model according to the given training data.  Parameters 
 
X{array-like, sparse matrix} of shape (n_samples, n_features) or (n_samples, n_samples) 

Training vectors, where n_samples is the number of samples and n_features is the number of features. For kernel=”precomputed”, the expected shape of X is (n_samples, n_samples).  
yarray-like of shape (n_samples,) 

Target values (class labels in classification, real numbers in regression).  
sample_weightarray-like of shape (n_samples,), default=None 

Per-sample weights. Rescale C per sample. Higher weights force the classifier to put more emphasis on these points.    Returns 
 
selfobject 
   Notes If X and y are not C-ordered and contiguous arrays of np.float64 and X is not a scipy.sparse.csr_matrix, X and/or y may be copied. If X is a dense array, then the other methods will not support sparse matrices as input.
predict(X) [source]
 
Perform classification on samples in X. For an one-class model, +1 or -1 is returned.  Parameters 
 
X{array-like, sparse matrix} of shape (n_samples, n_features) or (n_samples_test, n_samples_train) 

For kernel=”precomputed”, the expected shape of X is (n_samples_test, n_samples_train).    Returns 
 
y_predndarray of shape (n_samples,) 

Class labels for samples in X.
property predict_log_proba  
Compute log probabilities of possible outcomes for samples in X. The model need to have probability information computed at training time: fit with attribute probability set to True.  Parameters 
 
Xarray-like of shape (n_samples, n_features) or (n_samples_test, n_samples_train) 

For kernel=”precomputed”, the expected shape of X is (n_samples_test, n_samples_train).    Returns 
 
Tndarray of shape (n_samples, n_classes) 

Returns the log-probabilities of the sample for each class in the model. The columns correspond to the classes in sorted order, as they appear in the attribute classes_.     Notes The probability model is created using cross validation, so the results can be slightly different than those obtained by predict. Also, it will produce meaningless results on very small datasets.
property predict_proba  
Compute probabilities of possible outcomes for samples in X. The model need to have probability information computed at training time: fit with attribute probability set to True.  Parameters 
 
Xarray-like of shape (n_samples, n_features) 

For kernel=”precomputed”, the expected shape of X is (n_samples_test, n_samples_train).    Returns 
 
Tndarray of shape (n_samples, n_classes) 

Returns the probability of the sample for each class in the model. The columns correspond to the classes in sorted order, as they appear in the attribute classes_.     Notes The probability model is created using cross validation, so the results can be slightly different than those obtained by predict. Also, it will produce meaningless results on very small datasets.
predict(X) [source]
 
Perform regression on samples in X. For an one-class model, +1 (inlier) or -1 (outlier) is returned.  Parameters 
 
X{array-like, sparse matrix} of shape (n_samples, n_features) 

For kernel=”precomputed”, the expected shape of X is (n_samples_test, n_samples_train).    Returns 
 
y_predndarray of shape (n_samples,)
decision_function(X) [source]
 
Signed distance to the separating hyperplane. Signed distance is positive for an inlier and negative for an outlier.  Parameters 
 
Xarray-like of shape (n_samples, n_features) 

The data matrix.    Returns 
 
decndarray of shape (n_samples,) 

Returns the decision function of the samples.
fit(X, y=None, sample_weight=None, **params) [source]
 
Detects the soft boundary of the set of samples X.  Parameters 
 
X{array-like, sparse matrix} of shape (n_samples, n_features) 

Set of samples, where n_samples is the number of samples and n_features is the number of features.  
sample_weightarray-like of shape (n_samples,), default=None 

Per-sample weights. Rescale C per sample. Higher weights force the classifier to put more emphasis on these points.  
yIgnored 

not used, present for API consistency by convention.    Returns 
 
selfobject 
   Notes If X is not a C-ordered contiguous array it is copied.
predict(X) [source]
 
Perform classification on samples in X. For a one-class model, +1 or -1 is returned.  Parameters 
 
X{array-like, sparse matrix} of shape (n_samples, n_features) or (n_samples_test, n_samples_train) 

For kernel=”precomputed”, the expected shape of X is (n_samples_test, n_samples_train).    Returns 
 
y_predndarray of shape (n_samples,) 

Class labels for samples in X.
score_samples(X) [source]
 
Raw scoring function of the samples.  Parameters 
 
Xarray-like of shape (n_samples, n_features) 

The data matrix.    Returns 
 
score_samplesndarray of shape (n_samples,) 

Returns the (unshifted) scoring function of the samples.