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

[BUG] SarimaxModel fails with to fit with exogenous data #90

Open
jstammers opened this issue May 12, 2022 · 0 comments
Open

[BUG] SarimaxModel fails with to fit with exogenous data #90

jstammers opened this issue May 12, 2022 · 0 comments
Labels
bug Something isn't working

Comments

@jstammers
Copy link

Describe the bug
I am failing to fit a SarimaxModel because the model reports that the exogenous and endogenous dataframes do not have the same index despite coming from the same dataframe.

After debugging, this seems to be due to the fact that the _get_transformed_data method does not preserve the index using the default transformer

I have been able to correct this using

    def _get_transformed_data(
        self, as_series: bool = False
    ) -> Union[pandas.DataFrame, pandas.Series]:
        key = self.node.key
        value = self.node.item
        transformed = self.transform_function.transform(value[key])
        if as_series:
            return pandas.Series(transformed, index=value[key].index)
        else:
            return pandas.DataFrame({key: transformed})

But perhaps it would be better to modify FunctionTransformer.transform

    def transform(self, x: pandas.Series):
        return self.func(x.values)

as this does not preserve the index of the input series

To Reproduce

from hts.model import SarimaxModel
tree = ...
model = SarimaxModel(node=tree)

#raises ValueError: The indices for endog and exog are not aligned
Expected behavior
No error should be raised because the two dataframes should have the same index

@jstammers jstammers added the bug Something isn't working label May 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant