Comments (2)
Hi @vandonova,
You can retrieve the components for training as follows:
fig = result.model[-1].plot_components() # Generates and stores the components
result.model[-1].silverkite_diagnostics.components
Currently there is no easy way to return the components for the forecasts, but it can be computed as follows.
Assumption: result
is the output from the pipeline
import patsy
estimator = result.forecast.estimator
trained_model= estimator.model_dict
fut_df = result.forecast.df[["ts", "actual"]].rename(columns={"actual":"y"})
# Build Silverkite features
features_df_fut = estimator.silverkite._SilverkiteForecast__build_silverkite_features(
df=fut_df,
time_col=trained_model["time_col"],
origin_for_time_vars=trained_model["origin_for_time_vars"],
daily_event_df_dict=trained_model["daily_event_df_dict"],
changepoint_values=trained_model["changepoint_values"],
continuous_time_col=trained_model["continuous_time_col"],
growth_func=trained_model["growth_func"],
fs_func=trained_model["fs_func"],
seasonality_changepoint_result=trained_model["seasonality_changepoint_result"],
changepoint_dates=trained_model["trend_changepoint_dates"]
)
# Add autoregression terms
if trained_model["autoreg_func"] is not None:
past_df = trained_model["df"].copy()
df = pd.DataFrame({value_col: [np.nan]*fut_df.shape[0]})
df.index = fut_df.index
autoreg_df = estimator.silverkite._SilverkiteForecast__build_autoreg_features(
df=df,
value_col=trained_model["value_col"],
autoreg_func=trained_model["autoreg_func"],
phase="predict",
past_df=past_df[[value_col]])
features_df_fut = pd.concat(
[features_df_fut, autoreg_df],
axis=1,
sort=False)
# Compute the design matrix
(x_mat_predict,) = patsy.build_design_matrices(
[trained_model["x_design_info"]],
data=features_df_fut,
return_type="dataframe")
# Compute features df ( this is `x_mat_predict` multiplied by the training coefficients)
feature_df_predict = (trained_model["ml_model"].coef_* x_mat_predict)
# Calculate components
diagnostics = estimator.silverkite_diagnostics
components_predict = diagnostics.get_silverkite_components(
fut_df,
diagnostics.time_col,
diagnostics.value_col,
feature_df_predict)
Hope this helps. Have a good weekend.
from greykite.
Thanks @sayanpatra this is exactly what I needed.
from greykite.
Related Issues (20)
- Input Data Has Many Null Values HOT 1
- run_forecast_config crash with regressors but not without HOT 1
- In get_auto_silverkite_model_template, `min_gap_in_seconds` fails if input is not sorted HOT 1
- Add support for HistGradientBoostingRegressor HOT 2
- Predicted values and metrics for N-step ahead forecast. HOT 5
- Implemening regressors HOT 3
- Importing Forecaster gives error for United States class (Holiday?) HOT 4
- Loosening dill version HOT 2
- GreyKite 0.3.0 Library Issue HOT 7
- Library import issues HOT 1
- Parallel execution on Spark, HOT 2
- ResourceWarning: Unclosed file... messages when deserializing a model. HOT 1
- The default performance of greykite silverkite is far worse than default prophet HOT 3
- Enforcing positive output, or how to tell the model not to produce negative results HOT 1
- Regressors Already Forecastd, No Lag Needed. But, getting AttributeError: 'dict' object has no attribute 'lagged_regressors' HOT 7
- Greykite feature scaling HOT 6
- Support for pandas 1.3 HOT 2
- Training the model on all data after benchmarking HOT 2
- regularization_strength Default value HOT 1
- Support custom metrics for cross validation HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from greykite.