trajminer.classification
.KNearestNeighbors¶
-
class
trajminer.classification.
KNearestNeighbors
(n_neighbors=1, weights='uniform', measure='precomputed', n_jobs=1)¶ K-Nearest Neighbors Classifier.
- n_neighborsint (default=1)
Number of neighbors to use for queries.
- weightsstr or callable (default=’uniform’)
Weight function used in prediction. See the scikit-learn API fo details.
- measureSimilarityMeasure object or str (default=’precomputed’)
The similarity measure to use for computing similarities (see
trajminer.similarity
) or the string ‘precomputed’.- n_jobsint (default=1)
The number of parallel jobs.
-
__init__
(n_neighbors=1, weights='uniform', measure='precomputed', n_jobs=1)¶ Initialize self. See help(type(self)) for accurate signature.
-
predict
(X)¶ Returns the predictions for the given test data.
- Xarray-like, shape (n_samples, max_length, n_features)
Input data.
- predictionsarray-like, shape (n_samples, n_labels)
Predicted class for each input sample.
-
score
(X, y)¶ Returns the accuracy on the given test data and labels.
- Xarray-like, shape (n_samples, max_length, n_features)
Input data.
- yarray-like, shape (n_samples, n_labels)
Labels of input samples.
- scorefloat
Accuracy of self.predict(X) according to y.