0
$\begingroup$

I have data set with date features like 01/01/2019 and I would like to use KNN. However, I cannot find a good transformation for dates that has a meaningful distance result for the last feature.

For example:

f1 | 1 | 2 | 3 | 4 | 01/01/2019

f2 | 10 | 3 | 12 | 1 | 14/01/2019

Does anyone have any recommendations?

$\endgroup$
0
$\begingroup$

Find the time difference in an appropriate granularity(/ies):

daysDiffFeature = diffInDays(dateCol)
hoursDiffFeature = diffInHours(dateCol)

Then you can use whatever distance based metrics/calculations are required in your algorithsm

|improve this answer|||||
$\endgroup$
0
$\begingroup$

You may consider the difference in number of days between each available date and the current day. The larger the number, the older the date will be.

|improve this answer|||||
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.