I’m starting to take my first steps with TensorFlow and trying to understand the division of columns into numeric and categorical in this example:
Could you explain me why columns: ‘n_siblings_spouses’ and ‘parch’ aren’t numeric?
(This is the part of the code in the example:)
CATEGORICAL_COLUMNS = ['sex', 'n_siblings_spouses', 'parch', 'class', 'deck',
NUMERIC_COLUMNS = ['age', 'fare']
feature_columns = 
for feature_name in CATEGORICAL_COLUMNS:
vocabulary = dftrain[feature_name].unique()
for feature_name in NUMERIC_COLUMNS:
Those columns are considered categorical because, while the actual values are numeric, they are in fact referring to discrete categories, specifically numbers of people. For a simple practical example, say that there were some missing values in one of those columns, and you wanted to fill them with something. If you wanted to use the mean value, you might end up with something nonsensical, like 2.3 parents and children (
As a general rule, if you are dealing with discrete entities, then you treat them as categorical values (even if the categories are numbers). But if it’s valid for the numbers themselves to fall on a continuum (such as with values like price or age), then they would be considered numeric.
Hope this helps!
Thank you very much. I see it now!