evalml.pipelines.components.KNeighborsClassifier

class evalml.pipelines.components.KNeighborsClassifier(n_neighbors=5, weights='uniform', algorithm='auto', leaf_size=30, p=2, random_state=0, **kwargs)[source]

K-Nearest Neighbors Classifier.

name = 'KNN Classifier'
model_family = 'k_neighbors'
supported_problem_types = [<ProblemTypes.BINARY: 'binary'>, <ProblemTypes.MULTICLASS: 'multiclass'>, <ProblemTypes.TIME_SERIES_BINARY: 'time series binary'>, <ProblemTypes.TIME_SERIES_MULTICLASS: 'time series multiclass'>]
hyperparameter_ranges = {'algorithm': ['auto', 'ball_tree', 'kd_tree', 'brute'], 'leaf_size': Integer(low=10, high=30, prior='uniform', transform='identity'), 'n_neighbors': Integer(low=2, high=12, prior='uniform', transform='identity'), 'p': Integer(low=1, high=5, prior='uniform', transform='identity'), 'weights': ['uniform', 'distance']}
default_parameters = {'algorithm': 'auto', 'leaf_size': 30, 'n_neighbors': 5, 'p': 2, 'weights': 'uniform'}
predict_uses_y = False

Instance attributes

feature_importance

Returns array of 0’s matching the input number of features as feature_importance is not defined for KNN classifiers.

needs_fitting

parameters

Returns the parameters which were used to initialize the component

Methods:

__init__

Initialize self.

clone

Constructs a new component with the same parameters and random state.

describe

Describe a component and its parameters

fit

Fits component to data

load

Loads component at file path

predict

Make predictions using selected features.

predict_proba

Make probability estimates for labels.

save

Saves component at file path

Class Inheritance

Inheritance diagram of KNeighborsClassifier