Skip to content
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

[FEAT] Core Numeric Type and Null Protections #181

Merged
merged 7 commits into from
Apr 19, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion hierarchicalforecast/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,14 @@ def _prepare_fit(self,
# Declare output names
drop_cols = ['ds', 'y'] if 'y' in Y_hat_df.columns else ['ds']
model_names = Y_hat_df.drop(columns=drop_cols, axis=1).columns.to_list()

# Ensure numeric columns
if not len(Y_hat_df[model_names].select_dtypes(include='number').columns) == len(model_names):
raise Exception('Check `Y_hat_df`s columns contain numeric types')

pi_model_names = [name for name in model_names if ('-lo' in name or '-hi' in name)]
model_names = [name for name in model_names if name not in pi_model_names]

# TODO: Complete y_hat_insample protection
if intervals_method in ['bootstrap', 'permbu']:
if not (set(model_names) <= set(Y_df.columns)):
Expand Down
7 changes: 6 additions & 1 deletion nbs/core.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,14 @@
" # Declare output names\n",
" drop_cols = ['ds', 'y'] if 'y' in Y_hat_df.columns else ['ds']\n",
" model_names = Y_hat_df.drop(columns=drop_cols, axis=1).columns.to_list()\n",
"\n",
" # Ensure numeric columns\n",
" if not len(Y_hat_df[model_names].select_dtypes(include='number').columns) == len(model_names):\n",
" raise Exception('Check `Y_hat_df`s columns contain numeric types')\n",
" \n",
" pi_model_names = [name for name in model_names if ('-lo' in name or '-hi' in name)]\n",
" model_names = [name for name in model_names if name not in pi_model_names]\n",
"\n",
" \n",
" # TODO: Complete y_hat_insample protection\n",
" if intervals_method in ['bootstrap', 'permbu']:\n",
" if not (set(model_names) <= set(Y_df.columns)):\n",
Expand Down