Challenge - 5 Problems
TF Transform Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediateOutput of TF Transform scaling function
What is the output of the following TF Transform preprocessing function when applied to input feature value 10?
TensorFlow
import tensorflow_transform as tft import tensorflow as tf def preprocessing_fn(inputs): x = inputs['feature'] x_scaled = tft.scale_to_0_1(x) return {'x_scaled': x_scaled} # Simulate input inputs = {'feature': tf.constant([10.0, 20.0, 30.0])} # Apply preprocessing_fn with TF Transform # Assume the dataset has min=10 and max=30 for 'feature'
Attempts:
2 left
💡 Hint
tft.scale_to_0_1 scales values linearly between min and max to the range 0 to 1.
✗ Incorrect
The function tft.scale_to_0_1 scales the input feature so that the minimum value maps to 0 and the maximum maps to 1. Given min=10 and max=30, 10 maps to 0, 20 maps to 0.5, and 30 maps to 1.
❓ Model Choice
intermediateChoosing the right TF Transform function for categorical data
You have a categorical feature with many unique string values. Which TF Transform function is best to convert this feature into a numeric representation suitable for a machine learning model?
Attempts:
2 left
💡 Hint
Think about converting strings to integer indices.
✗ Incorrect
tft.compute_and_apply_vocabulary creates a vocabulary of unique strings and maps each string to an integer index, which is suitable for categorical string features.
❓ Hyperparameter
advancedChoosing bucket boundaries in TF Transform bucketize
You want to bucketize a continuous feature into 3 buckets using TF Transform. Which set of bucket boundaries will create 3 buckets?
Attempts:
2 left
💡 Hint
Number of buckets = number of boundaries + 1.
✗ Incorrect
TF Transform bucketize creates buckets based on boundaries. If you want 3 buckets, you need 2 boundaries.
🔧 Debug
advancedDebugging TF Transform preprocessing function error
Given this preprocessing function, what error will occur when running TF Transform?
import tensorflow_transform as tft
def preprocessing_fn(inputs):
x = inputs['feature']
x_norm = (x - tft.mean(x)) / tft.stddev(x)
return {'x_norm': x_norm}
Assume 'feature' is a float tensor.
Attempts:
2 left
💡 Hint
tft.mean and tft.stddev compute statistics over the dataset during analysis phase.
✗ Incorrect
tft.mean and tft.stddev are designed to compute dataset-wide statistics and can be used safely in preprocessing_fn without errors.
🧠 Conceptual
expertWhy use TF Transform for data preprocessing?
Which of the following is the main advantage of using TF Transform for preprocessing data in a TensorFlow ML pipeline?
Attempts:
2 left
💡 Hint
Think about consistency between training and serving data transformations.
✗ Incorrect
TF Transform computes dataset-wide statistics during analysis and applies the same transformations at serving, ensuring consistency.
