TransWikia.com

Date transformation for KNN

Data Science Asked by Mapp on May 25, 2021

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?

2 Answers

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

Answered by StephenBoesch on May 25, 2021

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.

Answered by Christos Karatsalos on May 25, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP