Logging and Visualization
This reference explains how logging and visualization work in BojAI, focusing on the Logger and Visualizer classes. These tools allow you to track your model’s training and evaluation performance over time.
Logging in trainer.py
Logging is only available inside trainer.py and is done using the Logger singleton class. You can access it inside the trainer class like this:
self.logger
What You Can Log
You can log:
| Name | Logged with | Meaning |
|---|---|---|
| Loss | loss=... |
Training loss at each epoch |
| Train | train=... |
Training accuracy/score at each epoch |
| Valid | valid=... |
Validation accuracy/score at each epoch |
| Eval | eval_score=... |
Final evaluation score (post-training) |
How to Log
# Logging during training
self.logger.log(epoch=epoch, loss=loss, train=score, valid=val_score)
# Logging final evaluation score
self.logger.log(eval_score=final_score)
⚠️ You must always pass an
epochwhen logging training, validation, or loss.
Do not logeval_scorein the same call as training/validation metrics.
This prevents optimization bias.
Visualization with Visualizer
BojAI’s Visualizer reads the log from the Logger class and plots it using Matplotlib.
It supports four kinds of plots:
In the Train Stage
You can access:
Loss vs EpochTraining vs Validation
In the Deploy Stage
You can access:
- All four options below, if evaluation data is uploaded
- Only the first two, if evaluation data is not uploaded
The 4 Visualization Options
1. Loss vs Epoch
Plots how the training loss evolves over time.
visualizer.plot_loss()
Used to diagnose underfitting, overfitting, or unstable training.
2. Training vs Validation
Plots training vs validation performance per epoch.
visualizer.plot_validation_vs_training()
Helps you compare generalization quality and identify divergence.
3. Mean Train vs Eval (Deploy stage only)
Compares the average training score with the final evaluation score.
visualizer.plot_train_vs_eval()
Useful to spot overfitting if eval is much worse than train.
4. Mean Validation vs Eval (Deploy stage only)
Compares the average validation score with the final evaluation score.
visualizer.plot_valid_vs_eval()
Helps understand whether the validation set was representative of the evaluation set.