lale.lib.sklearn.k_neighbors_classifier module¶
- class lale.lib.sklearn.k_neighbors_classifier.KNeighborsClassifier(*, n_neighbors=5, weights='uniform', algorithm='auto', leaf_size=30, p=2, metric='minkowski', metric_params=None, n_jobs=None)¶
Bases:
PlannedIndividualOp
K nearest neighbors classifier from scikit-learn.
This documentation is auto-generated from JSON schemas.
- Parameters
n_neighbors (integer, >=1, <='X/maxItems', <=100 for optimizer, uniform distribution, default 5) – Number of neighbors to use by default for kneighbors queries.
weights (‘uniform’ or ‘distance’, default ‘uniform’) – Weight function used in prediction.
algorithm (‘ball_tree’, ‘kd_tree’, ‘brute’, or ‘auto’, default ‘auto’) – Algorithm used to compute the nearest neighbors.
leaf_size (integer, >=1, <=100 for optimizer, uniform distribution, not for optimizer, default 30) – Leaf size passed to BallTree or KDTree.
p (integer, >=1, <=3 for optimizer, uniform distribution, default 2) – Power parameter for the Minkowski metric.
metric (‘euclidean’, ‘manhattan’, or ‘minkowski’, default ‘minkowski’) – The distance metric to use for the tree.
metric_params (union type, not for optimizer, default None) –
Additional keyword arguments for the metric function.
None
or dict
n_jobs (union type, not for optimizer, default None) –
Number of parallel jobs to run for the neighbor search.
None
1 unless in joblib.parallel_backend context.
or -1
Use all processors.
or integer, >=1
Number of CPU cores.
- fit(X, y=None, **fit_params)¶
Train the operator.
Note: The fit method is not available until this operator is trainable.
Once this method is available, it will have the following signature:
- Parameters
X (array of items : array of items : float) – Features; the outer array is over samples.
y (union type) –
Target class labels; the array is over samples.
array of items : float
or array of items : array of items : float
or array of items : string
or array of items : boolean
- predict(X, **predict_params)¶
Make predictions.
Note: The predict method is not available until this operator is trained.
Once this method is available, it will have the following signature:
- Parameters
X (array of items : array of items : float) – Features; the outer array is over samples.
- Returns
result – Predicted class label per sample.
array of items : float
or array of items : array of items : float
or array of items : string
or array of items : boolean
- Return type
union type
- predict_proba(X)¶
Probability estimates for all classes.
Note: The predict_proba method is not available until this operator is trained.
Once this method is available, it will have the following signature:
- Parameters
X (array of items : array of items : float) – Features; the outer array is over samples.
- Returns
result – Probability of the sample for each class in the model.
- Return type
array of items : array of items : float