Datasets:

repository
stringclasses
11 values
repo_id
stringlengths
1
3
target_module_path
stringlengths
16
72
prompt
stringlengths
298
21.7k
relavent_test_path
stringlengths
50
99
full_function
stringlengths
336
33.8k
function_name
stringlengths
2
51
content_class
stringclasses
3 values
external_dependencies
stringclasses
2 values
scikit-learn
222
sklearn/mixture/_gaussian_mixture.py
def _compute_log_det_cholesky(matrix_chol, covariance_type, n_features): """Compute the log-det of the cholesky decomposition of matrices. Parameters ---------- matrix_chol : array-like Cholesky decompositions of the matrices. 'full' : shape of (n_components, n_features, n_features) ...
/usr/src/app/target_test_cases/failed_tests__compute_log_det_cholesky.txt
def _compute_log_det_cholesky(matrix_chol, covariance_type, n_features): """Compute the log-det of the cholesky decomposition of matrices. Parameters ---------- matrix_chol : array-like Cholesky decompositions of the matrices. 'full' : shape of (n_components, n_features, n_features) ...
_compute_log_det_cholesky
self-contained
external
scikit-learn
223
sklearn/mixture/_gaussian_mixture.py
def _compute_precision_cholesky(covariances, covariance_type): """Compute the Cholesky decomposition of the precisions. Parameters ---------- covariances : array-like The covariance matrix of the current components. The shape depends of the covariance_type. covariance_type : {'full...
/usr/src/app/target_test_cases/failed_tests__compute_precision_cholesky.txt
def _compute_precision_cholesky(covariances, covariance_type): """Compute the Cholesky decomposition of the precisions. Parameters ---------- covariances : array-like The covariance matrix of the current components. The shape depends of the covariance_type. covariance_type : {'full...
_compute_precision_cholesky
self-contained
external
scikit-learn
224
sklearn/utils/_testing.py
def _convert_container( container, constructor_name, columns_name=None, dtype=None, minversion=None, categorical_feature_names=None, ): """Convert a given container to a specific array-like with a dtype. Parameters ---------- container : array-like The container to conve...
/usr/src/app/target_test_cases/failed_tests__convert_container.txt
def _convert_container( container, constructor_name, columns_name=None, dtype=None, minversion=None, categorical_feature_names=None, ): """Convert a given container to a specific array-like with a dtype. Parameters ---------- container : array-like The container to conve...
_convert_container
repository-level
external
scikit-learn
225
sklearn/discriminant_analysis.py
def _cov(X, shrinkage=None, covariance_estimator=None): """Estimate covariance matrix (using optional covariance_estimator). Parameters ---------- X : array-like of shape (n_samples, n_features) Input data. shrinkage : {'empirical', 'auto'} or float, default=None Shrinkage parameter...
/usr/src/app/target_test_cases/failed_tests__cov.txt
def _cov(X, shrinkage=None, covariance_estimator=None): """Estimate covariance matrix (using optional covariance_estimator). Parameters ---------- X : array-like of shape (n_samples, n_features) Input data. shrinkage : {'empirical', 'auto'} or float, default=None Shrinkage parameter...
_cov
repository-level
external
scikit-learn
226
sklearn/metrics/_ranking.py
def _dcg_sample_scores(y_true, y_score, k=None, log_base=2, ignore_ties=False): """Compute Discounted Cumulative Gain. Sum the true scores ranked in the order induced by the predicted scores, after applying a logarithmic discount. This ranking metric yields a high value if true labels are ranked high ...
/usr/src/app/target_test_cases/failed_tests__dcg_sample_scores.txt
def _dcg_sample_scores(y_true, y_score, k=None, log_base=2, ignore_ties=False): """Compute Discounted Cumulative Gain. Sum the true scores ranked in the order induced by the predicted scores, after applying a logarithmic discount. This ranking metric yields a high value if true labels are ranked high ...
_dcg_sample_scores
file-level
external
scikit-learn
227
sklearn/linear_model/_ransac.py
def _dynamic_max_trials(n_inliers, n_samples, min_samples, probability): """Determine number trials such that at least one outlier-free subset is sampled for the given inlier/outlier ratio. Parameters ---------- n_inliers : int Number of inliers in the data. n_samples : int Tot...
/usr/src/app/target_test_cases/failed_tests__dynamic_max_trials.txt
def _dynamic_max_trials(n_inliers, n_samples, min_samples, probability): """Determine number trials such that at least one outlier-free subset is sampled for the given inlier/outlier ratio. Parameters ---------- n_inliers : int Number of inliers in the data. n_samples : int Tot...
_dynamic_max_trials
file-level
external
scikit-learn
228
sklearn/utils/_encode.py
def _encode(values, *, uniques, check_unknown=True): """Helper function to encode values into [0, n_uniques - 1]. Uses pure python method for object dtype, and numpy method for all other dtypes. The numpy method has the limitation that the `uniques` need to be sorted. Importantly, this is not check...
/usr/src/app/target_test_cases/failed_tests__encode.txt
def _encode(values, *, uniques, check_unknown=True): """Helper function to encode values into [0, n_uniques - 1]. Uses pure python method for object dtype, and numpy method for all other dtypes. The numpy method has the limitation that the `uniques` need to be sorted. Importantly, this is not check...
_encode
repository-level
non_external
scikit-learn
229
sklearn/mixture/_gaussian_mixture.py
def _estimate_gaussian_covariances_full(resp, X, nk, means, reg_covar): """Estimate the full covariance matrices. Parameters ---------- resp : array-like of shape (n_samples, n_components) X : array-like of shape (n_samples, n_features) nk : array-like of shape (n_components,) means : ar...
/usr/src/app/target_test_cases/failed_tests__estimate_gaussian_covariances_full.txt
def _estimate_gaussian_covariances_full(resp, X, nk, means, reg_covar): """Estimate the full covariance matrices. Parameters ---------- resp : array-like of shape (n_samples, n_components) X : array-like of shape (n_samples, n_features) nk : array-like of shape (n_components,) means : ar...
_estimate_gaussian_covariances_full
file-level
external
scikit-learn
230
sklearn/mixture/_gaussian_mixture.py
def _estimate_gaussian_parameters(X, resp, reg_covar, covariance_type): """Estimate the Gaussian distribution parameters. Parameters ---------- X : array-like of shape (n_samples, n_features) The input data array. resp : array-like of shape (n_samples, n_components) The responsibil...
/usr/src/app/target_test_cases/failed_tests__estimate_gaussian_parameters.txt
def _estimate_gaussian_parameters(X, resp, reg_covar, covariance_type): """Estimate the Gaussian distribution parameters. Parameters ---------- X : array-like of shape (n_samples, n_features) The input data array. resp : array-like of shape (n_samples, n_components) The responsibil...
_estimate_gaussian_parameters
file-level
external
scikit-learn
231
sklearn/feature_extraction/image.py
def _extract_patches(arr, patch_shape=8, extraction_step=1): """Extracts patches of any n-dimensional array in place using strides. Given an n-dimensional array it will return a 2n-dimensional array with the first n dimensions indexing patch position and the last n indexing the patch content. This oper...
/usr/src/app/target_test_cases/failed_tests__extract_patches.txt
def _extract_patches(arr, patch_shape=8, extraction_step=1): """Extracts patches of any n-dimensional array in place using strides. Given an n-dimensional array it will return a 2n-dimensional array with the first n dimensions indexing patch position and the last n indexing the patch content. This oper...
_extract_patches
file-level
external
scikit-learn
232
sklearn/datasets/_base.py
def _fetch_remote(remote, dirname=None, n_retries=3, delay=1): """Helper function to download a remote dataset. Fetch a dataset pointed by remote's url, save into path using remote's filename and ensure its integrity based on the SHA256 checksum of the downloaded file. .. versionchanged:: 1.6 ...
/usr/src/app/target_test_cases/failed_tests__fetch_remote.txt
def _fetch_remote(remote, dirname=None, n_retries=3, delay=1): """Helper function to download a remote dataset. Fetch a dataset pointed by remote's url, save into path using remote's filename and ensure its integrity based on the SHA256 checksum of the downloaded file. .. versionchanged:: 1.6 ...
_fetch_remote
file-level
external
scikit-learn
233
sklearn/ensemble/_hist_gradient_boosting/binning.py
def _find_binning_thresholds(col_data, max_bins): """Extract quantiles from a continuous feature. Missing values are ignored for finding the thresholds. Parameters ---------- col_data : array-like, shape (n_samples,) The continuous feature to bin. max_bins: int The maximum numb...
/usr/src/app/target_test_cases/failed_tests__find_binning_thresholds.txt
def _find_binning_thresholds(col_data, max_bins): """Extract quantiles from a continuous feature. Missing values are ignored for finding the thresholds. Parameters ---------- col_data : array-like, shape (n_samples,) The continuous feature to bin. max_bins: int The maximum numb...
_find_binning_thresholds
repository-level
external
scikit-learn
234
sklearn/model_selection/_validation.py
def _fit_and_score( estimator, X, y, *, scorer, train, test, verbose, parameters, fit_params, score_params, return_train_score=False, return_parameters=False, return_n_test_samples=False, return_times=False, return_estimator=False, split_progress=None,...
/usr/src/app/target_test_cases/failed_tests__fit_and_score.txt
def _fit_and_score( estimator, X, y, *, scorer, train, test, verbose, parameters, fit_params, score_params, return_train_score=False, return_parameters=False, return_n_test_samples=False, return_times=False, return_estimator=False, split_progress=None,...
_fit_and_score
repository-level
external
scikit-learn
235
sklearn/model_selection/_classification_threshold.py
def _fit_and_score_over_thresholds( classifier, X, y, *, fit_params, train_idx, val_idx, curve_scorer, score_params, ): """Fit a classifier and compute the scores for different decision thresholds. Parameters ---------- classifier : estimator instance The cla...
/usr/src/app/target_test_cases/failed_tests__fit_and_score_over_thresholds.txt
def _fit_and_score_over_thresholds( classifier, X, y, *, fit_params, train_idx, val_idx, curve_scorer, score_params, ): """Fit a classifier and compute the scores for different decision thresholds. Parameters ---------- classifier : estimator instance The cla...
_fit_and_score_over_thresholds
repository-level
non_external
scikit-learn
236
sklearn/utils/graph.py
def _fix_connected_components( X, graph, n_connected_components, component_labels, mode="distance", metric="euclidean", **kwargs, ): """Add connections to sparse graph to connect unconnected components. For each pair of unconnected components, compute all pairwise distances from...
/usr/src/app/target_test_cases/failed_tests__fix_connected_components.txt
def _fix_connected_components( X, graph, n_connected_components, component_labels, mode="distance", metric="euclidean", **kwargs, ): """Add connections to sparse graph to connect unconnected components. For each pair of unconnected components, compute all pairwise distances from...
_fix_connected_components
repository-level
external
scikit-learn
237
sklearn/cluster/_agglomerative.py
def _fix_connectivity(X, connectivity, affinity): """ Fixes the connectivity matrix. The different steps are: - copies it - makes it symmetric - converts it to LIL if necessary - completes it if necessary. Parameters ---------- X : array-like of shape (n_samples, n_features) ...
/usr/src/app/target_test_cases/failed_tests__fix_connectivity.txt
def _fix_connectivity(X, connectivity, affinity): """ Fixes the connectivity matrix. The different steps are: - copies it - makes it symmetric - converts it to LIL if necessary - completes it if necessary. Parameters ---------- X : array-like of shape (n_samples, n_features) ...
_fix_connectivity
repository-level
external
scikit-learn
238
sklearn/inspection/_pd_utils.py
def _get_feature_index(fx, feature_names=None): """Get feature index. Parameters ---------- fx : int or str Feature index or name. feature_names : list of str, default=None All feature names from which to search the indices. Returns ------- idx : int Feature in...
/usr/src/app/target_test_cases/failed_tests__get_feature_index.txt
def _get_feature_index(fx, feature_names=None): """Get feature index. Parameters ---------- fx : int or str Feature index or name. feature_names : list of str, default=None All feature names from which to search the indices. Returns ------- idx : int Feature in...
_get_feature_index
self-contained
non_external
scikit-learn
239
sklearn/ensemble/_forest.py
def _get_n_samples_bootstrap(n_samples, max_samples): """ Get the number of samples in a bootstrap sample. Parameters ---------- n_samples : int Number of samples in the dataset. max_samples : int or float The maximum number of samples to draw from the total available: ...
/usr/src/app/target_test_cases/failed_tests__get_n_samples_bootstrap.txt
def _get_n_samples_bootstrap(n_samples, max_samples): """ Get the number of samples in a bootstrap sample. Parameters ---------- n_samples : int Number of samples in the dataset. max_samples : int or float The maximum number of samples to draw from the total available: ...
_get_n_samples_bootstrap
self-contained
external
scikit-learn
240
sklearn/utils/_response.py
def _get_response_values( estimator, X, response_method, pos_label=None, return_response_method_used=False, ): """Compute the response values of a classifier, an outlier detector, or a regressor. The response values are predictions such that it follows the following shape: - for binary...
/usr/src/app/target_test_cases/failed_tests__get_response_values.txt
def _get_response_values( estimator, X, response_method, pos_label=None, return_response_method_used=False, ): """Compute the response values of a classifier, an outlier detector, or a regressor. The response values are predictions such that it follows the following shape: - for binary...
_get_response_values
repository-level
non_external
scikit-learn
241
sklearn/utils/_response.py
def _get_response_values_binary( estimator, X, response_method, pos_label=None, return_response_method_used=False ): """Compute the response values of a binary classifier. Parameters ---------- estimator : estimator instance Fitted classifier or a fitted :class:`~sklearn.pipeline.Pipeline` ...
/usr/src/app/target_test_cases/failed_tests__get_response_values_binary.txt
def _get_response_values_binary( estimator, X, response_method, pos_label=None, return_response_method_used=False ): """Compute the response values of a binary classifier. Parameters ---------- estimator : estimator instance Fitted classifier or a fitted :class:`~sklearn.pipeline.Pipeline` ...
_get_response_values_binary
repository-level
non_external
scikit-learn
242
sklearn/manifold/_t_sne.py
def _gradient_descent( objective, p0, it, max_iter, n_iter_check=1, n_iter_without_progress=300, momentum=0.8, learning_rate=200.0, min_gain=0.01, min_grad_norm=1e-7, verbose=0, args=None, kwargs=None, ): """Batch gradient descent with momentum and individual gain...
/usr/src/app/target_test_cases/failed_tests__gradient_descent.txt
def _gradient_descent( objective, p0, it, max_iter, n_iter_check=1, n_iter_without_progress=300, momentum=0.8, learning_rate=200.0, min_gain=0.01, min_grad_norm=1e-7, verbose=0, args=None, kwargs=None, ): """Batch gradient descent with momentum and individual gain...
_gradient_descent
file-level
external
scikit-learn
243
sklearn/manifold/_spectral_embedding.py
def _graph_connected_component(graph, node_id): """Find the largest graph connected components that contains one given node. Parameters ---------- graph : array-like of shape (n_samples, n_samples) Adjacency matrix of the graph, non-zero weight means an edge between the nodes. ...
/usr/src/app/target_test_cases/failed_tests__graph_connected_component.txt
def _graph_connected_component(graph, node_id): """Find the largest graph connected components that contains one given node. Parameters ---------- graph : array-like of shape (n_samples, n_samples) Adjacency matrix of the graph, non-zero weight means an edge between the nodes. ...
_graph_connected_component
file-level
external
scikit-learn
244
sklearn/manifold/_spectral_embedding.py
def _graph_is_connected(graph): """Return whether the graph is connected (True) or Not (False). Parameters ---------- graph : {array-like, sparse matrix} of shape (n_samples, n_samples) Adjacency matrix of the graph, non-zero weight means an edge between the nodes. Returns ----...
/usr/src/app/target_test_cases/failed_tests__graph_is_connected.txt
def _graph_is_connected(graph): """Return whether the graph is connected (True) or Not (False). Parameters ---------- graph : {array-like, sparse matrix} of shape (n_samples, n_samples) Adjacency matrix of the graph, non-zero weight means an edge between the nodes. Returns ----...
_graph_is_connected
repository-level
external
scikit-learn
245
sklearn/inspection/_partial_dependence.py
def _grid_from_X(X, percentiles, is_categorical, grid_resolution): """Generate a grid of points based on the percentiles of X. The grid is a cartesian product between the columns of ``values``. The ith column of ``values`` consists in ``grid_resolution`` equally-spaced points between the percentiles of...
/usr/src/app/target_test_cases/failed_tests__grid_from_X.txt
def _grid_from_X(X, percentiles, is_categorical, grid_resolution): """Generate a grid of points based on the percentiles of X. The grid is a cartesian product between the columns of ``values``. The ith column of ``values`` consists in ``grid_resolution`` equally-spaced points between the percentiles of...
_grid_from_X
repository-level
external
scikit-learn
246
sklearn/cluster/_agglomerative.py
def _hc_cut(n_clusters, children, n_leaves): """Function cutting the ward tree for a given number of clusters. Parameters ---------- n_clusters : int or ndarray The number of clusters to form. children : ndarray of shape (n_nodes-1, 2) The children of each non-leaf node. Values les...
/usr/src/app/target_test_cases/failed_tests__hc_cut.txt
def _hc_cut(n_clusters, children, n_leaves): """Function cutting the ward tree for a given number of clusters. Parameters ---------- n_clusters : int or ndarray The number of clusters to form. children : ndarray of shape (n_nodes-1, 2) The children of each non-leaf node. Values les...
_hc_cut
self-contained
external
scikit-learn
247
sklearn/linear_model/_huber.py
def _huber_loss_and_gradient(w, X, y, epsilon, alpha, sample_weight=None): """Returns the Huber loss and the gradient. Parameters ---------- w : ndarray, shape (n_features + 1,) or (n_features + 2,) Feature vector. w[:n_features] gives the coefficients w[-1] gives the scale fact...
/usr/src/app/target_test_cases/failed_tests__huber_loss_and_gradient.txt
def _huber_loss_and_gradient(w, X, y, epsilon, alpha, sample_weight=None): """Returns the Huber loss and the gradient. Parameters ---------- w : ndarray, shape (n_features + 1,) or (n_features + 2,) Feature vector. w[:n_features] gives the coefficients w[-1] gives the scale fact...
_huber_loss_and_gradient
repository-level
external
scikit-learn
248
sklearn/manifold/_t_sne.py
def _joint_probabilities(distances, desired_perplexity, verbose): """Compute joint probabilities p_ij from distances. Parameters ---------- distances : ndarray of shape (n_samples * (n_samples-1) / 2,) Distances of samples are stored as condensed matrices, i.e. we omit the diagonal and ...
/usr/src/app/target_test_cases/failed_tests__joint_probabilities.txt
def _joint_probabilities(distances, desired_perplexity, verbose): """Compute joint probabilities p_ij from distances. Parameters ---------- distances : ndarray of shape (n_samples * (n_samples-1) / 2,) Distances of samples are stored as condensed matrices, i.e. we omit the diagonal and ...
_joint_probabilities
file-level
external
scikit-learn
249
sklearn/manifold/_t_sne.py
def _joint_probabilities_nn(distances, desired_perplexity, verbose): """Compute joint probabilities p_ij from distances using just nearest neighbors. This method is approximately equal to _joint_probabilities. The latter is O(N), but limiting the joint probability to nearest neighbors improves this...
/usr/src/app/target_test_cases/failed_tests__joint_probabilities_nn.txt
def _joint_probabilities_nn(distances, desired_perplexity, verbose): """Compute joint probabilities p_ij from distances using just nearest neighbors. This method is approximately equal to _joint_probabilities. The latter is O(N), but limiting the joint probability to nearest neighbors improves this...
_joint_probabilities_nn
file-level
external
scikit-learn
250
sklearn/manifold/_t_sne.py
def _kl_divergence( params, P, degrees_of_freedom, n_samples, n_components, skip_num_points=0, compute_error=True, ): """t-SNE objective function: gradient of the KL divergence of p_ijs and q_ijs and the absolute error. Parameters ---------- params : ndarray of shape (n_...
/usr/src/app/target_test_cases/failed_tests__kl_divergence.txt
def _kl_divergence( params, P, degrees_of_freedom, n_samples, n_components, skip_num_points=0, compute_error=True, ): """t-SNE objective function: gradient of the KL divergence of p_ijs and q_ijs and the absolute error. Parameters ---------- params : ndarray of shape (n_...
_kl_divergence
file-level
external
scikit-learn
251
sklearn/manifold/_t_sne.py
def _kl_divergence_bh( params, P, degrees_of_freedom, n_samples, n_components, angle=0.5, skip_num_points=0, verbose=False, compute_error=True, num_threads=1, ): """t-SNE objective function: KL divergence of p_ijs and q_ijs. Uses Barnes-Hut tree methods to calculate the ...
/usr/src/app/target_test_cases/failed_tests__kl_divergence_bh.txt
def _kl_divergence_bh( params, P, degrees_of_freedom, n_samples, n_components, angle=0.5, skip_num_points=0, verbose=False, compute_error=True, num_threads=1, ): """t-SNE objective function: KL divergence of p_ijs and q_ijs. Uses Barnes-Hut tree methods to calculate the ...
_kl_divergence_bh
self-contained
external
scikit-learn
252
sklearn/cluster/_kmeans.py
def _labels_inertia(X, sample_weight, centers, n_threads=1, return_inertia=True): """E step of the K-means EM algorithm. Compute the labels and the inertia of the given samples and centers. Parameters ---------- X : {ndarray, sparse matrix} of shape (n_samples, n_features) The input sample...
/usr/src/app/target_test_cases/failed_tests__labels_inertia.txt
def _labels_inertia(X, sample_weight, centers, n_threads=1, return_inertia=True): """E step of the K-means EM algorithm. Compute the labels and the inertia of the given samples and centers. Parameters ---------- X : {ndarray, sparse matrix} of shape (n_samples, n_features) The input sample...
_labels_inertia
self-contained
external
scikit-learn
253
sklearn/linear_model/_least_angle.py
def _lars_path_residues( X_train, y_train, X_test, y_test, Gram=None, copy=True, method="lar", verbose=False, fit_intercept=True, max_iter=500, eps=np.finfo(float).eps, positive=False, ): """Compute the residues on left-out data for a full LARS path Parameters ...
/usr/src/app/target_test_cases/failed_tests__lars_path_residues.txt
def _lars_path_residues( X_train, y_train, X_test, y_test, Gram=None, copy=True, method="lar", verbose=False, fit_intercept=True, max_iter=500, eps=np.finfo(float).eps, positive=False, ): """Compute the residues on left-out data for a full LARS path Parameters ...
_lars_path_residues
repository-level
external
scikit-learn
254
sklearn/linear_model/_logistic.py
def _log_reg_scoring_path( X, y, train, test, *, pos_class, Cs, scoring, fit_intercept, max_iter, tol, class_weight, verbose, solver, penalty, dual, intercept_scaling, multi_class, random_state, max_squared_sum, sample_weight, l1_ra...
/usr/src/app/target_test_cases/failed_tests__log_reg_scoring_path.txt
def _log_reg_scoring_path( X, y, train, test, *, pos_class, Cs, scoring, fit_intercept, max_iter, tol, class_weight, verbose, solver, penalty, dual, intercept_scaling, multi_class, random_state, max_squared_sum, sample_weight, l1_ra...
_log_reg_scoring_path
repository-level
external
scikit-learn
255
sklearn/mixture/_bayesian_mixture.py
def _log_wishart_norm(degrees_of_freedom, log_det_precisions_chol, n_features): """Compute the log of the Wishart distribution normalization term. Parameters ---------- degrees_of_freedom : array-like of shape (n_components,) The number of degrees of freedom on the covariance Wishart di...
/usr/src/app/target_test_cases/failed_tests__log_wishart_norm.txt
def _log_wishart_norm(degrees_of_freedom, log_det_precisions_chol, n_features): """Compute the log of the Wishart distribution normalization term. Parameters ---------- degrees_of_freedom : array-like of shape (n_components,) The number of degrees of freedom on the covariance Wishart di...
_log_wishart_norm
self-contained
external
scikit-learn
256
sklearn/linear_model/_logistic.py
def _logistic_regression_path( X, y, pos_class=None, Cs=10, fit_intercept=True, max_iter=100, tol=1e-4, verbose=0, solver="lbfgs", coef=None, class_weight=None, dual=False, penalty="l2", intercept_scaling=1.0, multi_class="auto", random_state=None, che...
/usr/src/app/target_test_cases/failed_tests__logistic_regression_path.txt
def _logistic_regression_path( X, y, pos_class=None, Cs=10, fit_intercept=True, max_iter=100, tol=1e-4, verbose=0, solver="lbfgs", coef=None, class_weight=None, dual=False, penalty="l2", intercept_scaling=1.0, multi_class="auto", random_state=None, che...
_logistic_regression_path
repository-level
external
scikit-learn
257
sklearn/cluster/_kmeans.py
def _mini_batch_step( X, sample_weight, centers, centers_new, weight_sums, random_state, random_reassign=False, reassignment_ratio=0.01, verbose=False, n_threads=1, ): """Incremental update of the centers for the Minibatch K-Means algorithm. Parameters ---------- ...
/usr/src/app/target_test_cases/failed_tests__mini_batch_step.txt
def _mini_batch_step( X, sample_weight, centers, centers_new, weight_sums, random_state, random_reassign=False, reassignment_ratio=0.01, verbose=False, n_threads=1, ): """Incremental update of the centers for the Minibatch K-Means algorithm. Parameters ---------- ...
_mini_batch_step
file-level
external
scikit-learn
258
sklearn/linear_model/_theil_sen.py
def _modified_weiszfeld_step(X, x_old): """Modified Weiszfeld step. This function defines one iteration step in order to approximate the spatial median (L1 median). It is a form of an iteratively re-weighted least squares method. Parameters ---------- X : array-like of shape (n_samples, n_...
/usr/src/app/target_test_cases/failed_tests__modified_weiszfeld_step.txt
def _modified_weiszfeld_step(X, x_old): """Modified Weiszfeld step. This function defines one iteration step in order to approximate the spatial median (L1 median). It is a form of an iteratively re-weighted least squares method. Parameters ---------- X : array-like of shape (n_samples, n_...
_modified_weiszfeld_step
file-level
external
scikit-learn
259
sklearn/utils/extmath.py
def _nanaverage(a, weights=None): """Compute the weighted average, ignoring NaNs. Parameters ---------- a : ndarray Array containing data to be averaged. weights : array-like, default=None An array of weights associated with the values in a. Each value in a contributes to th...
/usr/src/app/target_test_cases/failed_tests__nanaverage.txt
def _nanaverage(a, weights=None): """Compute the weighted average, ignoring NaNs. Parameters ---------- a : ndarray Array containing data to be averaged. weights : array-like, default=None An array of weights associated with the values in a. Each value in a contributes to th...
_nanaverage
self-contained
external
scikit-learn
260
sklearn/utils/optimize.py
def _newton_cg( grad_hess, func, grad, x0, args=(), tol=1e-4, maxiter=100, maxinner=200, line_search=True, warn=True, verbose=0, ): """ Minimization of scalar function of one or more variables using the Newton-CG algorithm. Parameters ---------- grad_...
/usr/src/app/target_test_cases/failed_tests__newton_cg.txt
def _newton_cg( grad_hess, func, grad, x0, args=(), tol=1e-4, maxiter=100, maxinner=200, line_search=True, warn=True, verbose=0, ): """ Minimization of scalar function of one or more variables using the Newton-CG algorithm. Parameters ---------- grad_...
_newton_cg
repository-level
external
scikit-learn
261
sklearn/datasets/_openml.py
def _open_openml_url( openml_path: str, data_home: Optional[str], n_retries: int = 3, delay: float = 1.0 ): """ Returns a resource from OpenML.org. Caches it to data_home if required. Parameters ---------- openml_path : str OpenML URL that will be accessed. This will be prefixes with ...
/usr/src/app/target_test_cases/failed_tests__open_openml_url.txt
def _open_openml_url( openml_path: str, data_home: Optional[str], n_retries: int = 3, delay: float = 1.0 ): """ Returns a resource from OpenML.org. Caches it to data_home if required. Parameters ---------- openml_path : str OpenML URL that will be accessed. This will be prefixes with ...
_open_openml_url
file-level
external
scikit-learn
262
sklearn/utils/multiclass.py
def _ovr_decision_function(predictions, confidences, n_classes): """Compute a continuous, tie-breaking OvR decision function from OvO. It is important to include a continuous value, not only votes, to make computing AUC or calibration meaningful. Parameters ---------- predictions : array-like ...
/usr/src/app/target_test_cases/failed_tests__ovr_decision_function.txt
def _ovr_decision_function(predictions, confidences, n_classes): """Compute a continuous, tie-breaking OvR decision function from OvO. It is important to include a continuous value, not only votes, to make computing AUC or calibration meaningful. Parameters ---------- predictions : array-like ...
_ovr_decision_function
self-contained
external
scikit-learn
263
sklearn/inspection/_partial_dependence.py
def _partial_dependence_brute( est, grid, features, X, response_method, sample_weight=None ): """Calculate partial dependence via the brute force method. The brute method explicitly averages the predictions of an estimator over a grid of feature values. For each `grid` value, all the samples from ...
/usr/src/app/target_test_cases/failed_tests__partial_dependence_brute.txt
def _partial_dependence_brute( est, grid, features, X, response_method, sample_weight=None ): """Calculate partial dependence via the brute force method. The brute method explicitly averages the predictions of an estimator over a grid of feature values. For each `grid` value, all the samples from ...
_partial_dependence_brute
repository-level
external
scikit-learn
264
sklearn/datasets/_arff_parser.py
def _post_process_frame(frame, feature_names, target_names): """Post process a dataframe to select the desired columns in `X` and `y`. Parameters ---------- frame : dataframe The dataframe to split into `X` and `y`. feature_names : list of str The list of feature names to populate ...
/usr/src/app/target_test_cases/failed_tests__post_process_frame.txt
def _post_process_frame(frame, feature_names, target_names): """Post process a dataframe to select the desired columns in `X` and `y`. Parameters ---------- frame : dataframe The dataframe to split into `X` and `y`. feature_names : list of str The list of feature names to populate ...
_post_process_frame
self-contained
non_external
scikit-learn
265
sklearn/utils/random.py
def _random_choice_csc(n_samples, classes, class_probability=None, random_state=None): """Generate a sparse random matrix given column class distributions Parameters ---------- n_samples : int, Number of samples to draw in each column. classes : list of size n_outputs of arrays of size (n_...
/usr/src/app/target_test_cases/failed_tests__random_choice_csc.txt
def _random_choice_csc(n_samples, classes, class_probability=None, random_state=None): """Generate a sparse random matrix given column class distributions Parameters ---------- n_samples : int, Number of samples to draw in each column. classes : list of size n_outputs of arrays of size (n_...
_random_choice_csc
repository-level
external
scikit-learn
266
sklearn/utils/extmath.py
def _randomized_eigsh( M, n_components, *, n_oversamples=10, n_iter="auto", power_iteration_normalizer="auto", selection="module", random_state=None, ): """Computes a truncated eigendecomposition using randomized methods This method solves the fixed-rank approximation problem de...
/usr/src/app/target_test_cases/failed_tests__randomized_eigsh.txt
def _randomized_eigsh( M, n_components, *, n_oversamples=10, n_iter="auto", power_iteration_normalizer="auto", selection="module", random_state=None, ): """Computes a truncated eigendecomposition using randomized methods This method solves the fixed-rank approximation problem de...
_randomized_eigsh
file-level
external
scikit-learn
267
sklearn/linear_model/_base.py
def _rescale_data(X, y, sample_weight, inplace=False): """Rescale data sample-wise by square root of sample_weight. For many linear models, this enables easy support for sample_weight because (y - X w)' S (y - X w) with S = diag(sample_weight) becomes ||y_rescaled - X_rescaled w||_2^2 ...
/usr/src/app/target_test_cases/failed_tests__rescale_data.txt
def _rescale_data(X, y, sample_weight, inplace=False): """Rescale data sample-wise by square root of sample_weight. For many linear models, this enables easy support for sample_weight because (y - X w)' S (y - X w) with S = diag(sample_weight) becomes ||y_rescaled - X_rescaled w||_2^2 ...
_rescale_data
repository-level
external
scikit-learn
268
sklearn/utils/_indexing.py
def _safe_assign(X, values, *, row_indexer=None, column_indexer=None): """Safe assignment to a numpy array, sparse matrix, or pandas dataframe. Parameters ---------- X : {ndarray, sparse-matrix, dataframe} Array to be modified. It is expected to be 2-dimensional. values : ndarray T...
/usr/src/app/target_test_cases/failed_tests__safe_assign.txt
def _safe_assign(X, values, *, row_indexer=None, column_indexer=None): """Safe assignment to a numpy array, sparse matrix, or pandas dataframe. Parameters ---------- X : {ndarray, sparse-matrix, dataframe} Array to be modified. It is expected to be 2-dimensional. values : ndarray T...
_safe_assign
self-contained
external
scikit-learn
269
sklearn/utils/_set_output.py
def _safe_set_output(estimator, *, transform=None): """Safely call estimator.set_output and error if it not available. This is used by meta-estimators to set the output for child estimators. Parameters ---------- estimator : estimator instance Estimator instance. transform : {"default...
/usr/src/app/target_test_cases/failed_tests__safe_set_output.txt
def _safe_set_output(estimator, *, transform=None): """Safely call estimator.set_output and error if it not available. This is used by meta-estimators to set the output for child estimators. Parameters ---------- estimator : estimator instance Estimator instance. transform : {"default...
_safe_set_output
self-contained
non_external
scikit-learn
270
sklearn/utils/metaestimators.py
def _safe_split(estimator, X, y, indices, train_indices=None): """Create subset of dataset and properly handle kernels. Slice X, y according to indices for cross-validation, but take care of precomputed kernel-matrices or pairwise affinities / distances. If ``estimator._pairwise is True``, X needs to ...
/usr/src/app/target_test_cases/failed_tests__safe_split.txt
def _safe_split(estimator, X, y, indices, train_indices=None): """Create subset of dataset and properly handle kernels. Slice X, y according to indices for cross-validation, but take care of precomputed kernel-matrices or pairwise affinities / distances. If ``estimator._pairwise is True``, X needs to ...
_safe_split
repository-level
external
scikit-learn
271
sklearn/linear_model/_coordinate_descent.py
def _set_order(X, y, order="C"): """Change the order of X and y if necessary. Parameters ---------- X : {array-like, sparse matrix} of shape (n_samples, n_features) Training data. y : ndarray of shape (n_samples,) Target values. order : {None, 'C', 'F'} If 'C', dense a...
/usr/src/app/target_test_cases/failed_tests__set_order.txt
def _set_order(X, y, order="C"): """Change the order of X and y if necessary. Parameters ---------- X : {array-like, sparse matrix} of shape (n_samples, n_features) Training data. y : ndarray of shape (n_samples,) Target values. order : {None, 'C', 'F'} If 'C', dense a...
_set_order
self-contained
external
scikit-learn
272
sklearn/ensemble/_base.py
def _set_random_states(estimator, random_state=None): """Set fixed random_state parameters for an estimator. Finds all parameters ending ``random_state`` and sets them to integers derived from ``random_state``. Parameters ---------- estimator : estimator supporting get/set_params Estim...
/usr/src/app/target_test_cases/failed_tests__set_random_states.txt
def _set_random_states(estimator, random_state=None): """Set fixed random_state parameters for an estimator. Finds all parameters ending ``random_state`` and sets them to integers derived from ``random_state``. Parameters ---------- estimator : estimator supporting get/set_params Estim...
_set_random_states
repository-level
external
scikit-learn
273
sklearn/calibration.py
def _sigmoid_calibration( predictions, y, sample_weight=None, max_abs_prediction_threshold=30 ): """Probability Calibration with sigmoid method (Platt 2000) Parameters ---------- predictions : ndarray of shape (n_samples,) The decision function or predict proba for the samples. y : nda...
/usr/src/app/target_test_cases/failed_tests__sigmoid_calibration.txt
def _sigmoid_calibration( predictions, y, sample_weight=None, max_abs_prediction_threshold=30 ): """Probability Calibration with sigmoid method (Platt 2000) Parameters ---------- predictions : ndarray of shape (n_samples,) The decision function or predict proba for the samples. y : nda...
_sigmoid_calibration
repository-level
external
scikit-learn
274
sklearn/metrics/cluster/_unsupervised.py
def _silhouette_reduce(D_chunk, start, labels, label_freqs): """Accumulate silhouette statistics for vertical chunk of X. Parameters ---------- D_chunk : {array-like, sparse matrix} of shape (n_chunk_samples, n_samples) Precomputed distances for a chunk. If a sparse matrix is provided, ...
/usr/src/app/target_test_cases/failed_tests__silhouette_reduce.txt
def _silhouette_reduce(D_chunk, start, labels, label_freqs): """Accumulate silhouette statistics for vertical chunk of X. Parameters ---------- D_chunk : {array-like, sparse matrix} of shape (n_chunk_samples, n_samples) Precomputed distances for a chunk. If a sparse matrix is provided, ...
_silhouette_reduce
self-contained
external
scikit-learn
275
sklearn/utils/fixes.py
def _smallest_admissible_index_dtype(arrays=(), maxval=None, check_contents=False): """Based on input (integer) arrays `a`, determine a suitable index data type that can hold the data in the arrays. This function returns `np.int64` if it either required by `maxval` or based on the largest precision of ...
/usr/src/app/target_test_cases/failed_tests__smallest_admissible_index_dtype.txt
def _smallest_admissible_index_dtype(arrays=(), maxval=None, check_contents=False): """Based on input (integer) arrays `a`, determine a suitable index data type that can hold the data in the arrays. This function returns `np.int64` if it either required by `maxval` or based on the largest precision of ...
_smallest_admissible_index_dtype
self-contained
external
scikit-learn
276
sklearn/decomposition/_dict_learning.py
def _update_dict( dictionary, Y, code, A=None, B=None, verbose=False, random_state=None, positive=False, ): """Update the dense dictionary factor in place. Parameters ---------- dictionary : ndarray of shape (n_components, n_features) Value of the dictionary at t...
/usr/src/app/target_test_cases/failed_tests__update_dict.txt
def _update_dict( dictionary, Y, code, A=None, B=None, verbose=False, random_state=None, positive=False, ): """Update the dense dictionary factor in place. Parameters ---------- dictionary : ndarray of shape (n_components, n_features) Value of the dictionary at t...
_update_dict
repository-level
external
scikit-learn
277
sklearn/utils/stats.py
def _weighted_percentile(array, sample_weight, percentile=50): """Compute weighted percentile Computes lower weighted percentile. If `array` is a 2D array, the `percentile` is computed along the axis 0. .. versionchanged:: 0.24 Accepts 2D `array`. Parameters ---------- arr...
/usr/src/app/target_test_cases/failed_tests__weighted_percentile.txt
def _weighted_percentile(array, sample_weight, percentile=50): """Compute weighted percentile Computes lower weighted percentile. If `array` is a 2D array, the `percentile` is computed along the axis 0. .. versionchanged:: 0.24 Accepts 2D `array`. Parameters ---------- arr...
_weighted_percentile
repository-level
external
scikit-learn
278
sklearn/utils/_estimator_html_repr.py
def _write_label_html( out, name, name_details, name_caption=None, doc_link_label=None, outer_class="sk-label-container", inner_class="sk-label", checked=False, doc_link="", is_fitted_css_class="", is_fitted_icon="", ): """Write labeled html with or without a dropdown wit...
/usr/src/app/target_test_cases/failed_tests__write_label_html.txt
def _write_label_html( out, name, name_details, name_caption=None, doc_link_label=None, outer_class="sk-label-container", inner_class="sk-label", checked=False, doc_link="", is_fitted_css_class="", is_fitted_icon="", ): """Write labeled html with or without a dropdown wit...
_write_label_html
file-level
external
scikit-learn
279
sklearn/model_selection/_search.py
def _yield_masked_array_for_each_param(candidate_params): """ Yield a masked array for each candidate param. `candidate_params` is a sequence of params which were used in a `GridSearchCV`. We use masked arrays for the results, as not all params are necessarily present in each element of `candid...
/usr/src/app/target_test_cases/failed_tests__yield_masked_array_for_each_param.txt
def _yield_masked_array_for_each_param(candidate_params): """ Yield a masked array for each candidate param. `candidate_params` is a sequence of params which were used in a `GridSearchCV`. We use masked arrays for the results, as not all params are necessarily present in each element of `candid...
_yield_masked_array_for_each_param
self-contained
external
scikit-learn
280
sklearn/utils/_testing.py
def assert_allclose_dense_sparse(x, y, rtol=1e-07, atol=1e-9, err_msg=""): """Assert allclose for sparse and dense data. Both x and y need to be either sparse or dense, they can't be mixed. Parameters ---------- x : {array-like, sparse matrix} First array to compare. y : {array-li...
/usr/src/app/target_test_cases/failed_tests_assert_allclose_dense_sparse.txt
def assert_allclose_dense_sparse(x, y, rtol=1e-07, atol=1e-9, err_msg=""): """Assert allclose for sparse and dense data. Both x and y need to be either sparse or dense, they can't be mixed. Parameters ---------- x : {array-like, sparse matrix} First array to compare. y : {array-li...
assert_allclose_dense_sparse
file-level
external
scikit-learn
281
sklearn/metrics/tests/test_pairwise_distances_reduction.py
def assert_compatible_argkmin_results( neighbors_dists_a, neighbors_dists_b, neighbors_indices_a, neighbors_indices_b, rtol=1e-5, atol=1e-6, ): """Assert that argkmin results are valid up to rounding errors. This function asserts that the results of argkmin queries are valid up to: ...
/usr/src/app/target_test_cases/failed_tests_assert_compatible_argkmin_results.txt
def assert_compatible_argkmin_results( neighbors_dists_a, neighbors_dists_b, neighbors_indices_a, neighbors_indices_b, rtol=1e-5, atol=1e-6, ): """Assert that argkmin results are valid up to rounding errors. This function asserts that the results of argkmin queries are valid up to: ...
assert_compatible_argkmin_results
file-level
external
scikit-learn
282
sklearn/metrics/tests/test_pairwise_distances_reduction.py
def assert_compatible_radius_results( neighbors_dists_a, neighbors_dists_b, neighbors_indices_a, neighbors_indices_b, radius, check_sorted=True, rtol=1e-5, atol=1e-6, ): """Assert that radius neighborhood results are valid up to: - relative and absolute tolerance on computed d...
/usr/src/app/target_test_cases/failed_tests_assert_compatible_radius_results.txt
def assert_compatible_radius_results( neighbors_dists_a, neighbors_dists_b, neighbors_indices_a, neighbors_indices_b, radius, check_sorted=True, rtol=1e-5, atol=1e-6, ): """Assert that radius neighborhood results are valid up to: - relative and absolute tolerance on computed d...
assert_compatible_radius_results
file-level
external
scikit-learn
283
sklearn/utils/_testing.py
def assert_run_python_script_without_output(source_code, pattern=".+", timeout=60): """Utility to check assertions in an independent Python subprocess. The script provided in the source code should return 0 and the stdtout + stderr should not match the pattern `pattern`. This is a port from cloudpickl...
/usr/src/app/target_test_cases/failed_tests_assert_run_python_script_without_output.txt
def assert_run_python_script_without_output(source_code, pattern=".+", timeout=60): """Utility to check assertions in an independent Python subprocess. The script provided in the source code should return 0 and the stdtout + stderr should not match the pattern `pattern`. This is a port from cloudpickl...
assert_run_python_script_without_output
repository-level
external
scikit-learn
284
sklearn/manifold/_locally_linear.py
def barycenter_kneighbors_graph(X, n_neighbors, reg=1e-3, n_jobs=None): """Computes the barycenter weighted graph of k-Neighbors for points in X Parameters ---------- X : {array-like, NearestNeighbors} Sample data, shape = (n_samples, n_features), in the form of a numpy array or a Neare...
/usr/src/app/target_test_cases/failed_tests_barycenter_kneighbors_graph.txt
def barycenter_kneighbors_graph(X, n_neighbors, reg=1e-3, n_jobs=None): """Computes the barycenter weighted graph of k-Neighbors for points in X Parameters ---------- X : {array-like, NearestNeighbors} Sample data, shape = (n_samples, n_features), in the form of a numpy array or a Neare...
barycenter_kneighbors_graph
repository-level
external
scikit-learn
285
sklearn/utils/validation.py
def check_X_y( X, y, accept_sparse=False, *, accept_large_sparse=True, dtype="numeric", order=None, copy=False, force_writeable=False, force_all_finite="deprecated", ensure_all_finite=None, ensure_2d=True, allow_nd=False, multi_output=False, ensure_min_samples...
/usr/src/app/target_test_cases/failed_tests_check_X_y.txt
def check_X_y( X, y, accept_sparse=False, *, accept_large_sparse=True, dtype="numeric", order=None, copy=False, force_writeable=False, force_all_finite="deprecated", ensure_all_finite=None, ensure_2d=True, allow_nd=False, multi_output=False, ensure_min_samples...
check_X_y
repository-level
non_external
scikit-learn
286
sklearn/utils/validation.py
def check_array( array, accept_sparse=False, *, accept_large_sparse=True, dtype="numeric", order=None, copy=False, force_writeable=False, force_all_finite="deprecated", ensure_all_finite=None, ensure_non_negative=False, ensure_2d=True, allow_nd=False, ensure_min_s...
/usr/src/app/target_test_cases/failed_tests_check_array.txt
def check_array( array, accept_sparse=False, *, accept_large_sparse=True, dtype="numeric", order=None, copy=False, force_writeable=False, force_all_finite="deprecated", ensure_all_finite=None, ensure_non_negative=False, ensure_2d=True, allow_nd=False, ensure_min_s...
check_array
repository-level
external
scikit-learn
287
sklearn/metrics/pairwise.py
def check_paired_arrays(X, Y): """Set X and Y appropriately and checks inputs for paired distances. All paired distance metrics should use this function first to assert that the given parameters are correct and safe to use. Specifically, this function first ensures that both X and Y are arrays, th...
/usr/src/app/target_test_cases/failed_tests_check_paired_arrays.txt
def check_paired_arrays(X, Y): """Set X and Y appropriately and checks inputs for paired distances. All paired distance metrics should use this function first to assert that the given parameters are correct and safe to use. Specifically, this function first ensures that both X and Y are arrays, th...
check_paired_arrays
file-level
non_external
scikit-learn
288
sklearn/metrics/pairwise.py
def check_pairwise_arrays( X, Y, *, precomputed=False, dtype="infer_float", accept_sparse="csr", force_all_finite="deprecated", ensure_all_finite=None, ensure_2d=True, copy=False, ): """Set X and Y appropriately and checks inputs. If Y is None, it is set as a pointer to ...
/usr/src/app/target_test_cases/failed_tests_check_pairwise_arrays.txt
def check_pairwise_arrays( X, Y, *, precomputed=False, dtype="infer_float", accept_sparse="csr", force_all_finite="deprecated", ensure_all_finite=None, ensure_2d=True, copy=False, ): """Set X and Y appropriately and checks inputs. If Y is None, it is set as a pointer to ...
check_pairwise_arrays
repository-level
external
scikit-learn
289
sklearn/tests/metadata_routing_common.py
def check_recorded_metadata(obj, method, parent, split_params=tuple(), **kwargs): """Check whether the expected metadata is passed to the object's method. Parameters ---------- obj : estimator object sub-estimator to check routed params for method : str sub-estimator's method where ...
/usr/src/app/target_test_cases/failed_tests_check_recorded_metadata.txt
def check_recorded_metadata(obj, method, parent, split_params=tuple(), **kwargs): """Check whether the expected metadata is passed to the object's method. Parameters ---------- obj : estimator object sub-estimator to check routed params for method : str sub-estimator's method where ...
check_recorded_metadata
self-contained
external
scikit-learn
290
sklearn/utils/multiclass.py
def class_distribution(y, sample_weight=None): """Compute class priors from multioutput-multiclass target data. Parameters ---------- y : {array-like, sparse matrix} of size (n_samples, n_outputs) The labels for each example. sample_weight : array-like of shape (n_samples,), default=None ...
/usr/src/app/target_test_cases/failed_tests_class_distribution.txt
def class_distribution(y, sample_weight=None): """Compute class priors from multioutput-multiclass target data. Parameters ---------- y : {array-like, sparse matrix} of size (n_samples, n_outputs) The labels for each example. sample_weight : array-like of shape (n_samples,), default=None ...
class_distribution
self-contained
external
scikit-learn
291
sklearn/utils/sparsefuncs.py
def count_nonzero(X, axis=None, sample_weight=None): """A variant of X.getnnz() with extension to weighting on axis 0. Useful in efficiently calculating multilabel metrics. Parameters ---------- X : sparse matrix of shape (n_samples, n_labels) Input data. It should be of CSR format. a...
/usr/src/app/target_test_cases/failed_tests_count_nonzero.txt
def count_nonzero(X, axis=None, sample_weight=None): """A variant of X.getnnz() with extension to weighting on axis 0. Useful in efficiently calculating multilabel metrics. Parameters ---------- X : sparse matrix of shape (n_samples, n_labels) Input data. It should be of CSR format. a...
count_nonzero
self-contained
external
scikit-learn
292
sklearn/utils/sparsefuncs.py
def csc_median_axis_0(X): """Find the median across axis 0 of a CSC matrix. It is equivalent to doing np.median(X, axis=0). Parameters ---------- X : sparse matrix of shape (n_samples, n_features) Input data. It should be of CSC format. Returns ------- median : ndarray of shap...
/usr/src/app/target_test_cases/failed_tests_csc_median_axis_0.txt
def csc_median_axis_0(X): """Find the median across axis 0 of a CSC matrix. It is equivalent to doing np.median(X, axis=0). Parameters ---------- X : sparse matrix of shape (n_samples, n_features) Input data. It should be of CSC format. Returns ------- median : ndarray of shap...
csc_median_axis_0
file-level
external
scikit-learn
293
sklearn/cluster/_spectral.py
def discretize( vectors, *, copy=True, max_svd_restarts=30, n_iter_max=20, random_state=None ): """Search for a partition matrix which is closest to the eigenvector embedding. This implementation was proposed in [1]_. Parameters ---------- vectors : array-like of shape (n_samples, n_clusters) ...
/usr/src/app/target_test_cases/failed_tests_discretize.txt
def discretize( vectors, *, copy=True, max_svd_restarts=30, n_iter_max=20, random_state=None ): """Search for a partition matrix which is closest to the eigenvector embedding. This implementation was proposed in [1]_. Parameters ---------- vectors : array-like of shape (n_samples, n_clusters) ...
discretize
repository-level
external
scikit-learn
294
sklearn/feature_selection/_univariate_selection.py
def f_oneway(*args): """Perform a 1-way ANOVA. The one-way ANOVA tests the null hypothesis that 2 or more groups have the same population mean. The test is applied to samples from two or more groups, possibly with differing sizes. Read more in the :ref:`User Guide <univariate_feature_selection>`. ...
/usr/src/app/target_test_cases/failed_tests_f_oneway.txt
def f_oneway(*args): """Perform a 1-way ANOVA. The one-way ANOVA tests the null hypothesis that 2 or more groups have the same population mean. The test is applied to samples from two or more groups, possibly with differing sizes. Read more in the :ref:`User Guide <univariate_feature_selection>`. ...
f_oneway
repository-level
external
scikit-learn
295
sklearn/covariance/_robust_covariance.py
def fast_mcd( X, support_fraction=None, cov_computation_method=empirical_covariance, random_state=None, ): """Estimate the Minimum Covariance Determinant matrix. Read more in the :ref:`User Guide <robust_covariance>`. Parameters ---------- X : array-like of shape (n_samples, n_feat...
/usr/src/app/target_test_cases/failed_tests_fast_mcd.txt
def fast_mcd( X, support_fraction=None, cov_computation_method=empirical_covariance, random_state=None, ): """Estimate the Minimum Covariance Determinant matrix. Read more in the :ref:`User Guide <robust_covariance>`. Parameters ---------- X : array-like of shape (n_samples, n_feat...
fast_mcd
repository-level
external
scikit-learn
296
sklearn/linear_model/_sag.py
def get_auto_step_size( max_squared_sum, alpha_scaled, loss, fit_intercept, n_samples=None, is_saga=False ): """Compute automatic step size for SAG solver. The step size is set to 1 / (alpha_scaled + L + fit_intercept) where L is the max sum of squares for over all samples. Parameters --------...
/usr/src/app/target_test_cases/failed_tests_get_auto_step_size.txt
def get_auto_step_size( max_squared_sum, alpha_scaled, loss, fit_intercept, n_samples=None, is_saga=False ): """Compute automatic step size for SAG solver. The step size is set to 1 / (alpha_scaled + L + fit_intercept) where L is the max sum of squares for over all samples. Parameters --------...
get_auto_step_size
self-contained
non_external
scikit-learn
297
sklearn/cluster/_mean_shift.py
def get_bin_seeds(X, bin_size, min_bin_freq=1): """Find seeds for mean_shift. Finds seeds by first binning data onto a grid whose lines are spaced bin_size apart, and then choosing those bins with at least min_bin_freq points. Parameters ---------- X : array-like of shape (n_samples, n_fe...
/usr/src/app/target_test_cases/failed_tests_get_bin_seeds.txt
def get_bin_seeds(X, bin_size, min_bin_freq=1): """Find seeds for mean_shift. Finds seeds by first binning data onto a grid whose lines are spaced bin_size apart, and then choosing those bins with at least min_bin_freq points. Parameters ---------- X : array-like of shape (n_samples, n_fe...
get_bin_seeds
self-contained
external
scikit-learn
298
sklearn/utils/_chunking.py
def get_chunk_n_rows(row_bytes, *, max_n_rows=None, working_memory=None): """Calculate how many rows can be processed within `working_memory`. Parameters ---------- row_bytes : int The expected number of bytes of memory that will be consumed during the processing of each row. max_n_...
/usr/src/app/target_test_cases/failed_tests_get_chunk_n_rows.txt
def get_chunk_n_rows(row_bytes, *, max_n_rows=None, working_memory=None): """Calculate how many rows can be processed within `working_memory`. Parameters ---------- row_bytes : int The expected number of bytes of memory that will be consumed during the processing of each row. max_n_...
get_chunk_n_rows
repository-level
external
scikit-learn
299
sklearn/utils/sparsefuncs.py
def incr_mean_variance_axis(X, *, axis, last_mean, last_var, last_n, weights=None): """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....
/usr/src/app/target_test_cases/failed_tests_incr_mean_variance_axis.txt
def incr_mean_variance_axis(X, *, axis, last_mean, last_var, last_n, weights=None): """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....
incr_mean_variance_axis
repository-level
external
scikit-learn
300
sklearn/neighbors/_graph.py
def kneighbors_graph( X, n_neighbors, *, mode="connectivity", metric="minkowski", p=2, metric_params=None, include_self=False, n_jobs=None, ): """Compute the (weighted) graph of k-Neighbors for points in X. Read more in the :ref:`User Guide <unsupervised_neighbors>`. Pa...
/usr/src/app/target_test_cases/failed_tests_kneighbors_graph.txt
def kneighbors_graph( X, n_neighbors, *, mode="connectivity", metric="minkowski", p=2, metric_params=None, include_self=False, n_jobs=None, ): """Compute the (weighted) graph of k-Neighbors for points in X. Read more in the :ref:`User Guide <unsupervised_neighbors>`. Pa...
kneighbors_graph
repository-level
external
scikit-learn
301
sklearn/cluster/_agglomerative.py
def linkage_tree( X, connectivity=None, n_clusters=None, linkage="complete", affinity="euclidean", return_distance=False, ): """Linkage agglomerative clustering based on a Feature matrix. The inertia matrix uses a Heapq-based representation. This is the structured version, that tak...
/usr/src/app/target_test_cases/failed_tests_linkage_tree.txt
def linkage_tree( X, connectivity=None, n_clusters=None, linkage="complete", affinity="euclidean", return_distance=False, ): """Linkage agglomerative clustering based on a Feature matrix. The inertia matrix uses a Heapq-based representation. This is the structured version, that tak...
linkage_tree
repository-level
external
scikit-learn
302
sklearn/datasets/_arff_parser.py
def load_arff_from_gzip_file( gzip_file, parser, output_type, openml_columns_info, feature_names_to_select, target_names_to_select, shape=None, read_csv_kwargs=None, ): """Load a compressed ARFF file using a given parser. Parameters ---------- gzip_file : GzipFile instan...
/usr/src/app/target_test_cases/failed_tests_load_arff_from_gzip_file.txt
def load_arff_from_gzip_file( gzip_file, parser, output_type, openml_columns_info, feature_names_to_select, target_names_to_select, shape=None, read_csv_kwargs=None, ): """Load a compressed ARFF file using a given parser. Parameters ---------- gzip_file : GzipFile instan...
load_arff_from_gzip_file
file-level
non_external
scikit-learn
303
sklearn/datasets/_base.py
def load_diabetes(*, return_X_y=False, as_frame=False, scaled=True): """Load and return the diabetes dataset (regression). ============== ================== Samples total 442 Dimensionality 10 Features real, -.2 < x < .2 Targets integer 25 - 346 ============== ====...
/usr/src/app/target_test_cases/failed_tests_load_diabetes.txt
def load_diabetes(*, return_X_y=False, as_frame=False, scaled=True): """Load and return the diabetes dataset (regression). ============== ================== Samples total 442 Dimensionality 10 Features real, -.2 < x < .2 Targets integer 25 - 346 ============== ====...
load_diabetes
repository-level
non_external
scikit-learn
304
sklearn/neural_network/_base.py
def log_loss(y_true, y_prob): """Compute Logistic loss for classification. Parameters ---------- y_true : array-like or label indicator matrix Ground truth (correct) labels. y_prob : array-like of float, shape = (n_samples, n_classes) Predicted probabilities, as returned by a class...
/usr/src/app/target_test_cases/failed_tests_log_loss.txt
def log_loss(y_true, y_prob): """Compute Logistic loss for classification. Parameters ---------- y_true : array-like or label indicator matrix Ground truth (correct) labels. y_prob : array-like of float, shape = (n_samples, n_classes) Predicted probabilities, as returned by a class...
log_loss
self-contained
external
scikit-learn
305
sklearn/datasets/_samples_generator.py
def make_blobs( n_samples=100, n_features=2, *, centers=None, cluster_std=1.0, center_box=(-10.0, 10.0), shuffle=True, random_state=None, return_centers=False, ): """Generate isotropic Gaussian blobs for clustering. For an example of usage, see :ref:`sphx_glr_auto_exampl...
/usr/src/app/target_test_cases/failed_tests_make_blobs.txt
def make_blobs( n_samples=100, n_features=2, *, centers=None, cluster_std=1.0, center_box=(-10.0, 10.0), shuffle=True, random_state=None, return_centers=False, ): """Generate isotropic Gaussian blobs for clustering. For an example of usage, see :ref:`sphx_glr_auto_exampl...
make_blobs
repository-level
external
scikit-learn
306
sklearn/compose/_column_transformer.py
def make_column_transformer( *transformers, remainder="drop", sparse_threshold=0.3, n_jobs=None, verbose=False, verbose_feature_names_out=True, force_int_remainder_cols=True, ): """Construct a ColumnTransformer from the given transformers. This is a shorthand for the ColumnTransform...
/usr/src/app/target_test_cases/failed_tests_make_column_transformer.txt
def make_column_transformer( *transformers, remainder="drop", sparse_threshold=0.3, n_jobs=None, verbose=False, verbose_feature_names_out=True, force_int_remainder_cols=True, ): """Construct a ColumnTransformer from the given transformers. This is a shorthand for the ColumnTransform...
make_column_transformer
file-level
non_external
scikit-learn
307
sklearn/linear_model/_base.py
def make_dataset(X, y, sample_weight, random_state=None): """Create ``Dataset`` abstraction for sparse and dense inputs. This also returns the ``intercept_decay`` which is different for sparse datasets. Parameters ---------- X : array-like, shape (n_samples, n_features) Training data ...
/usr/src/app/target_test_cases/failed_tests_make_dataset.txt
def make_dataset(X, y, sample_weight, random_state=None): """Create ``Dataset`` abstraction for sparse and dense inputs. This also returns the ``intercept_decay`` which is different for sparse datasets. Parameters ---------- X : array-like, shape (n_samples, n_features) Training data ...
make_dataset
repository-level
external
scikit-learn
308
sklearn/utils/sparsefuncs.py
def min_max_axis(X, axis, ignore_nan=False): """Compute minimum and maximum along an axis on a CSR or CSC matrix. Optionally ignore NaN values. Parameters ---------- X : sparse matrix of shape (n_samples, n_features) Input data. It should be of CSR or CSC format. axis : {0, 1} ...
/usr/src/app/target_test_cases/failed_tests_min_max_axis.txt
def min_max_axis(X, axis, ignore_nan=False): """Compute minimum and maximum along an axis on a CSR or CSC matrix. Optionally ignore NaN values. Parameters ---------- X : sparse matrix of shape (n_samples, n_features) Input data. It should be of CSR or CSC format. axis : {0, 1} ...
min_max_axis
repository-level
external
scikit-learn
309
sklearn/utils/extmath.py
def softmax(X, copy=True): """ Calculate the softmax function. The softmax function is calculated by np.exp(X) / np.sum(np.exp(X), axis=1) This will cause overflow when large values are exponentiated. Hence the largest value in each row is subtracted from each data point to prevent this. ...
/usr/src/app/target_test_cases/failed_tests_softmax.txt
def softmax(X, copy=True): """ Calculate the softmax function. The softmax function is calculated by np.exp(X) / np.sum(np.exp(X), axis=1) This will cause overflow when large values are exponentiated. Hence the largest value in each row is subtracted from each data point to prevent this. ...
softmax
repository-level
external
scikit-learn
310
sklearn/metrics/_pairwise_distances_reduction/_dispatcher.py
def sqeuclidean_row_norms(X, num_threads): """Compute the squared euclidean norm of the rows of X in parallel. Parameters ---------- X : ndarray or CSR matrix of shape (n_samples, n_features) Input data. Must be c-contiguous. num_threads : int The number of OpenMP threads to use. ...
/usr/src/app/target_test_cases/failed_tests_sqeuclidean_row_norms.txt
def sqeuclidean_row_norms(X, num_threads): """Compute the squared euclidean norm of the rows of X in parallel. Parameters ---------- X : ndarray or CSR matrix of shape (n_samples, n_features) Input data. Must be c-contiguous. num_threads : int The number of OpenMP threads to use. ...
sqeuclidean_row_norms
self-contained
external
scikit-learn
311
sklearn/utils/extmath.py
def stable_cumsum(arr, axis=None, rtol=1e-05, atol=1e-08): """Use high precision for cumsum and check that final value matches sum. Warns if the final cumulative sum does not match the sum (up to the chosen tolerance). Parameters ---------- arr : array-like To be cumulatively summed as...
/usr/src/app/target_test_cases/failed_tests_stable_cumsum.txt
def stable_cumsum(arr, axis=None, rtol=1e-05, atol=1e-08): """Use high precision for cumsum and check that final value matches sum. Warns if the final cumulative sum does not match the sum (up to the chosen tolerance). Parameters ---------- arr : array-like To be cumulatively summed as...
stable_cumsum
self-contained
external
scikit-learn
312
sklearn/utils/extmath.py
def svd_flip(u, v, u_based_decision=True): """Sign correction to ensure deterministic output from SVD. Adjusts the columns of u and the rows of v such that the loadings in the columns in u that are largest in absolute value are always positive. If u_based_decision is False, then the same sign correcti...
/usr/src/app/target_test_cases/failed_tests_svd_flip.txt
def svd_flip(u, v, u_based_decision=True): """Sign correction to ensure deterministic output from SVD. Adjusts the columns of u and the rows of v such that the loadings in the columns in u that are largest in absolute value are always positive. If u_based_decision is False, then the same sign correcti...
svd_flip
repository-level
external
scikit-learn
313
sklearn/utils/multiclass.py
def type_of_target(y, input_name=""): """Determine the type of data indicated by the target. Note that this type is the most specific type that can be inferred. For example: * ``binary`` is more specific but compatible with ``multiclass``. * ``multiclass`` of integers is more specific but compatib...
/usr/src/app/target_test_cases/failed_tests_type_of_target.txt
def type_of_target(y, input_name=""): """Determine the type of data indicated by the target. Note that this type is the most specific type that can be inferred. For example: * ``binary`` is more specific but compatible with ``multiclass``. * ``multiclass`` of integers is more specific but compatib...
type_of_target
repository-level
external
astropy
0
astropy/modeling/physical_models.py
def evaluate(self, x, temperature, scale): """Evaluate the model. Parameters ---------- x : float, `~numpy.ndarray`, or `~astropy.units.Quantity` ['frequency'] Frequency at which to compute the blackbody. If no units are given, this defaults to Hz (or AA if `...
/usr/src/app/target_test_cases/failed_tests_BlackBody.evaluate.txt
def evaluate(self, x, temperature, scale): """Evaluate the model. Parameters ---------- x : float, `~numpy.ndarray`, or `~astropy.units.Quantity` ['frequency'] Frequency at which to compute the blackbody. If no units are given, this defaults to Hz (or AA if `...
BlackBody.evaluate
repository-level
external
astropy
1
astropy/timeseries/periodograms/bls/core.py
def autoperiod( self, duration, minimum_period=None, maximum_period=None, minimum_n_transit=3, frequency_factor=1.0, ): """Determine a suitable grid of periods. This method uses a set of heuristics to select a conservative period grid that...
/usr/src/app/target_test_cases/failed_tests_BoxLeastSquares.autoperiod.txt
def autoperiod( self, duration, minimum_period=None, maximum_period=None, minimum_n_transit=3, frequency_factor=1.0, ): """Determine a suitable grid of periods. This method uses a set of heuristics to select a conservative period grid that...
BoxLeastSquares.autoperiod
repository-level
external
astropy
2
astropy/timeseries/periodograms/bls/core.py
def compute_stats(self, period, duration, transit_time): """Compute descriptive statistics for a given transit model. These statistics are commonly used for vetting of transit candidates. Parameters ---------- period : float or `~astropy.units.Quantity` ['time'] ...
/usr/src/app/target_test_cases/failed_tests_BoxLeastSquares.compute_stats.txt
def compute_stats(self, period, duration, transit_time): """Compute descriptive statistics for a given transit model. These statistics are commonly used for vetting of transit candidates. Parameters ---------- period : float or `~astropy.units.Quantity` ['time'] ...
BoxLeastSquares.compute_stats
repository-level
external
astropy
3
astropy/timeseries/periodograms/bls/core.py
def model(self, t_model, period, duration, transit_time): """Compute the transit model at the given period, duration, and phase. Parameters ---------- t_model : array-like, `~astropy.units.Quantity`, or `~astropy.time.Time` Times at which to compute the model. pe...
/usr/src/app/target_test_cases/failed_tests_BoxLeastSquares.model.txt
def model(self, t_model, period, duration, transit_time): """Compute the transit model at the given period, duration, and phase. Parameters ---------- t_model : array-like, `~astropy.units.Quantity`, or `~astropy.time.Time` Times at which to compute the model. pe...
BoxLeastSquares.model
repository-level
external
astropy
4
astropy/timeseries/periodograms/bls/core.py
def power(self, period, duration, objective=None, method=None, oversample=10): """Compute the periodogram for a set of periods. Parameters ---------- period : array-like or `~astropy.units.Quantity` ['time'] The periods where the power should be computed duration...
/usr/src/app/target_test_cases/failed_tests_BoxLeastSquares.power.txt
def power(self, period, duration, objective=None, method=None, oversample=10): """Compute the periodogram for a set of periods. Parameters ---------- period : array-like or `~astropy.units.Quantity` ['time'] The periods where the power should be computed duration...
BoxLeastSquares.power
repository-level
external
astropy
5
astropy/timeseries/periodograms/bls/core.py
def transit_mask(self, t, period, duration, transit_time): """Compute which data points are in transit for a given parameter set. Parameters ---------- t : array-like or `~astropy.units.Quantity` ['time'] Times where the mask should be evaluated. period : float o...
/usr/src/app/target_test_cases/failed_tests_BoxLeastSquares.transit_mask.txt
def transit_mask(self, t, period, duration, transit_time): """Compute which data points are in transit for a given parameter set. Parameters ---------- t : array-like or `~astropy.units.Quantity` ['time'] Times where the mask should be evaluated. period : float o...
BoxLeastSquares.transit_mask
repository-level
external
astropy
6
astropy/nddata/ccddata.py
def to_hdu( self, hdu_mask="MASK", hdu_uncertainty="UNCERT", hdu_flags=None, wcs_relax=True, key_uncertainty_type="UTYPE", as_image_hdu=False, hdu_psf="PSFIMAGE", ): """Creates an HDUList object from a CCDData object. Parameters ...
/usr/src/app/target_test_cases/failed_tests_CCDData.to_hdu.txt
def to_hdu( self, hdu_mask="MASK", hdu_uncertainty="UNCERT", hdu_flags=None, wcs_relax=True, key_uncertainty_type="UTYPE", as_image_hdu=False, hdu_psf="PSFIMAGE", ): """Creates an HDUList object from a CCDData object. Parameters ...
CCDData.to_hdu
repository-level
external
astropy
7
astropy/uncertainty/core.py
def pdf_histogram(self, **kwargs): """ Compute histogram over the samples in the distribution. Parameters ---------- All keyword arguments are passed into `astropy.stats.histogram`. Note That some of these options may not be valid for some multidimensional di...
/usr/src/app/target_test_cases/failed_tests_Distribution.pdf_histogram.txt
def pdf_histogram(self, **kwargs): """ Compute histogram over the samples in the distribution. Parameters ---------- All keyword arguments are passed into `astropy.stats.histogram`. Note That some of these options may not be valid for some multidimensional di...
Distribution.pdf_histogram
repository-level
external