Skip to content

Instantly share code, notes, and snippets.

@abhijeet-talaulikar
Created June 20, 2023 03:19
Show Gist options
  • Save abhijeet-talaulikar/eca8363be689d630c0da663cb970985e to your computer and use it in GitHub Desktop.
Save abhijeet-talaulikar/eca8363be689d630c0da663cb970985e to your computer and use it in GitHub Desktop.
bias = pd.DataFrame({
"t": np.arange(104)
})
d = 2
# Fourier terms
for i in np.arange(1,d+1):
bias[f"cos_{i}"] = np.cos(2 * np.pi * i * bias["t"] / 52)
bias[f"sin_{i}"] = np.sin(2 * np.pi * i * bias["t"] / 52)
# Holiday flag
bias['holiday_period'] = np.select([bias.t==26, bias.t==78, np.logical_and(bias.t>=40,bias.t<=52), np.logical_and(bias.t>=92,bias.t<=104)],[1,1,1,1],0)
# Min-max scaling
bias.iloc[:,1:] = (bias.iloc[:,1:] - bias.iloc[:,1:].min()) / (bias.iloc[:,1:].max() - bias.iloc[:,1:].min())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment