Sakea
Sakea

Reputation: 1

How to use directional data as feature using scikit-learn knn?

I'm new to using KNN and in my train set I have velocity vector. Since the directions 359° and 0° are completely different I was thinking of transforming the direction so that the vector in test data it points to 180°.

I could make this transformation before using KNeighborsClassifier if I predict from one data point, but when I tune the hyperparameters with GridSearchCV the transformation should be done between every comparison. Is there some way to do that?

Or some alternative way that I'm missing?

Upvotes: 0

Views: 120

Answers (1)

Mohsin hasan
Mohsin hasan

Reputation: 837

You can break direction column, theta into 2 columns, sin(theta) and cos(theta), both of which would have continuity.

Upvotes: 0

Related Questions