Recall & Review
beginner
What is date and time feature extraction in machine learning?
It is the process of taking raw date and time data and turning it into useful pieces of information (features) that a machine learning model can understand and use to make predictions.
Click to reveal answer
beginner
Name three common features extracted from a date-time value.
Year, month, day of the week, hour, minute, and second are common features extracted from date-time values.
Click to reveal answer
beginner
Why might extracting the day of the week be useful for a model?
Because some patterns depend on the day, like sales being higher on weekends or traffic being heavier on weekdays.
Click to reveal answer
intermediate
How can you extract the hour from a timestamp in Python using pandas?
Use pandas' dt accessor: df['timestamp'].dt.hour extracts the hour part from a datetime column.
Click to reveal answer
intermediate
What is the benefit of extracting cyclical features like hour or month as sine and cosine values?
It helps the model understand that these features repeat in cycles, for example, hour 23 is close to hour 0, which normal numbers don't show well.
Click to reveal answer
Which feature is NOT typically extracted from a datetime value?
✗ Incorrect
User's age is not a direct feature from datetime values; it requires additional data.
Why do we sometimes convert hour or month into sine and cosine values?
✗ Incorrect
Sine and cosine transformations help models understand that time features repeat in cycles.
Which Python library is commonly used to extract date and time features?
✗ Incorrect
pandas has built-in datetime functions to extract features easily.
What does df['date'].dt.weekday return in pandas?
✗ Incorrect
It returns the day of the week as an integer where Monday is 0 and Sunday is 6.
Which feature might help predict traffic patterns best?
✗ Incorrect
Traffic often changes depending on the day of the week (weekdays vs weekends).
Explain how you would extract useful features from a timestamp for a machine learning model.
Think about breaking down the timestamp into parts and representing repeating patterns.
You got /7 concepts.
Why is it important to transform cyclical time features like hour or month before using them in models?
Consider how time repeats and how numbers alone might mislead the model.
You got /4 concepts.