modeva.utils.results.ValidationResult#
- class modeva.utils.results.ValidationResult(key, data=None, model=None, inputs=None, value=None, table=None, func=None, options=None)#
Bases:
object
A class to handle validation results and plotting functionality.
This class stores validation data and provides methods to plot and save figures using the mocharts library.
- key#
Name of the validation result
- Type:
str
- data#
Data used in the validation
- Type:
str, default=None
- model#
Model used in the validation
- Type:
str, default=None
- inputs#
Input arguments used in the validation
- Type:
dict, default=None
- value#
Detailed validation result values
- Type:
any, default=None
- table#
Table data associated with the validation
- Type:
pd.DataFrame or dict of pd.DataFrame, default=None
- func#
Function used in the validation
- Type:
any, default=None
- options#
Plotting options and configurations
- Type:
dict, default=None
- get_figure_names()#
Show the list of figure names.
- Returns:
name_list – The list of figure names. Will return an empty list if there is only one figure, and it has no names.
- Return type:
list of str
- plot(name: [<class 'str'>, <class 'int'>, <class 'float'>, typing.Tuple] = None, figsize: ~typing.Tuple[int] = (6, 6), display: bool = False, n_bars: int = None, popup: bool = True)#
Show the figure results.
- Parameters:
name (str, int, float, tuple, default=None) – The name of the figure to visualize. The available figure names can be fetched by func get_figure_names. If None, then all figures will be displayed.
figsize (tuple, default=(6, 6)) – The size of displayed figure(s).
display (bool, default=False) – Whether to display the figure.
n_bars (int, default=None) – The number of displayed bars (from top).
popup (bool, default=True) – Whether to support popup for each plot
- Returns:
fig – The figure object in html format.
- Return type:
HTML object
- plot_save(name: str | int | float | Tuple = None, figsize: Tuple[int] = (6, 6), file_name: str = None, format: str = 'png')#
Generate and save figures based on validation options.
This method visualizes and saves figures created from the validation options using the mocharts library. The figures can be filtered by name, resized, and saved to a specified file path in the given format.
- Parameters:
name (str, int, float, tuple, default=None) – The name(s) of the figure(s) to visualize and save. Can be a single name or a tuple/list of names. To retrieve valid figure names, call self.get_figure_names(). If None, all available figures are processed.
figsize (tuple, default=(6, 6)) – The size (width, height) of the figure(s) to save, in inches.
file_name (str, default=None) – The base file path and name to save the figure(s). If None, the figure will be saved in the ‘images/’ directory using the self.key as the filename prefix. If multiple figures are saved, this will serve as the prefix for each figure’s name.
format (str, default='png') – The format to save the figure(s), e.g., ‘png’, ‘jpg’, ‘svg’.
- Raises:
ValueError – If an invalid name is provided, or if an unsupported key type is encountered.
Notes
The function automatically creates an ‘images/’ folder if no file path is specified.
Figure names are constructed by combining the file_name (if provided) and the figure’s key.