-
Notifications
You must be signed in to change notification settings - Fork 192
Add simple DatetimeEncoder example with periodic encoding (#1629) #1834
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Add simple DatetimeEncoder example with periodic encoding (#1629) #1834
Conversation
rcap107
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @TaobaOuathrani, thanks for this PR. It's a good start, but there is still some work to be done.
To begin with, this example should be in its own file, and the content of the current file (0030_datetime_encoder.py) should be moved to the FIXME folder in examples: we might want to revisit the forecasting example in the future, possibly by using the Data Ops.
Another general comment is that there should be more narrative, i.e., more text describing what are the steps that are being executed and the reasoning for it. Something like "we want to add periodic features because we are using a linear model and they are useful" etc.
I am not too keen on using synthetic data as the example, but I am aware that finding a dataset that is suitable for the example (something that has a timeseries but isn't forecasting-based) is hard, so we might be stuck with this for now.
In any case, thanks for the PR. We can keep on iterating on this.
| ------------------------------------------------------------ | ||
| This example demonstrates what the DatetimeEncoder does on a simple, | ||
| non-forecasting regression task. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please expand a bit this section explaining that for the sake of the example we are using a synthetic dataset, and a plot of what the target looks like.
| y_pred_baseline = model_baseline.predict(X_baseline) | ||
| print("R² with naive timestamp:", r2_score(y, y_pred_baseline)) | ||
|
|
||
| # --------------------------------------------------------------------- |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should also be a section with a DatetimeEncoder that does not include periodic features for the sake of the comparison.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also please add a few lines explaining in words what is happening here as part of the narrative of the example.
| encoder = next(iter(apply.transformers_.values())) | ||
|
|
||
| print("Generated features:") | ||
| print(encoder.get_feature_names_out()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a conclusion summarizing briefly what is being done here
|
Oh, and pre-commit checks can be addressed by running either |
This PR adds a self-contained example showcasing how
DatetimeEncoder extracts meaningful time-based features in a
regression setting.
Closes #1629