0
$\begingroup$

I have a pytorch tabular dataset with zip code as a categorical embedding. I'm getting great results on the test set. When I go to run my hold out sample through, it errors out because I have more zip codes in the hold out then what the model was trained on.

How do I handle this? In production, the likelihood of seeing a new zip code is high so I need to learn something I can transfer into production.

Thank you.

$\endgroup$
2
$\begingroup$

One possibility would be to represent the zip codes using some transformation that could be applied to new (unseen) zip codes as well. For example, could you re-represent zip codes as latitude + longitude?

$\endgroup$
0
$\begingroup$

You could add a unseen zipcode in your training data (represented by a value like -1) and then train the model. The model would then be able to handle unseen zipcode values in the test data set.

$\endgroup$
1
  • $\begingroup$ That's interesting in regards to other categorical variables. How does the model know if new data is unseen? Are you envisioning some sort of look up table with all seen values? $\endgroup$
    – Jordan
    Jan 16 '20 at 17:55

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.