-
Notifications
You must be signed in to change notification settings - Fork 178
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: Add feature contributions as attribute and tutorial on how to use #448
Conversation
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
This reverts commit 51927f5.
Thanks! Please add a test with num_partitions on the cell where the test for the contributions is. It can be something like the following: # this part already exists
fcst_hist_df = nixtla_client.forecast(df=df_date_features, h=h, X_df=future_df, add_history=True, feature_contributions=True)
shap_values_hist = nixtla_client.feature_contributions.copy() # <- add the copy here
assert len(shap_values_hist) == len(fcst_hist_df)
np.testing.assert_allclose(fcst_hist_df["TimeGPT"].values, shap_values_hist.iloc[:, 3:].sum(axis=1).values)
# the following is new
# test num partitions
_ = nixtla_client.forecast(df=df_date_features, h=h, X_df=future_df, add_history=True, feature_contributions=True, num_partitions=2)
pd.testing.assert_frame_equal(nixtla_client.feature_contributions, shap_values_hist) Also please add this on the forecast method: self.__dict__.pop('feature_contributions', None) Just below the one for |
Experiment ResultsExperiment 1: air-passengersDescription:
Results:
Plot:Experiment 2: air-passengersDescription:
Results:
Plot:Experiment 3: electricity-multiple-seriesDescription:
Results:
Plot:Experiment 4: electricity-multiple-seriesDescription:
Results:
Plot:Experiment 5: electricity-multiple-seriesDescription:
Results:
Plot: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Please don't merge this until we release v2, otherwise it'll show up in the docs and we'll get issues about it.
Experiment ResultsExperiment 1: air-passengersDescription:
Results:
Plot:Experiment 2: air-passengersDescription:
Results:
Plot:Experiment 3: electricity-multiple-seriesDescription:
Results:
Plot:Experiment 4: electricity-multiple-seriesDescription:
Results:
Plot:Experiment 5: electricity-multiple-seriesDescription:
Results:
Plot: |
Experiment ResultsExperiment 1: air-passengersDescription:
Results:
Plot:Experiment 2: air-passengersDescription:
Results:
Plot:Experiment 3: electricity-multiple-seriesDescription:
Results:
Plot:Experiment 4: electricity-multiple-seriesDescription:
Results:
Plot:Experiment 5: electricity-multiple-seriesDescription:
Results:
Plot: |
Experiment ResultsExperiment 1: air-passengersDescription:
Results:
Plot:Experiment 2: air-passengersDescription:
Results:
Plot:Experiment 3: electricity-multiple-seriesDescription:
Results:
Plot:Experiment 4: electricity-multiple-seriesDescription:
Results:
Plot:Experiment 5: electricity-multiple-seriesDescription:
Results:
Plot: |
Experiment ResultsExperiment 1: air-passengersDescription:
Results:
Plot:Experiment 2: air-passengersDescription:
Results:
Plot:Experiment 3: electricity-multiple-seriesDescription:
Results:
Plot:Experiment 4: electricity-multiple-seriesDescription:
Results:
Plot:Experiment 5: electricity-multiple-seriesDescription:
Results:
Plot: |
Adds the attribute
feature_contributions
to the client when exogenous features are used.Tutorial on how to access feature contributions and use
shap
to make different plots.