0
$\begingroup$

I have been struggling to find proof for that but I couldnt

Every time I prepare dataset I face the same issue

when a column is a classification such as CountryCode or TaskType in this dataset

TaskType  CountryCode  Target
1         61           Red
1         962          Yellow
2         1            Yellow
6         61           Yellow
4         81           Red
2         1            Blue
1         61           Red
2         962          Green
4         61           Blue

if I applied the dataset as to different models such as linear regression, SVM, KNN, etc.

will these model consider CountryCode and TaskType as numeric fields and treat them as continuous data?

Shall I One Hot Encode these features before using them?

what is the best way to handle this scenario?

$\endgroup$
3
3
$\begingroup$

An intuitive explanation, why we should encode categorical features, is that otherwise there will be absolutely another sense of "closeness" between features of the same type. The model will treat this features as continuous and as a result if you have two points in your feature space (p1 with CountryCode 61 and p2 CountryCode 962) and then you add the third point p3 with CountryCode 81, then model will miss out, that it can't evaluate distances between 61, 962 and 81.

$\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.