-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Print final training report as tabulated text. #2383
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,10 @@ | ||
import logging | ||
from collections import OrderedDict | ||
from typing import Dict, List | ||
from typing import Dict, List, Tuple | ||
|
||
from ludwig.constants import COMBINED, LOSS | ||
from ludwig.features.base_feature import OutputFeature | ||
from ludwig.modules.metric_modules import get_best_function | ||
from ludwig.utils.data_utils import load_json, save_json | ||
from ludwig.utils.metric_utils import TrainerMetric | ||
|
||
|
@@ -184,3 +185,50 @@ def get_final_steps_per_checkpoint( | |
return steps_per_epoch | ||
|
||
return steps_per_checkpoint | ||
|
||
|
||
def get_training_report( | ||
validation_field: str, | ||
validation_metric: str, | ||
include_test_set: bool, | ||
train_valiset_stats: Dict[str, Dict[str, List[float]]], | ||
train_testset_stats: Dict[str, Dict[str, List[float]]], | ||
) -> List[Tuple[str, str]]: | ||
"""Returns a training report in the form of a list [(report item, value)].""" | ||
validation_field_result = train_valiset_stats[validation_field] | ||
best_function = get_best_function(validation_metric) | ||
|
||
training_report = [] | ||
best_vali_index, ( | ||
epoch_best_validation_metric, | ||
step_best_validation_metric, | ||
best_validation_metric, | ||
) = best_function( | ||
enumerate(validation_field_result[validation_metric]), | ||
# -1 for the last element of the TrainerMetric namedtuple. | ||
key=lambda index_epoch_step_value: index_epoch_step_value[1][-1], | ||
) | ||
training_report.append(["Validation feature", validation_field]) | ||
training_report.append(["Validation metric", validation_metric]) | ||
training_report.append(["Best model step", step_best_validation_metric]) | ||
training_report.append(["Best model epoch", epoch_best_validation_metric + 1]) | ||
training_report.append( | ||
[ | ||
f"Best model's validation {validation_metric}", | ||
best_validation_metric, | ||
] | ||
) | ||
if include_test_set: | ||
validation_selected_test_metric_score = train_testset_stats[validation_field][validation_metric][ | ||
best_vali_index | ||
][ | ||
-1 | ||
] # -1 for the last element of the TrainerMetric namedtuple. | ||
|
||
training_report.append( | ||
[ | ||
f"Best model's test {validation_metric}", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @justinxzhao Same as the previous comment |
||
validation_selected_test_metric_score, | ||
] | ||
) | ||
return training_report |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@justinxzhao Would it potentially make sense to mention that this is the combined loss?