neulab/docprompting-conala huggingface dataset:
partial_fit(X, y, classes=None, sample_weight=None) [source]
 
Incremental fit on a batch of samples. This method is expected to be called several times consecutively on different chunks of a dataset so as to implement out-of-core or online learning. This is especially useful when the whole dataset is too big to fit in memory at once. This method has some performance and numerical stability overhead, hence it is better to call partial_fit on chunks of data that are as large as possible (as long as fitting in the memory budget) to hide the overhead.  Parameters 
 
Xarray-like of shape (n_samples, n_features) 

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

Target values.  
classesarray-like of shape (n_classes,), default=None 

List of all the classes that can possibly appear in the y vector. Must be provided at the first call to partial_fit, can be omitted in subsequent calls.  
sample_weightarray-like of shape (n_samples,), default=None 

Weights applied to individual samples (1. for unweighted).  New in version 0.17.     Returns 
 
selfobject
get_arrays(self)  
Get data and node arrays.  Returns 
 arrays: tuple of array

Arrays for storing tree data, index, node data and node bounds.
get_n_calls(self)  
Get number of calls.  Returns 
 n_calls: int

number of distance computation calls
get_tree_stats(self)  
Get tree status.  Returns 
 tree_stats: tuple of int

(number of trims, number of leaves, number of splits)
kernel_density(self, X, h, kernel='gaussian', atol=0, rtol=1e-08, breadth_first=True, return_log=False)  
Compute the kernel density estimate at points X with the given kernel, using the distance metric specified at tree creation.  Parameters 
 
Xarray-like of shape (n_samples, n_features) 

An array of points to query. Last dimension should match dimension of training data.  
hfloat 

the bandwidth of the kernel  
kernelstr, default=”gaussian” 

specify the kernel to use. Options are - ‘gaussian’ - ‘tophat’ - ‘epanechnikov’ - ‘exponential’ - ‘linear’ - ‘cosine’ Default is kernel = ‘gaussian’  
atol, rtolfloat, default=0, 1e-8 

Specify the desired relative and absolute tolerance of the result. If the true result is K_true, then the returned result K_ret satisfies abs(K_true - K_ret) < atol + rtol * K_ret The default is zero (i.e. machine precision) for both.  
breadth_firstbool, default=False 

If True, use a breadth-first search. If False (default) use a depth-first search. Breadth-first is generally faster for compact kernels and/or high tolerances.  
return_logbool, default=False 

Return the logarithm of the result. This can be more accurate than returning the result itself for narrow kernels.    Returns 
 
densityndarray of shape X.shape[:-1] 

The array of (log)-density evaluations
query(X, k=1, return_distance=True, dualtree=False, breadth_first=False)  
query the tree for the k nearest neighbors  Parameters 
 
Xarray-like of shape (n_samples, n_features) 

An array of points to query  
kint, default=1 

The number of nearest neighbors to return  
return_distancebool, default=True 

if True, return a tuple (d, i) of distances and indices if False, return array i  
dualtreebool, default=False 

if True, use the dual tree formalism for the query: a tree is built for the query points, and the pair of trees is used to efficiently search this space. This can lead to better performance as the number of points grows large.  
breadth_firstbool, default=False 

if True, then query the nodes in a breadth-first manner. Otherwise, query the nodes in a depth-first manner.  
sort_resultsbool, default=True 

if True, then distances and indices of each point are sorted on return, so that the first column contains the closest points. Otherwise, neighbors are returned in an arbitrary order.    Returns 
 
iif return_distance == False 

(d,i)if return_distance == True 

dndarray of shape X.shape[:-1] + (k,), dtype=double 

Each entry gives the list of distances to the neighbors of the corresponding point.  
indarray of shape X.shape[:-1] + (k,), dtype=int 

Each entry gives the list of indices of neighbors of the corresponding point.
query_radius(X, r, return_distance=False, count_only=False, sort_results=False)  
query the tree for neighbors within a radius r  Parameters 
 
Xarray-like of shape (n_samples, n_features) 

An array of points to query  
rdistance within which neighbors are returned 

r can be a single value, or an array of values of shape x.shape[:-1] if different radii are desired for each point.  
return_distancebool, default=False 

if True, return distances to neighbors of each point if False, return only neighbors Note that unlike the query() method, setting return_distance=True here adds to the computation time. Not all distances need to be calculated explicitly for return_distance=False. Results are not sorted by default: see sort_results keyword.  
count_onlybool, default=False 

if True, return only the count of points within distance r if False, return the indices of all points within distance r If return_distance==True, setting count_only=True will result in an error.  
sort_resultsbool, default=False 

if True, the distances and indices will be sorted before being returned. If False, the results will not be sorted. If return_distance == False, setting sort_results = True will result in an error.    Returns 
 
countif count_only == True 

indif count_only == False and return_distance == False 

(ind, dist)if count_only == False and return_distance == True 

countndarray of shape X.shape[:-1], dtype=int 

Each entry gives the number of neighbors within a distance r of the corresponding point.  
indndarray of shape X.shape[:-1], dtype=object 

Each element is a numpy integer array listing the indices of neighbors of the corresponding point. Note that unlike the results of a k-neighbors query, the returned neighbors are not sorted by distance by default.  
distndarray of shape X.shape[:-1], dtype=object 

Each element is a numpy double array listing the distances corresponding to indices in i.
two_point_correlation(X, r, dualtree=False)  
Compute the two-point correlation function  Parameters 
 
Xarray-like of shape (n_samples, n_features) 

An array of points to query. Last dimension should match dimension of training data.  
rarray-like 

A one-dimensional array of distances  
dualtreebool, default=False 

If True, use a dualtree algorithm. Otherwise, use a single-tree algorithm. Dual tree algorithms can have better scaling for large N.    Returns 
 
countsndarray 

counts[i] contains the number of pairs of points with distance less than or equal to r[i]
dist_to_rdist()  
Convert the true distance to the reduced distance. The reduced distance, defined for some metrics, is a computationally more efficient measure which preserves the rank of the true distance. For example, in the Euclidean distance metric, the reduced distance is the squared-euclidean distance.
get_metric()  
Get the given distance metric from the string identifier. See the docstring of DistanceMetric for a list of available metrics.  Parameters 
 
metricstring or class name 

The distance metric to use  **kwargs

additional arguments will be passed to the requested metric
pairwise()  
Compute the pairwise distances between X and Y This is a convenience routine for the sake of testing. For many metrics, the utilities in scipy.spatial.distance.cdist and scipy.spatial.distance.pdist will be faster.  Parameters 
 
Xarray-like 

Array of shape (Nx, D), representing Nx points in D dimensions.  
Yarray-like (optional) 

Array of shape (Ny, D), representing Ny points in D dimensions. If not specified, then Y=X.  Returns
——-

distndarray 

The shape (Nx, Ny) array of pairwise distances between points in X and Y.
rdist_to_dist()  
Convert the Reduced distance to the true distance. The reduced distance, defined for some metrics, is a computationally more efficient measure which preserves the rank of the true distance. For example, in the Euclidean distance metric, the reduced distance is the squared-euclidean distance.
fit(X, y=None, sample_weight=None) [source]
 
Fit the Kernel Density model on the data.  Parameters 
 
Xarray-like of shape (n_samples, n_features) 

List of n_features-dimensional data points. Each row corresponds to a single data point.  
yNone 

Ignored. This parameter exists only for compatibility with Pipeline.  
sample_weightarray-like of shape (n_samples,), default=None 

List of sample weights attached to the data X.  New in version 0.20.     Returns 
 
selfobject 

Returns instance of object.
sample(n_samples=1, random_state=None) [source]
 
Generate random samples from the model. Currently, this is implemented only for gaussian and tophat kernels.  Parameters 
 
n_samplesint, default=1 

Number of samples to generate.  
random_stateint, RandomState instance or None, default=None 

Determines random number generation used to generate random samples. Pass an int for reproducible results across multiple function calls. See :term: Glossary <random_state>.    Returns 
 
Xarray-like of shape (n_samples, n_features) 

List of samples.
score(X, y=None) [source]
 
Compute the total log probability density under the model.  Parameters 
 
Xarray-like of shape (n_samples, n_features) 

List of n_features-dimensional data points. Each row corresponds to a single data point.  
yNone 

Ignored. This parameter exists only for compatibility with Pipeline.    Returns 
 
logprobfloat 

Total log-likelihood of the data in X. This is normalized to be a probability density, so the value will be low for high-dimensional data.
score_samples(X) [source]
 
Evaluate the log density model on the data.  Parameters 
 
Xarray-like of shape (n_samples, n_features) 

An array of points to query. Last dimension should match dimension of training data (n_features).    Returns 
 
densityndarray of shape (n_samples,) 

The array of log(density) evaluations. These are normalized to be probability densities, so values will be low for high-dimensional data.
fit(X, y) [source]
 
Fit the k-nearest neighbors classifier from the training dataset.  Parameters 
 
X{array-like, sparse matrix} of shape (n_samples, n_features) or (n_samples, n_samples) if metric=’precomputed’ 

Training data.  
y{array-like, sparse matrix} of shape (n_samples,) or (n_samples, n_outputs) 

Target values.    Returns 
 
selfKNeighborsClassifier 

The fitted k-nearest neighbors classifier.
kneighbors(X=None, n_neighbors=None, return_distance=True) [source]
 
Finds the K-neighbors of a point. Returns indices of and distances to the neighbors of each point.  Parameters 
 
Xarray-like, shape (n_queries, n_features), or (n_queries, n_indexed) if metric == ‘precomputed’, default=None 

The query point or points. If not provided, neighbors of each indexed point are returned. In this case, the query point is not considered its own neighbor.  
n_neighborsint, default=None 

Number of neighbors required for each sample. The default is the value passed to the constructor.  
return_distancebool, default=True 

Whether or not to return the distances.    Returns 
 
neigh_distndarray of shape (n_queries, n_neighbors) 

Array representing the lengths to points, only present if return_distance=True  
neigh_indndarray of shape (n_queries, n_neighbors) 

Indices of the nearest points in the population matrix.     Examples In the following example, we construct a NearestNeighbors class from an array representing our data set and ask who’s the closest point to [1,1,1] >>> samples = [[0., 0., 0.], [0., .5, 0.], [1., 1., .5]]
>>> from sklearn.neighbors import NearestNeighbors
>>> neigh = NearestNeighbors(n_neighbors=1)
>>> neigh.fit(samples)
NearestNeighbors(n_neighbors=1)
>>> print(neigh.kneighbors([[1., 1., 1.]]))
(array([[0.5]]), array([[2]]))
 As you can see, it returns [[0.5]], and [[2]], which means that the element is at distance 0.5 and is the third element of samples (indexes start at 0). You can also query for multiple points: >>> X = [[0., 1., 0.], [1., 0., 1.]]
>>> neigh.kneighbors(X, return_distance=False)
array([[1],
       [2]]...)
kneighbors_graph(X=None, n_neighbors=None, mode='connectivity') [source]
 
Computes the (weighted) graph of k-Neighbors for points in X  Parameters 
 
Xarray-like of shape (n_queries, n_features), or (n_queries, n_indexed) if metric == ‘precomputed’, default=None 

The query point or points. If not provided, neighbors of each indexed point are returned. In this case, the query point is not considered its own neighbor. For metric='precomputed' the shape should be (n_queries, n_indexed). Otherwise the shape should be (n_queries, n_features).  
n_neighborsint, default=None 

Number of neighbors for each sample. The default is the value passed to the constructor.  
mode{‘connectivity’, ‘distance’}, default=’connectivity’ 

Type of returned matrix: ‘connectivity’ will return the connectivity matrix with ones and zeros, in ‘distance’ the edges are Euclidean distance between points.    Returns 
 
Asparse-matrix of shape (n_queries, n_samples_fit) 

n_samples_fit is the number of samples in the fitted data A[i, j] is assigned the weight of edge that connects i to j. The matrix is of CSR format.      See also  
NearestNeighbors.radius_neighbors_graph

  Examples >>> X = [[0], [3], [1]]
>>> from sklearn.neighbors import NearestNeighbors
>>> neigh = NearestNeighbors(n_neighbors=2)
>>> neigh.fit(X)
NearestNeighbors(n_neighbors=2)
>>> A = neigh.kneighbors_graph(X)
>>> A.toarray()
array([[1., 0., 1.],
       [0., 1., 1.],
       [1., 0., 1.]])
predict(X) [source]
 
Predict the class labels for the provided data.  Parameters 
 
Xarray-like of shape (n_queries, n_features), or (n_queries, n_indexed) if metric == ‘precomputed’ 

Test samples.    Returns 
 
yndarray of shape (n_queries,) or (n_queries, n_outputs) 

Class labels for each data sample.
predict_proba(X) [source]
 
Return probability estimates for the test data X.  Parameters 
 
Xarray-like of shape (n_queries, n_features), or (n_queries, n_indexed) if metric == ‘precomputed’ 

Test samples.    Returns 
 
pndarray of shape (n_queries, n_classes), or a list of n_outputs 

of such arrays if n_outputs > 1. The class probabilities of the input samples. Classes are ordered by lexicographic order.
fit(X, y) [source]
 
Fit the k-nearest neighbors regressor from the training dataset.  Parameters 
 
X{array-like, sparse matrix} of shape (n_samples, n_features) or (n_samples, n_samples) if metric=’precomputed’ 

Training data.  
y{array-like, sparse matrix} of shape (n_samples,) or (n_samples, n_outputs) 

Target values.    Returns 
 
selfKNeighborsRegressor 

The fitted k-nearest neighbors regressor.
predict(X) [source]
 
Predict the target for the provided data  Parameters 
 
Xarray-like of shape (n_queries, n_features), or (n_queries, n_indexed) if metric == ‘precomputed’ 

Test samples.    Returns 
 
yndarray of shape (n_queries,) or (n_queries, n_outputs), dtype=int 

Target values.
fit(X, y=None) [source]
 
Fit the k-nearest neighbors transformer from the training dataset.  Parameters 
 
X{array-like, sparse matrix} of shape (n_samples, n_features) or (n_samples, n_samples) if metric=’precomputed’ 

Training data.    Returns 
 
selfKNeighborsTransformer 

The fitted k-nearest neighbors transformer.
fit_transform(X, y=None) [source]
 
Fit to data, then transform it. Fits transformer to X and y with optional parameters fit_params and returns a transformed version of X.  Parameters 
 
Xarray-like of shape (n_samples, n_features) 

Training set.  
yignored 
  Returns 
 
Xtsparse matrix of shape (n_samples, n_samples) 

Xt[i, j] is assigned the weight of edge that connects i to j. Only the neighbors have an explicit value. The diagonal is always explicit. The matrix is of CSR format.
transform(X) [source]
 
Computes the (weighted) graph of Neighbors for points in X  Parameters 
 
Xarray-like of shape (n_samples_transform, n_features) 

Sample data.    Returns 
 
Xtsparse matrix of shape (n_samples_transform, n_samples_fit) 

Xt[i, j] is assigned the weight of edge that connects i to j. Only the neighbors have an explicit value. The diagonal is always explicit. The matrix is of CSR format.
sklearn.neighbors.kneighbors_graph(X, n_neighbors, *, mode='connectivity', metric='minkowski', p=2, metric_params=None, include_self=False, n_jobs=None) [source]
 
Computes the (weighted) graph of k-Neighbors for points in X Read more in the User Guide.  Parameters 
 
Xarray-like of shape (n_samples, n_features) or BallTree 

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

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

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

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

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

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

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

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

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

  Examples >>> X = [[0], [3], [1]]
>>> from sklearn.neighbors import kneighbors_graph
>>> A = kneighbors_graph(X, 2, mode='connectivity', include_self=True)
>>> A.toarray()
array([[1., 0., 1.],
       [0., 1., 1.],
       [1., 0., 1.]])
property decision_function  
Shifted opposite of the Local Outlier Factor of X. Bigger is better, i.e. large values correspond to inliers. Only available for novelty detection (when novelty is set to True). The shift offset allows a zero threshold for being an outlier. The argument X is supposed to contain new data: if X contains a point from training, it considers the later in its own neighborhood. Also, the samples in X are not considered in the neighborhood of any point.  Parameters 
 
Xarray-like of shape (n_samples, n_features) 

The query sample or samples to compute the Local Outlier Factor w.r.t. the training samples.    Returns 
 
shifted_opposite_lof_scoresndarray of shape (n_samples,) 

The shifted opposite of the Local Outlier Factor of each input samples. The lower, the more abnormal. Negative scores represent outliers, positive scores represent inliers.
fit(X, y=None) [source]
 
Fit the local outlier factor detector from the training dataset.  Parameters 
 
X{array-like, sparse matrix} of shape (n_samples, n_features) or (n_samples, n_samples) if metric=’precomputed’ 

Training data.  
yIgnored 

Not used, present for API consistency by convention.    Returns 
 
selfLocalOutlierFactor 

The fitted local outlier factor detector.
property fit_predict  
Fits the model to the training set X and returns the labels. Not available for novelty detection (when novelty is set to True). Label is 1 for an inlier and -1 for an outlier according to the LOF score and the contamination parameter.  Parameters 
 
Xarray-like of shape (n_samples, n_features), default=None 

The query sample or samples to compute the Local Outlier Factor w.r.t. to the training samples.  
yIgnored 

Not used, present for API consistency by convention.    Returns 
 
is_inlierndarray of shape (n_samples,) 

Returns -1 for anomalies/outliers and 1 for inliers.
property predict  
Predict the labels (1 inlier, -1 outlier) of X according to LOF. Only available for novelty detection (when novelty is set to True). This method allows to generalize prediction to new observations (not in the training set).  Parameters 
 
Xarray-like of shape (n_samples, n_features) 

The query sample or samples to compute the Local Outlier Factor w.r.t. to the training samples.    Returns 
 
is_inlierndarray of shape (n_samples,) 

Returns -1 for anomalies/outliers and +1 for inliers.
property score_samples  
Opposite of the Local Outlier Factor of X. It is the opposite as bigger is better, i.e. large values correspond to inliers. Only available for novelty detection (when novelty is set to True). The argument X is supposed to contain new data: if X contains a point from training, it considers the later in its own neighborhood. Also, the samples in X are not considered in the neighborhood of any point. The score_samples on training data is available by considering the the negative_outlier_factor_ attribute.  Parameters 
 
Xarray-like of shape (n_samples, n_features) 

The query sample or samples to compute the Local Outlier Factor w.r.t. the training samples.    Returns 
 
opposite_lof_scoresndarray of shape (n_samples,) 

The opposite of the Local Outlier Factor of each input samples. The lower, the more abnormal.
fit(X, y) [source]
 
Fit the NearestCentroid model according to the given training data.  Parameters 
 
X{array-like, sparse matrix} of shape (n_samples, n_features) 

Training vector, where n_samples is the number of samples and n_features is the number of features. Note that centroid shrinking cannot be used with sparse matrices.  
yarray-like of shape (n_samples,) 

Target values (integers)
predict(X) [source]
 
Perform classification on an array of test vectors X. The predicted class C for each sample in X is returned.  Parameters 
 
Xarray-like of shape (n_samples, n_features) 
  Returns 
 
Cndarray of shape (n_samples,) 
   Notes If the metric constructor parameter is “precomputed”, X is assumed to be the distance matrix between the data to be predicted and self.centroids_.
fit(X, y=None) [source]
 
Fit the nearest neighbors estimator from the training dataset.  Parameters 
 
X{array-like, sparse matrix} of shape (n_samples, n_features) or (n_samples, n_samples) if metric=’precomputed’ 

Training data.  
yIgnored 

Not used, present for API consistency by convention.    Returns 
 
selfNearestNeighbors 

The fitted nearest neighbors estimator.