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

1862 more robust way of component naming #1863

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ but cannot always guarantee backwards compatibility. Changes that may **break co
- `RegressionEnsembleModel` and `NaiveEnsembleModel` can generate probabilistic forecasts, probabilistics `forecasting_models` can be sampled to train the `regression_model`, updated the documentation (stacking technique). [#1692](https://github.com/unit8co/darts/pull/#1692) by [Antoine Madrona](https://github.com/madtoinou).
- Improvements to `ShapExplainer`:
- Added static covariates support to `ShapeExplainer`. [#1803](https://github.com/unit8co/darts/pull/#1803) by [Anne de Vries](https://github.com/anne-devries) and [Dennis Bader](https://github.com/dennisbader).
- Improved static covariates column naming when applying a `sklearn.preprocessing.OneHotEncoder` with `StaticCovariatesTransformer` [#1863](https://github.com/unit8co/darts/pull/1863) by [Anne de Vries](https://github.com/anne-devries)

**Fixed**
- Fixed an issue not considering original component names for `TimeSeries.plot()` when providing a label prefix. [#1783](https://github.com/unit8co/darts/pull/1783) by [Simon Sudrich](https://github.com/sudrich).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,11 @@ def _create_category_mappings(
col_map_cat_i = []
for cat in categories:
col_map_cat_i.append(cat)
inv_col_map_cat[cat] = [col]
if len(categories) > 1:
cat_col_name = str(col) + "_" + str(cat)
inv_col_map_cat[cat_col_name] = [col]
else:
inv_col_map_cat[cat] = [col]
col_map_cat[col] = col_map_cat_i
# If we don't have any categorical static covariates, don't need to generate mapping:
else:
Expand Down Expand Up @@ -454,6 +458,8 @@ def _add_back_static_covs(
elif is_cat: # categorical transformed column
# covers one to one feature map (ordinal/label encoding) and one to multi feature (one hot encoding)
for col_name in col_map_cat[col]:
if len(col_map_cat[col]) > 1:
col_name = str(col) + "_" + str(col_name)
if col_name not in static_cov_columns:
data[col_name] = vals_cat[:, idx_cat]
static_cov_columns.append(col_name)
Expand Down