C2W2 missing values in preprocessing_fn

Good day,

Use tf.cast to cast the label key to float32 and fill in the missing values.

traffic_volume = tf.cast(inputs[_VOLUME_KEY], dtype=tf.float32)


# Create a feature that shows if the traffic volume is greater than the mean and cast to an int
outputs[_transformed_name(_VOLUME_KEY)] = tf.cast(
    
    # Use `tf.greater` to check if the traffic volume in a row is greater than the mean of the entire traffic volumn column
    tf.greater(_, _(tf.cast(inputs[_VOLUME_KEY], tf.float32))),
    
    tf.int64)                           

### END CODE HERE
return outputs

It says I should add missing values however when I search the discussion forum i keep seeing a reference to a _fill_in_missing function. It appears in some peoples code but I don’t see it anywhere in my notebook. Is this something we must add ourselves?

In the given file, there are no missing values for the traffic_volume column. That said, there’s no _fill_in_missing function in my version of the notebook. The tests passed without filling in missing values.

It makes sense for a better hint on what the missing values should be. We could use mean / 0 or other options.

If we consider default to be 0 to indicate that there’s no traffic, consider using tf.where and tf.is_nan to get rid of missing values.

2 Likes