code: def plot_tsice_explanation(explanation, forecast_horizon):
      original_ts = pd.DataFrame(explanation["data_x"])
      perturbations = explanation["perturbations"]
      forecasts_on_perturbations = explanation[
          "forecasts_on_perturbations"
      ]
  
      new_perturbations = []
      new_timestamps = []
      pred_ts = []
  
      original_ts.index.freq = pd.infer_freq(original_ts.index)
      for i in range(1, forecast_horizon + 1):
          new_timestamps.append(
              original_ts.index[-1] + (i * original_ts.index.freq)
          )
  
      for perturbation in perturbations:
          new_perturbations.append(pd.DataFrame(perturbation))
  
      for forecast in forecasts_on_perturbations:
          pred_ts.append(pd.DataFrame(forecast, index=new_timestamps))
  
      pred_original_ts = pd.DataFrame(
          explanation["current_forecast"], index=new_timestamps
      )
  
      # plot perturbed timeseries
      fig = plot_timeseries(
          ts=new_perturbations,
          color="lightgreen",
          name="perturbed timeseries samples",
      )
      # plot original timeseries
      plot_timeseries(
          ts=original_ts,
          fig=fig,
          name="input/original timeseries",
          color="green",
      )
  
      # plot varying forecast range
      plot_timeseries(
          ts=pred_ts,
          color="lightblue",
          fig=fig,
          name="forecast on perturbed samples",
      )
  
      # plot original forecast
      fig = plot_timeseries(
          ts=pred_original_ts,
          fig=fig,
          color="blue",
          name="original forecast",
      )
  
      fig.update_layout(template="plotly_white")
      fig.update_layout(
          title_text="Time Series Individual Conditional Expectation (TSICE) Plot"
      )
  
      fig.update_xaxes(title_text="Month/Year")
  
      fig.update_yaxes(title_text="sunspots")
  
      return fig
  
file_path: AIX360/examples/tsice/plots.py
imports: from typing import Union
  import numpy
  import pandas
  from sklearn.linear_model import LinearRegression
label_desc: Use image node_id 3 for calling a global function with example usage: plot_tsice_explanation(explanation, forecast_horizon) and returns: fig