Created
July 28, 2022 20:27
-
-
Save erykml/0fa1aabdf55f9682bdddb4db287e3b70 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
X_2 = X.copy() | |
X_2["month"] = X_2.index.month | |
X_2["month_sin"] = sin_transformer(12).fit_transform(X_2)["month"] | |
X_2["month_cos"] = cos_transformer(12).fit_transform(X_2)["month"] | |
X_2["day_sin"] = sin_transformer(365).fit_transform(X_2)["day_of_year"] | |
X_2["day_cos"] = cos_transformer(365).fit_transform(X_2)["day_of_year"] | |
fig, ax = plt.subplots(2, 1, sharex=True, figsize=(16,8)) | |
X_2[["month_sin", "month_cos"]].plot(ax=ax[0]) | |
X_2[["day_sin", "day_cos"]].plot(ax=ax[1]) | |
plt.suptitle("Cyclical encoding with sine/cosine transformation"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment