casanovoutils.graphloss#
Plot Casanovo training and validation loss.
This script reads one or more Casanovo training logs (either a log file or a metrics.csv file) and produces a PNG plot of training and validation loss as a function of step/iteration.
Output is written to <root>.png.
Attributes#
Functions#
|
Read train/validation loss series from a Casanovo log file. |
|
Read train/validation loss series from a Casanovo metrics.csv file. |
|
Determine whether the input is a log file or a metrics CSV. |
|
Read losses from a Casanovo log file or metrics CSV. |
|
Create and save the loss plot. |
|
Read Casanovo log and/or metrics.csv files and plot training/validation loss. |
|
Module Contents#
- type casanovoutils.graphloss.LossSeries = list[tuple[int, float]]#
- casanovoutils.graphloss.read_from_logfile(input_path: pathlib.Path) tuple[LossSeries, LossSeries]#
Read train/validation loss series from a Casanovo log file.
- Parameters:
input_path – Path to a text log file produced during Casanovo training.
- Returns:
Two lists of
(step, loss)tuples.- Return type:
(train_losses, val_losses)
- casanovoutils.graphloss.read_from_csvfile(input_path: pathlib.Path) tuple[LossSeries, LossSeries]#
Read train/validation loss series from a Casanovo metrics.csv file.
- Parameters:
input_path – Path to a CSV file containing Casanovo metrics.
- Returns:
Two lists of
(step, loss)tuples.- Return type:
(train_losses, val_losses)
- casanovoutils.graphloss.detect_input_format(input_path: pathlib.Path) str#
Determine whether the input is a log file or a metrics CSV.
The detection is based on filename conventions and a quick header sniff.
- Parameters:
input_path – Path to an input file.
- Returns:
Either
"csv"or"log".- Return type:
format
- casanovoutils.graphloss.read_from_file(input_path: pathlib.Path) tuple[LossSeries, LossSeries]#
Read losses from a Casanovo log file or metrics CSV.
- casanovoutils.graphloss.plot_losses(root: str, train_loss_lists: list[LossSeries], val_loss_lists: list[LossSeries], max_y: float | None) None#
Create and save the loss plot.
- Parameters:
root – Output file root name. Output is written to
{root}.png.train_loss_lists – A sequence of training loss series.
val_loss_lists – A sequence of validation loss series.
max_y – Optional y-axis maximum.
- casanovoutils.graphloss.plot(root: str, inputs: list[str], max_y: float | None = None) None#
Read Casanovo log and/or metrics.csv files and plot training/validation loss.
- Parameters:
root – Output file root; plot will be written to
<root>.pngand log to<root>.log.inputs – One or more input files (Casanovo log files or
metrics.csvfiles).max_y – Optional y-axis maximum.
- casanovoutils.graphloss.COMMANDS: casanovoutils.types.Commands#
- casanovoutils.graphloss.main() None#