carate.plotting package

Submodules

carate.plotting.base_plots module

Plotting module for PyTorch prototyping.

author:

Julian M. Kleber

carate.plotting.base_plots.load_result_json_old_format(path_to_json: str) Dict[str, Any][source]

The load_result_json function takes in a path to a json file and returns the contents of that json file as a dictionary.The function also parses the “Acc” key in the dictionary, which contains lists of tuples containing train and test accuracy values. The function then separates these tuples into two separate lists, one for train accuracy values and one for test accuracy values.These new lists are added to the original dictionary under keys “Acc_train” and “Acc_val”, respectively.

Parameters:

path_to_json – str: Used to Specify the path to the json file.

Returns:

A dictionary with the following keys:. :doc-author: Julian M. Kleber

carate.plotting.base_plots.parse_min_max_avg(result_list: List[List[float]]) List[float][source]

The parse_min function takes a list of lists and returns the minimum value for each sublist.

Parameters:

result_list – List[List[float]]: Used to Store the results of the simulation.

Returns:

A list of the minimum values for each step. :doc-author: Julian M. Kleber

carate.plotting.base_plots.parse_old_file_format_for_plot(path_to_json: str) List[List[float]][source]

The parse_old_file_format_for_plot function takes in a path to a json file and returns the following:

Parameters:

path_to_json:str – Used to Specify the path to the json file that we want to parse.

Returns:

A list of dictionaries.

Doc-author:

Julian M. Kleber

carate.plotting.base_plots.plot_range_band_multi(result: List[Dict[str, float]], key_vals: List[str], file_name: str, alpha: float = 0.5, y_lim: Tuple[float] = (0.0, 1.01), set_ylim_dynamically: bool = False, save_dir: str | None = None, title_text: str | None = None) None[source]

The plot_range_band_multi function is used to plot multiple range bands on the same graph. The function takes in a list of dictionaries, each dictionary containing the results from one cross-validation run.It also takes in a list of keys that correspond to values within each dictionary that should be plotted as range bands. The function then plots all these values as separate lines with their corresponding ranges filled in between them.

Parameters:
  • result – List[Dict[str: Used to Pass in the list of dictionaries :param float]]: Used to Set the alpha value of the fill.

  • key_vals – List[str]: Used to Specify which metrics to plot.

  • file_name – str: Used to name the file that will be saved.

  • alpha – float=0.5: Used to Set the transparency of the fill between.

  • save_dir – Optional[str]=None: Used to Save the plot in a specific directory.

:paramUsed to Set the transparency of the fill between min and

max values.

Returns:

A plot of the average, maximum and minimum values. :doc- author: Julian M. Kleber

carate.plotting.base_plots.plot_range_band_single(result: List[Dict[str, List[float]]], key_val: str, file_name: str, alpha: float = 0.5, fixed_y_lim=(0.0, 1.01), set_ylim_dynamically: bool = False, save_dir: str | None = None, legend_text: str | None = None) None[source]

The plot_range_band function takes in a list of dictionaries, each dictionary containing the results from one run. It then plots the average value for each key_val (e.g., ‘accuracy’) and also plots a range band between the minimum and maximum values for that key_val across all runs.

Parameters:
  • result – List[Dict[str: Used to plot the results of each run. :param float]]: Used to specify the type of data that is being passed into the function.

  • key_val – str: Used to specify which key in the dictionary to plot.

  • file_name – str: Used to specify the file_name on where to save the plot

Param:

alpha: float: Set the alpha level of the range band

Param:

fixed_y_lim: str: Setting a fixed limit on the y_axis

Param:

set_ylim_dynamically: bool: If the y_lim should be set based on min, max values of the defined key_val

Param:

save_dir: str: Where to save the plot

Param:

legend_text: Text to put on the legend

Returns:

None, but saves a plot with the average value of a list, and the minimum and maximum values.

Doc-author:

Julian M. Kleber

Author:

Julian M. Kleber

carate.plotting.base_plots.plot_range_fill(max_val: List[float], min_val: List[float], alpha: float, axis) None[source]

The plot_range_lines function takes in three lists of floats, max_val, min_val and avg_val. It then plots the average value as a line graph with the training steps on the x-axis and the average values on the y-axis. It also fills in between each point with a color to show the range of values for that particular step.

Parameters:
  • max_val – List[float]: Used to Plot the maximum value of each training step.

  • min_val – List[float]: Used to Plot the minimum value of each metric.

  • avg_val – List[float]: Used to Plot the average value of a given metric.

Returns:

A plot with the average value, max value and min values for each training step. :doc-author: Julian M. Kleber

carate.plotting.base_plots.plot_trajectory_single_algorithm(path_to_directory: str, parameter: str, save_dir: str = './plots', data_name: str | None = None) None[source]

The plot_classification_algorithm function takes in a path to a directory containing the results of a classification algorithm and plots the accuracy of that algorithm on both training and testing data.

Parameters:

path_to_directory – str: Used to specify the directory where the results are stored.

Returns:

None. :doc-author: Julian M. Kleber

carate.plotting.base_plots.save_publication_graphic(fig_object: Type[figure], file_name: str, prefix: str | None = None) None[source]

The save_publication_graphic function saves the current figure to a file.

The save_publication_graphic function saves the current figure to a file, with a default resolution of 300 dpi. The function also tightens up the layout of the plot before saving it, so that there is no wasted space around it in its saved form.

Parameters:
  • file_name – str: Used to Specify the name of the file to be saved.

  • prefix – Optional[str]=None: Used to Specify the directory where the file is saved.

Returns:

None. :doc-author: Julian M. Kleber

carate.plotting.multi_run module

Module for routine multi-run plotting.

author:

Julian M. Kleber

carate.plotting.multi_run.ploat_range_band_multi_val() None[source]
carate.plotting.multi_run.plot_all_runs_in_dir(base_dir: str, save_name: str, legend_texts: List[str], val_single: str = 'Acc_test', num_cv: int = 5, y_lims=(0.0, 1.01)) None[source]

Function to plot hyperparameter tunins of a single dataset and algorithm inside a directory

Author:

Julian M. Kleber

carate.plotting.multi_run.plot_range_band_multi_run(result: List[Dict[str, List[float]]], key_val: str, file_name: str, fig, axis, alpha: float = 0.5, fixed_y_lim=(0.0, 1.01), save_dir: str | None = None, legend_text: str | None = None) None[source]

The plot_range_band function takes in a list of dictionaries, each dictionary containing the results from one run. The function is meant to be used in a for-loop iterating about many runs. It then plots the average value for each key_val (e.g., ‘accuracy’) and also plots a range band between the minimum and maximum values for that key_val across all runs.

Parameters:
  • result – List[Dict[str: Used to plot the results of each run. :param float]]: Used to specify the type of data that is being passed into the function.

  • key_val – str: Used to specify which key in the dictionary to plot.

  • file_name – str: Used to save the plot as a png file.

Returns:

A plot with the average value of a list, and the minimum and maximum values. :doc-author: Julian M. Kleber

carate.plotting.multi_run.prepare_plot_multi(base_dir: str, run_dir: str, val_single: str, num_cv: int = 5)[source]

Module contents