CompareModels#
- class CompareModels(models, names=None)[source]#
Class for visually comparing pastas Models.
This is a versatile class for constructing visual model comparison plots. The default CompareModels.plot() method mimics ml.plots.results() but allows multiple models to be included in the figure. Instead of parameter uncertainties, by default only optimal values are shown for each model and a table containing fit metrics is included in the top right of the figure.
The visualization of each component (i.e. time series, a table) is controlled by separate functions allowing users to easily customize their figure. The layout of the figure is controlled by a so-called “mosaic”, which is essentially a 2D array (in the form of nested lists) containing labels that refer to specific axes:
mosaic = [ ["sim", "sim", "met"], # oseries+simulation (2x2), metrics (1x1) ["sim", "sim", "tab"], # oseries+simulation (2x2), parameters (2x1) ["res", "res", "tab"], # residuals+noise (1x2), parameters (2x1) ["con0", "con0", "rf0"] # contributions (1x2), step response (1x1) ]
In this example, the “sim” axis will be 2x2 in the top left portion of the figure (with total dimensions (4x3)), while the “met” axis will be 1x1 in the top right. Users can either use the default mosaic or provide their own.
Additional logic is available to control plotting of multiple contributions of stresses on the same set of axes. Additionally, some helper methods are defined to obtain relevant information from the models passed to CompareModels.
Example usage:
mc = ps.CompareModels([ml1, ml2]) mc.plot() # obtain axes handles sim_ax = mc.axes["sim"] sim_ax.grid(False) # save figure mc.figure.savefig("modelcomparison.png")
Methods#
Initialize model compare class. |
|
Get default mosaic for matplotlib.subplot_mosaic(). |
|
Get p-values of statistical tests in a DataFrame. |
|
get metrics of all models in a DataFrame. |
|
get parameter values of all models in a DataFrame. |
|
get tmin and tmax of all models. |
|
Get all unique stressmodel names. |
|
initialize subplots based on a mosaic with equal vertical scales. |
|
initialize a custom figure based on a mosaic. |
|
plot the models in a comparison plot. |
|
plot autocorrelation plot. |
|
plot stressmodel contributions. |
|
plot noise. |
|
Plot all oseries, unless all oseries are the same. |
|
plot residuals. |
|
plot step or block responses. |
|
plot model simulation. |
|
plot stresses time series. |
|
Plot dataframe as table. |
|
plot diagnostics table. |
|
plot metrics table. |
|
plot model parameters table. |
|
share x-axes. |
|
share y-axes. |