chap_core.plotting package¶
Submodules¶
chap_core.plotting.backtest_plot module¶
- class chap_core.plotting.backtest_plot.BackTestPlotBase[source]¶
Bases:
ABCAbstract base class for backtest plotting.
Subclasses must implement: - from_backtest: Class method to create plot instance from a BackTest object - plot: Method to generate and return the visualization - name: Class variable with the name of the plot type
- abstractmethod classmethod from_backtest(backtest: BackTest)[source]¶
Create a plot instance from a BackTest object.
Parameters¶
- backtestBackTest
The backtest object containing forecast and observation data
Returns¶
- BackTestPlotBase
An instance of the concrete plot class
- name: str = ''¶
- class chap_core.plotting.backtest_plot.EvaluationBackTestPlot(forecast_df: DataFrame, observed_df: DataFrame)[source]¶
Bases:
BackTestPlotBaseBacktest-plot that shows truth vs predictions over time.
- classmethod from_backtest(backtest: BackTest) EvaluationBackTestPlot[source]¶
Create a plot instance from a BackTest object.
Parameters¶
- backtestBackTest
The backtest object containing forecast and observation data
Returns¶
- BackTestPlotBase
An instance of the concrete plot class
- name: str = 'Evaluation Plot'¶
- chap_core.plotting.backtest_plot.clean_time(period)[source]¶
Convert period to ISO date format for Altair/vegafusion compatibility.
chap_core.plotting.conftest module¶
chap_core.plotting.dataset_plot module¶
- class chap_core.plotting.dataset_plot.DiseaseCasesMap(df: DataFrame, geojson=None)[source]¶
Bases:
DatasetPlot- plot_variable: str = 'disease_cases'¶
- class chap_core.plotting.dataset_plot.StandardizedFeaturePlot(df: DataFrame, geojson=None)[source]¶
Bases:
DatasetPlotThis plot shows standardized(zero mean, unit variance) features over time for different locations. It includes a log1p transformation of the disease incidence rate (disease_cases/population) This shows how different features correlate over time and location.
chap_core.plotting.evaluation_plot module¶
- class chap_core.plotting.evaluation_plot.MetricByHorizonAndLocationMean(metric_data: FlatMetric, geojson: dict | None = None)[source]¶
Bases:
MetricPlotV2- visualization_info = VisualizationInfo(id='metric_by_horizon', display_name='Horizon Plot', description='Shows the aggregated metric by forecast horizon')¶
- class chap_core.plotting.evaluation_plot.MetricByHorizonV2Mean(metric_data: FlatMetric, geojson: dict | None = None)[source]¶
Bases:
MetricPlotV2- visualization_info = VisualizationInfo(id='metric_by_horizon', display_name='Horizon Plot', description='Shows the aggregated metric by forecast horizon')¶
- class chap_core.plotting.evaluation_plot.MetricByHorizonV2Sum(metric_data: FlatMetric, geojson: dict | None = None)[source]¶
Bases:
MetricPlotV2- visualization_info = VisualizationInfo(id='metric_by_horizon_sum', display_name='Horizon Plot (sum)', description='Sums metric across locations per forecast horizon')¶
- class chap_core.plotting.evaluation_plot.MetricByTimePeriodAndLocationV2Mean(metric_data: FlatMetric, geojson: dict | None = None)[source]¶
Bases:
MetricPlotV2- visualization_info = VisualizationInfo(id='metric_by_time_period', display_name='Time Period Plot', description='Shows the aggregated metric by time period (per location)')¶
- class chap_core.plotting.evaluation_plot.MetricByTimePeriodV2Mean(metric_data: FlatMetric, geojson: dict | None = None)[source]¶
Bases:
MetricPlotV2- visualization_info = VisualizationInfo(id='metric_by_time_mean', display_name='Metric by time (mean)', description='Mean metric across locations and horizons per time period')¶
- class chap_core.plotting.evaluation_plot.MetricByTimePeriodV2Sum(metric_data: FlatMetric, geojson: dict | None = None)[source]¶
Bases:
MetricPlotV2- visualization_info = VisualizationInfo(id='metric_by_time_sum', display_name='Horizon Plot (sum)', description='Sums metric across locations per forecast horizon')¶
- class chap_core.plotting.evaluation_plot.MetricMapV2(metric_data: FlatMetric, geojson: dict | None = None)[source]¶
Bases:
MetricPlotV2- visualization_info = VisualizationInfo(id='metric_map', display_name='Map', description='Shows a map of aggregated metrics per org unit')¶
- class chap_core.plotting.evaluation_plot.MetricPlotV2(metric_data: FlatMetric, geojson: dict | None = None)[source]¶
Bases:
ABCRepresents types of metrics plots, that always start from raw FlatMetric data. Differnet plots can process this data in the way they want to produce a plot
- class chap_core.plotting.evaluation_plot.VisualizationInfo(*, id: str, displayName: str, description: str)[source]¶
Bases:
DBModel- description: str¶
- display_name: str¶
- id: str¶
- model_config: ClassVar[ConfigDict] = {'alias_generator': <function to_camel>, 'from_attributes': True, 'populate_by_name': True, 'registry': PydanticUndefined, 'validate_by_alias': True, 'validate_by_name': True}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- chap_core.plotting.evaluation_plot.make_plot_from_backtest_object(backtest: BackTest, plotting_class: MetricPlotV2, metric: MetricBase, geojson=None) Chart[source]¶
chap_core.plotting.prediction_plot module¶
Note: Some of this might be outdated, but plot_forecast_from_summaries is used in several places. is being used to create forecast plots.
- chap_core.plotting.prediction_plot.add_prediction_lines(fig, prediction_df, transform, true_df)[source]¶
- chap_core.plotting.prediction_plot.plot_forecast(quantiles: ndarray, true_data: HealthData, x_pred=None) Figure[source]¶
- chap_core.plotting.prediction_plot.plot_forecast_from_summaries(summaries: ~bionumpy.bnpdataclass.bnpdataclass.SummaryStatistics | list[~bionumpy.bnpdataclass.bnpdataclass.SummaryStatistics], true_data: ~bionumpy.bnpdataclass.bnpdataclass.HealthData, transform=<function <lambda>>) Figure[source]¶
chap_core.plotting.season_plot module¶
- class chap_core.plotting.season_plot.SeasonCorrelationBarPlot(*args, **kwargs)[source]¶
Bases:
SeasonCorrelationPlot- feature_name = 'mean_temperature'¶
- class chap_core.plotting.season_plot.SeasonCorrelationPlot(*args, **kwargs)[source]¶
Bases:
DatasetPlot
- class chap_core.plotting.season_plot.SeasonPlot(df: DataFrame, geojson=None)[source]¶
Bases:
DatasetPlot