Building-ML-Pipelines / building-machine-learning-pipelines

Code repository for the O'Reilly publication "Building Machine Learning Pipelines" by Hannes Hapke & Catherine Nelson
MIT License
584 stars 249 forks source link

Please help with understanding of convert_zip_code #33

Closed festeh closed 4 years ago

festeh commented 4 years ago

Hi! I'm struggling to understand why function convert_zip_code works.

First of all, its input argument will have type tf.Tensor when it is called from preprocessing_fn. Consequently, zipcode=='' will allways be false, as tensor does not equal to empty string and eager mode is not supported in tfx. So I expect this function to crash during casting to an empty string to a number, what I'm missing here? Thanks!

festeh commented 4 years ago

Ah, I get it. It's due to regex that handles empty strings lol. Still, the code is confusing, if statement should be removed.