Violin Plot Generation
- class SAES.plots.violin.Violin(data: DataFrame, metrics: DataFrame, metric: str)
Bases:
object
Class to generate violin plots for the performance results of different algorithms across multiple instances.
- Attributes:
- data (pd.DataFrame):
A pandas DataFrame containing the performance results of different algorithms across multiple instances.
- metric (str):
The metric to be used for comparison.
- algorithms (np.ndarray):
An array containing the names of the algorithms.
- instances (np.ndarray):
An array containing the names of the instances.
- logger (Logger):
A logger object to record and display log messages.
- Methods:
- __init__(data: pd.DataFrame, metrics: pd.DataFrame, metric: str):
Initializes the violin object with the given data, metrics, and metric.
- save_instance(instance: str, output_path: str):
Generates a violin for the specified instance and saves it to the specified output path.
- save_all_instances(output_path: str):
Generates a violin for all instances and saves it to the specified output path.
- show_instance(instance: str):
Generates a violin for the specified instance and displays it.
- show_all_instances():
Generates a violin for all instances and displays it.
- save_all_instances(output_path: str, file_name: str = None, width: int = 30) None
Generates a violin for all instances and saves it to the specified output path.
- Args:
- output_path (str):
The path where the violin image will be saved.
- file_name (str):
The name of the file to be saved. If None, a default name will be used.
- width (int):
The width of the violin image.
- Returns:
None
- Example:
>>> frtom SAES.plots.violin import Violin >>> import os >>> >>> data = pd.read_csv("data.csv") >>> metrics = pd.read_csv("metrics.csv") >>> metric = "HV" >>> violin = Violin(data, metrics, metric) >>> violin.save_all_instances(os.getcwd())
- save_instance(instance: str, output_path: str, file_name: str = None, width: int = 8) None
Generates a violin for the specified instance and saves it to the specified output path.
- Args:
- instance (str):
The name of the instance for which the violin is to be generated.
- output_path (str):
The path where the violin image will be saved.
- file_name (str):
The name of the file to be saved. If None, a default name will be used.
- width (int):
The width of the violin image.
- returns:
None
- Example:
>>> frtom SAES.plots.violin import Violin >>> import os >>> >>> data = pd.read_csv("data.csv") >>> metrics = pd.read_csv("metrics.csv") >>> metric = "HV" >>> violin = Violin(data, metrics, metric) >>> violin.save_instance("ZDT1", os.getcwd())
- show_all_instances(width: int = 30) None
Generates a violin for all instances and displays it.
- Args:
- width (int):
The width of the violin image.
- Returns:
None
- Example:
>>> frtom SAES.plots.violin import Violin >>> import os >>> >>> data = pd.read_csv("data.csv") >>> metrics = pd.read_csv("metrics.csv") >>> metric = "HV" >>> violin = Violin(data, metrics, metric) >>> violin.show_all_instances()
- show_instance(instance: str, width: int = 8) None
Generates a violin for the specified instance and displays it.
- Args:
- instance (str):
The name of the instance for which the violin is to be generated.
- width (int):
The width of the violin image.
- returns:
None
- Example:
>>> frtom SAES.plots.violin import Violin >>> import os >>> >>> data = pd.read_csv("data.csv") >>> metrics = pd.read_csv("metrics.csv") >>> metric = "HV" >>> violin = Violin(data, metrics, metric) >>> violin.show_instance("ZDT1")