<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Intro
The tf.feature_column package provides several options for encoding categorical data. This mini-lab gives you an oppurtunity to explore and understand these options.
Step1:  Feature Column Definition
We have one continuous feature and one categorical feature.
Note that the category 'townhouse' is outside of our vocabulary list (OOV for short).
Step2:  Inspect Transformed Data
This is what would be input to your model would be after the features are transformed by the feature column specification.
Step3:  Excercise 1
What is the current encoding behavior for the OOV value? Currently it is ignored, which is to say the feature vector is set to all zeros.
Modify the feature column to have OOV values default to the 'house' category.
Step4:  Excercise 2
Now modify the feature column to have OOV values be assigned to a separate 'catch-all' category.
Step5:  Excercise 3
Assume we didn't have a vocabulary list available. Modify the feature column to one-hot encode house type based on a hash function.
What is the minimum hash bucket size to ensure no collisions? 5 is the minumum. With a hash bucket size of 2, all categories collide. With a size of 3 of 4, 'house' and 'townhouse' collide'
<ASSISTANT_TASK:>
Python Code:
# Toy Features Dictionary
features = {"sq_footage": [ 1000, 2000, 3000, 4000, 5000],
            "house_type":       ["house", "house", "apt", "apt", "townhouse"]}
Explanation: Intro
The tf.feature_column package provides several options for encoding categorical data. This mini-lab gives you an oppurtunity to explore and understand these options.
End of explanation
feat_cols = [
    tf.feature_column.numeric_column('sq_footage'),
    tf.feature_column.indicator_column(
        tf.feature_column.categorical_column_with_vocabulary_list(
            'house_type',['house','apt']
        ))
]
Explanation: Feature Column Definition
We have one continuous feature and one categorical feature.
Note that the category 'townhouse' is outside of our vocabulary list (OOV for short).
End of explanation
tf.feature_column.input_layer(features,feat_cols)
Explanation: Inspect Transformed Data
This is what would be input to your model would be after the features are transformed by the feature column specification.
End of explanation
feat_cols = [
    tf.feature_column.numeric_column('sq_footage'),
    tf.feature_column.indicator_column(
        tf.feature_column.categorical_column_with_vocabulary_list(
            'house_type',['house','apt'], default_value=0
        ))
]
tf.feature_column.input_layer(features,feat_cols)
Explanation: Excercise 1
What is the current encoding behavior for the OOV value? Currently it is ignored, which is to say the feature vector is set to all zeros.
Modify the feature column to have OOV values default to the 'house' category.
End of explanation
feat_cols = [
    tf.feature_column.numeric_column('sq_footage'),
    tf.feature_column.indicator_column(
        tf.feature_column.categorical_column_with_vocabulary_list(
            'house_type',['house','apt'], num_oov_buckets=1
        ))
]
tf.feature_column.input_layer(features,feat_cols)
Explanation: Excercise 2
Now modify the feature column to have OOV values be assigned to a separate 'catch-all' category.
End of explanation
feat_cols = [
    tf.feature_column.numeric_column('sq_footage'),
    tf.feature_column.indicator_column(
        tf.feature_column.categorical_column_with_hash_bucket(
            'house_type',5
        ))
]
tf.feature_column.input_layer(features,feat_cols)
Explanation: Excercise 3
Assume we didn't have a vocabulary list available. Modify the feature column to one-hot encode house type based on a hash function.
What is the minimum hash bucket size to ensure no collisions? 5 is the minumum. With a hash bucket size of 2, all categories collide. With a size of 3 of 4, 'house' and 'townhouse' collide'
End of explanation
<END_TASK>