Alex Rivera | Logout

KNN classification with categorical data

Asked 2012-11-29T12:28:16.957
24

I'm busy working on a project involving k-nearest neighbor (KNN) classification. I have mixed numerical and categorical fields. The categorical values are ordinal (e.g. bank name, account type). Numerical types are, for e.g. salary and age. There are also some binary types (e.g., male, female).

How do I go about incorporating categorical values into the KNN analysis?

As far as I'm aware, one cannot simply map each categorical field to number keys (e.g. bank 1 = 1; bank 2 = 2, etc.), so I need a better approach for using the categorical fields. I have heard that one can use binary numbers. Is this a feasible method?

Edit
Report

1 Answer

3

The most straight forward way to convert categorical data into numeric is by using indicator vectors. See the reference I posted at my previous comment.

answered 2012-11-30T07:32:13.443

Your Answer