neulab/docprompting-conala huggingface dataset:
apply(X, check_input=True) [source]
 
Return the index of the leaf that each sample is predicted as.  New in version 0.17.   Parameters 
 
X{array-like, sparse matrix} of shape (n_samples, n_features) 

The input samples. Internally, it will be converted to dtype=np.float32 and if a sparse matrix is provided to a sparse csr_matrix.  
check_inputbool, default=True 

Allow to bypass several input checking. Don’t use this parameter unless you know what you do.    Returns 
 
X_leavesarray-like of shape (n_samples,) 

For each datapoint x in X, return the index of the leaf x ends up in. Leaves are numbered within [0; self.tree_.node_count), possibly with gaps in the numbering.
cost_complexity_pruning_path(X, y, sample_weight=None) [source]
 
Compute the pruning path during Minimal Cost-Complexity Pruning. See Minimal Cost-Complexity Pruning for details on the pruning process.  Parameters 
 
X{array-like, sparse matrix} of shape (n_samples, n_features) 

The training input samples. Internally, it will be converted to dtype=np.float32 and if a sparse matrix is provided to a sparse csc_matrix.  
yarray-like of shape (n_samples,) or (n_samples, n_outputs) 

The target values (class labels) as integers or strings.  
sample_weightarray-like of shape (n_samples,), default=None 

Sample weights. If None, then samples are equally weighted. Splits that would create child nodes with net zero or negative weight are ignored while searching for a split in each node. Splits are also ignored if they would result in any single class carrying a negative weight in either child node.    Returns 
 
ccp_pathBunch 

Dictionary-like object, with the following attributes.  
ccp_alphasndarray 

Effective alphas of subtree during pruning.  
impuritiesndarray 

Sum of the impurities of the subtree leaves for the corresponding alpha value in ccp_alphas.
decision_path(X, check_input=True) [source]
 
Return the decision path in the tree.  New in version 0.18.   Parameters 
 
X{array-like, sparse matrix} of shape (n_samples, n_features) 

The input samples. Internally, it will be converted to dtype=np.float32 and if a sparse matrix is provided to a sparse csr_matrix.  
check_inputbool, default=True 

Allow to bypass several input checking. Don’t use this parameter unless you know what you do.    Returns 
 
indicatorsparse matrix of shape (n_samples, n_nodes) 

Return a node indicator CSR matrix where non zero elements indicates that the samples goes through the nodes.
property feature_importances_  
Return the feature importances. The importance of a feature is computed as the (normalized) total reduction of the criterion brought by that feature. It is also known as the Gini importance. Warning: impurity-based feature importances can be misleading for high cardinality features (many unique values). See sklearn.inspection.permutation_importance as an alternative.  Returns 
 
feature_importances_ndarray of shape (n_features,) 

Normalized total reduction of criteria by feature (Gini importance).
fit(X, y, sample_weight=None, check_input=True, X_idx_sorted='deprecated') [source]
 
Build a decision tree classifier from the training set (X, y).  Parameters 
 
X{array-like, sparse matrix} of shape (n_samples, n_features) 

The training input samples. Internally, it will be converted to dtype=np.float32 and if a sparse matrix is provided to a sparse csc_matrix.  
yarray-like of shape (n_samples,) or (n_samples, n_outputs) 

The target values (class labels) as integers or strings.  
sample_weightarray-like of shape (n_samples,), default=None 

Sample weights. If None, then samples are equally weighted. Splits that would create child nodes with net zero or negative weight are ignored while searching for a split in each node. Splits are also ignored if they would result in any single class carrying a negative weight in either child node.  
check_inputbool, default=True 

Allow to bypass several input checking. Don’t use this parameter unless you know what you do.  
X_idx_sorteddeprecated, default=”deprecated” 

This parameter is deprecated and has no effect. It will be removed in 1.1 (renaming of 0.26).  Deprecated since version 0.24.     Returns 
 
selfDecisionTreeClassifier 

Fitted estimator.
get_depth() [source]
 
Return the depth of the decision tree. The depth of a tree is the maximum distance between the root and any leaf.  Returns 
 
self.tree_.max_depthint 

The maximum depth of the tree.
get_n_leaves() [source]
 
Return the number of leaves of the decision tree.  Returns 
 
self.tree_.n_leavesint 

Number of leaves.
predict(X, check_input=True) [source]
 
Predict class or regression value for X. For a classification model, the predicted class for each sample in X is returned. For a regression model, the predicted value based on X is returned.  Parameters 
 
X{array-like, sparse matrix} of shape (n_samples, n_features) 

The input samples. Internally, it will be converted to dtype=np.float32 and if a sparse matrix is provided to a sparse csr_matrix.  
check_inputbool, default=True 

Allow to bypass several input checking. Don’t use this parameter unless you know what you do.    Returns 
 
yarray-like of shape (n_samples,) or (n_samples, n_outputs) 

The predicted classes, or the predict values.
predict_log_proba(X) [source]
 
Predict class log-probabilities of the input samples X.  Parameters 
 
X{array-like, sparse matrix} of shape (n_samples, n_features) 

The input samples. Internally, it will be converted to dtype=np.float32 and if a sparse matrix is provided to a sparse csr_matrix.    Returns 
 
probandarray of shape (n_samples, n_classes) or list of n_outputs such arrays if n_outputs > 1 

The class log-probabilities of the input samples. The order of the classes corresponds to that in the attribute classes_.
predict_proba(X, check_input=True) [source]
 
Predict class probabilities of the input samples X. The predicted class probability is the fraction of samples of the same class in a leaf.  Parameters 
 
X{array-like, sparse matrix} of shape (n_samples, n_features) 

The input samples. Internally, it will be converted to dtype=np.float32 and if a sparse matrix is provided to a sparse csr_matrix.  
check_inputbool, default=True 

Allow to bypass several input checking. Don’t use this parameter unless you know what you do.    Returns 
 
probandarray of shape (n_samples, n_classes) or list of n_outputs such arrays if n_outputs > 1 

The class probabilities of the input samples. The order of the classes corresponds to that in the attribute classes_.
fit(X, y, sample_weight=None, check_input=True, X_idx_sorted='deprecated') [source]
 
Build a decision tree regressor from the training set (X, y).  Parameters 
 
X{array-like, sparse matrix} of shape (n_samples, n_features) 

The training input samples. Internally, it will be converted to dtype=np.float32 and if a sparse matrix is provided to a sparse csc_matrix.  
yarray-like of shape (n_samples,) or (n_samples, n_outputs) 

The target values (real numbers). Use dtype=np.float64 and order='C' for maximum efficiency.  
sample_weightarray-like of shape (n_samples,), default=None 

Sample weights. If None, then samples are equally weighted. Splits that would create child nodes with net zero or negative weight are ignored while searching for a split in each node.  
check_inputbool, default=True 

Allow to bypass several input checking. Don’t use this parameter unless you know what you do.  
X_idx_sorteddeprecated, default=”deprecated” 

This parameter is deprecated and has no effect. It will be removed in 1.1 (renaming of 0.26).  Deprecated since version 0.24.     Returns 
 
selfDecisionTreeRegressor 

Fitted estimator.
sklearn.tree.export_text(decision_tree, *, feature_names=None, max_depth=10, spacing=3, decimals=2, show_weights=False) [source]
 
Build a text report showing the rules of a decision tree. Note that backwards compatibility may not be supported.  Parameters 
 
decision_treeobject 

The decision tree estimator to be exported. It can be an instance of DecisionTreeClassifier or DecisionTreeRegressor.  
feature_nameslist of str, default=None 

A list of length n_features containing the feature names. If None generic names will be used (“feature_0”, “feature_1”, …).  
max_depthint, default=10 

Only the first max_depth levels of the tree are exported. Truncated branches will be marked with “…”.  
spacingint, default=3 

Number of spaces between edges. The higher it is, the wider the result.  
decimalsint, default=2 

Number of decimal digits to display.  
show_weightsbool, default=False 

If true the classification weights will be exported on each leaf. The classification weights are the number of samples each class.    Returns 
 
reportstring 

Text summary of all the rules in the decision tree.     Examples >>> from sklearn.datasets import load_iris
>>> from sklearn.tree import DecisionTreeClassifier
>>> from sklearn.tree import export_text
>>> iris = load_iris()
>>> X = iris['data']
>>> y = iris['target']
>>> decision_tree = DecisionTreeClassifier(random_state=0, max_depth=2)
>>> decision_tree = decision_tree.fit(X, y)
>>> r = export_text(decision_tree, feature_names=iris['feature_names'])
>>> print(r)
|--- petal width (cm) <= 0.80
|   |--- class: 0
|--- petal width (cm) >  0.80
|   |--- petal width (cm) <= 1.75
|   |   |--- class: 1
|   |--- petal width (cm) >  1.75
|   |   |--- class: 2
sklearn.tree.plot_tree(decision_tree, *, max_depth=None, feature_names=None, class_names=None, label='all', filled=False, impurity=True, node_ids=False, proportion=False, rotate='deprecated', rounded=False, precision=3, ax=None, fontsize=None) [source]
 
Plot a decision tree. The sample counts that are shown are weighted with any sample_weights that might be present. The visualization is fit automatically to the size of the axis. Use the figsize or dpi arguments of plt.figure to control the size of the rendering. Read more in the User Guide.  New in version 0.21.   Parameters 
 
decision_treedecision tree regressor or classifier 

The decision tree to be plotted.  
max_depthint, default=None 

The maximum depth of the representation. If None, the tree is fully generated.  
feature_nameslist of strings, default=None 

Names of each of the features. If None, generic names will be used (“X[0]”, “X[1]”, …).  
class_nameslist of str or bool, default=None 

Names of each of the target classes in ascending numerical order. Only relevant for classification and not supported for multi-output. If True, shows a symbolic representation of the class name.  
label{‘all’, ‘root’, ‘none’}, default=’all’ 

Whether to show informative labels for impurity, etc. Options include ‘all’ to show at every node, ‘root’ to show only at the top root node, or ‘none’ to not show at any node.  
filledbool, default=False 

When set to True, paint nodes to indicate majority class for classification, extremity of values for regression, or purity of node for multi-output.  
impuritybool, default=True 

When set to True, show the impurity at each node.  
node_idsbool, default=False 

When set to True, show the ID number on each node.  
proportionbool, default=False 

When set to True, change the display of ‘values’ and/or ‘samples’ to be proportions and percentages respectively.  
rotatebool, default=False 

This parameter has no effect on the matplotlib tree visualisation and it is kept here for backward compatibility.  Deprecated since version 0.23: rotate is deprecated in 0.23 and will be removed in 1.0 (renaming of 0.25).   
roundedbool, default=False 

When set to True, draw node boxes with rounded corners and use Helvetica fonts instead of Times-Roman.  
precisionint, default=3 

Number of digits of precision for floating point in the values of impurity, threshold and value attributes of each node.  
axmatplotlib axis, default=None 

Axes to plot to. If None, use current axis. Any previous content is cleared.  
fontsizeint, default=None 

Size of text font. If None, determined automatically to fit figure.    Returns 
 
annotationslist of artists 

List containing the artists for the annotation boxes making up the tree.     Examples >>> from sklearn.datasets import load_iris
>>> from sklearn import tree
 >>> clf = tree.DecisionTreeClassifier(random_state=0)
>>> iris = load_iris()
 >>> clf = clf.fit(iris.data, iris.target)
>>> tree.plot_tree(clf)  
[Text(251.5,345.217,'X[3] <= 0.8...
sklearn.utils.all_estimators(type_filter=None) [source]
 
Get a list of all estimators from sklearn. This function crawls the module and gets all classes that inherit from BaseEstimator. Classes that are defined in test-modules are not included.  Parameters 
 
type_filter{“classifier”, “regressor”, “cluster”, “transformer”} or list of such str, default=None 

Which kind of estimators should be returned. If None, no filter is applied and all estimators are returned. Possible values are ‘classifier’, ‘regressor’, ‘cluster’ and ‘transformer’ to get estimators only of these specific types, or a list of these to get the estimators that fit at least one of the types.    Returns 
 
estimatorslist of tuples 

List of (name, class), where name is the class name as string and class is the actuall type of the class.
sklearn.utils.arrayfuncs.min_pos()  
Find the minimum value of an array over positive values Returns a huge value if none of the values are positive
sklearn.utils.assert_all_finite(X, *, allow_nan=False) [source]
 
Throw a ValueError if X contains NaN or infinity.  Parameters 
 
X{ndarray, sparse matrix} 

allow_nanbool, default=False
sklearn.utils.as_float_array(X, *, copy=True, force_all_finite=True) [source]
 
Converts an array-like to an array of floats. The new dtype will be np.float32 or np.float64, depending on the original type. The function can create a copy or modify the argument depending on the argument copy.  Parameters 
 
X{array-like, sparse matrix} 

copybool, default=True 

If True, a copy of X will be created. If False, a copy may still be returned if X’s dtype is not a floating point type.  
force_all_finitebool or ‘allow-nan’, default=True 

Whether to raise an error on np.inf, np.nan, pd.NA in X. The possibilities are:  True: Force all values of X to be finite. False: accepts np.inf, np.nan, pd.NA in X. ‘allow-nan’: accepts only np.nan and pd.NA values in X. Values cannot be infinite.   New in version 0.20: force_all_finite accepts the string 'allow-nan'.   Changed in version 0.23: Accepts pd.NA and converts it into np.nan     Returns 
 
XT{ndarray, sparse matrix} 

An array of type float.
sklearn.utils.Bunch(**kwargs) [source]
 
Container object exposing keys as attributes. Bunch objects are sometimes used as an output for functions and methods. They extend dictionaries by enabling values to be accessed by key, bunch["value_key"], or by an attribute, bunch.value_key. Examples >>> b = Bunch(a=1, b=2)
>>> b['b']
2
>>> b.b
2
>>> b.a = 3
>>> b['a']
3
>>> b.c = 6
>>> b['c']
6
sklearn.utils.check_consistent_length(*arrays) [source]
 
Check that all arrays have consistent first dimensions. Checks whether all objects in arrays have the same shape or length.  Parameters 
 
*arrayslist or tuple of input objects. 

Objects that will be checked for consistent length.
sklearn.utils.check_random_state(seed) [source]
 
Turn seed into a np.random.RandomState instance  Parameters 
 
seedNone, int or instance of RandomState 

If seed is None, return the RandomState singleton used by np.random. If seed is an int, return a new RandomState instance seeded with seed. If seed is already a RandomState instance, return it. Otherwise raise ValueError.
sklearn.utils.check_scalar(x, name, target_type, *, min_val=None, max_val=None) [source]
 
Validate scalar parameters type and value.  Parameters 
 
xobject 

The scalar parameter to validate.  
namestr 

The name of the parameter to be printed in error messages.  
target_typetype or tuple 

Acceptable data types for the parameter.  
min_valfloat or int, default=None 

The minimum valid value the parameter can take. If None (default) it is implied that the parameter does not have a lower bound.  
max_valfloat or int, default=None 

The maximum valid value the parameter can take. If None (default) it is implied that the parameter does not have an upper bound.    Raises 
 TypeError

If the parameter’s type does not match the desired type.  ValueError

If the parameter’s value violates the given bounds.
sklearn.utils.class_weight.compute_class_weight(class_weight, *, classes, y) [source]
 
Estimate class weights for unbalanced datasets.  Parameters 
 
class_weightdict, ‘balanced’ or None 

If ‘balanced’, class weights will be given by n_samples / (n_classes * np.bincount(y)). If a dictionary is given, keys are classes and values are corresponding class weights. If None is given, the class weights will be uniform.  
classesndarray 

Array of the classes occurring in the data, as given by np.unique(y_org) with y_org the original class labels.  
yarray-like of shape (n_samples,) 

Array of original class labels per sample.    Returns 
 
class_weight_vectndarray of shape (n_classes,) 

Array with class_weight_vect[i] the weight for i-th class.     References The “balanced” heuristic is inspired by Logistic Regression in Rare Events Data, King, Zen, 2001.
sklearn.utils.class_weight.compute_sample_weight(class_weight, y, *, indices=None) [source]
 
Estimate sample weights by class for unbalanced datasets.  Parameters 
 
class_weightdict, list of dicts, “balanced”, or None 

Weights associated with classes in the form {class_label: weight}. If not given, all classes are supposed to have weight one. For multi-output problems, a list of dicts can be provided in the same order as the columns of y. Note that for multioutput (including multilabel) weights should be defined for each class of every column in its own dict. For example, for four-class multilabel classification weights should be [{0: 1, 1: 1}, {0: 1, 1: 5}, {0: 1, 1: 1}, {0: 1, 1: 1}] instead of [{1:1}, {2:5}, {3:1}, {4:1}]. The “balanced” mode uses the values of y to automatically adjust weights inversely proportional to class frequencies in the input data: n_samples / (n_classes * np.bincount(y)). For multi-output, the weights of each column of y will be multiplied.  
yarray-like of shape (n_samples,) or (n_samples, n_outputs) 

Array of original class labels per sample.  
indicesarray-like of shape (n_subsample,), default=None 

Array of indices to be used in a subsample. Can be of length less than n_samples in the case of a subsample, or equal to n_samples in the case of a bootstrap subsample with repeated indices. If None, the sample weight will be calculated over the full sample. Only “balanced” is supported for class_weight if this is provided.    Returns 
 
sample_weight_vectndarray of shape (n_samples,) 

Array with sample weights as applied to the original y.
sklearn.utils.deprecated(extra='') [source]
 
Decorator to mark a function or class as deprecated. Issue a warning when the function is called/the class is instantiated and adds a warning to the docstring. The optional extra argument will be appended to the deprecation message and the docstring. Note: to use this with the default value for extra, put in an empty of parentheses: >>> from sklearn.utils import deprecated
>>> deprecated()
<sklearn.utils.deprecation.deprecated object at ...>
 >>> @deprecated()
... def some_function(): pass
  Parameters 
 
extrastr, default=’’ 

To be added to the deprecation messages.
sklearn.utils.estimator_checks.check_estimator(Estimator, generate_only=False) [source]
 
Check if estimator adheres to scikit-learn conventions. This estimator will run an extensive test-suite for input validation, shapes, etc, making sure that the estimator complies with scikit-learn conventions as detailed in Rolling your own estimator. Additional tests for classifiers, regressors, clustering or transformers will be run if the Estimator class inherits from the corresponding mixin from sklearn.base. Setting generate_only=True returns a generator that yields (estimator, check) tuples where the check can be called independently from each other, i.e. check(estimator). This allows all checks to be run independently and report the checks that are failing. scikit-learn provides a pytest specific decorator, parametrize_with_checks, making it easier to test multiple estimators.  Parameters 
 
Estimatorestimator object 

Estimator instance to check.  Changed in version 0.24: Passing a class was deprecated in version 0.23, and support for classes was removed in 0.24.   
generate_onlybool, default=False 

When False, checks are evaluated when check_estimator is called. When True, check_estimator returns a generator that yields (estimator, check) tuples. The check is run by calling check(estimator).  New in version 0.22.     Returns 
 
checks_generatorgenerator 

Generator that yields (estimator, check) tuples. Returned when generate_only=True.
sklearn.utils.estimator_checks.parametrize_with_checks(estimators) [source]
 
Pytest specific decorator for parametrizing estimator checks. The id of each check is set to be a pprint version of the estimator and the name of the check with its keyword arguments. This allows to use pytest -k to specify which tests to run: pytest test_check_estimators.py -k check_estimators_fit_returns_self
  Parameters 
 
estimatorslist of estimators instances 

Estimators to generated checks for.  Changed in version 0.24: Passing a class was deprecated in version 0.23, and support for classes was removed in 0.24. Pass an instance instead.   New in version 0.24.     Returns 
 
decoratorpytest.mark.parametrize 
   Examples >>> from sklearn.utils.estimator_checks import parametrize_with_checks
>>> from sklearn.linear_model import LogisticRegression
>>> from sklearn.tree import DecisionTreeRegressor
 >>> @parametrize_with_checks([LogisticRegression(),
...                           DecisionTreeRegressor()])
... def test_sklearn_compatible_estimator(estimator, check):
...     check(estimator)
sklearn.utils.estimator_html_repr(estimator) [source]
 
Build a HTML representation of an estimator. Read more in the User Guide.  Parameters 
 
estimatorestimator object 

The estimator to visualize.    Returns 
 html: str

HTML representation of estimator.
sklearn.utils.extmath.density(w, **kwargs) [source]
 
Compute density of a sparse vector.  Parameters 
 
warray-like 

The sparse vector.    Returns 
 float

The density of w, between 0 and 1.
sklearn.utils.extmath.fast_logdet(A) [source]
 
Compute log(det(A)) for A symmetric. Equivalent to : np.log(nl.det(A)) but more robust. It returns -Inf if det(A) is non positive or is not defined.  Parameters 
 
Aarray-like 

The matrix.
sklearn.utils.extmath.randomized_range_finder(A, *, size, n_iter, power_iteration_normalizer='auto', random_state=None) [source]
 
Computes an orthonormal matrix whose range approximates the range of A.  Parameters 
 
A2D array 

The input data matrix.  
sizeint 

Size of the return array.  
n_iterint 

Number of power iterations used to stabilize the result.  
power_iteration_normalizer{‘auto’, ‘QR’, ‘LU’, ‘none’}, default=’auto’ 

Whether the power iterations are normalized with step-by-step QR factorization (the slowest but most accurate), ‘none’ (the fastest but numerically unstable when n_iter is large, e.g. typically 5 or larger), or ‘LU’ factorization (numerically stable but can lose slightly in accuracy). The ‘auto’ mode applies no normalization if n_iter <= 2 and switches to LU otherwise.  New in version 0.18.   
random_stateint, RandomState instance or None, default=None 

The seed of the pseudo random number generator to use when shuffling the data, i.e. getting the random vectors to initialize the algorithm. Pass an int for reproducible results across multiple function calls. See Glossary.    Returns 
 
Qndarray 

A (size x size) projection matrix, the range of which approximates well the range of the input matrix A.     Notes Follows Algorithm 4.3 of Finding structure with randomness: Stochastic algorithms for constructing approximate matrix decompositions Halko, et al., 2009 (arXiv:909) https://arxiv.org/pdf/0909.4061.pdf An implementation of a randomized algorithm for principal component analysis A. Szlam et al. 2014