Skip to content

Commit

Permalink
chore: improve logging
Browse files Browse the repository at this point in the history
  • Loading branch information
severinsimmler committed Mar 15, 2022
1 parent a3e4428 commit 1692ea4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions chaine/crf.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from chaine._core.crf import Model as _Model
from chaine._core.crf import Trainer as _Trainer
from chaine.logging import Logger
from chaine.logging import Logger, set_level
from chaine.optimization.spaces import (
APSearchSpace,
AROWSearchSpace,
Expand Down Expand Up @@ -182,7 +182,7 @@ def train(
model_filepath : Filepath, optional (default=model.chaine)
Path to model location.
"""
LOGGER.info("Loading training data")
LOGGER.info("Start training")
for i, (sequence, labels_) in enumerate(zip(dataset, labels)):
if not is_valid_sequence(sequence):
raise ValueError(f"Invalid format: {sequence}")
Expand Down Expand Up @@ -277,6 +277,9 @@ def optimize_hyperparameters(
list[dict[str, dict]]
Sorted list of hyperparameters and evaluation scores.
"""
# make logging less verbose
set_level("chaine._core.crf", "ERROR")

# set random seed
random.seed(self.seed)

Expand Down Expand Up @@ -309,6 +312,9 @@ def optimize_hyperparameters(
LOGGER.info(f"Best baseline: {baselines[0][f'mean_{self.metric}']}")
LOGGER.info(f"Best optimized model: {results[0]['stats'][f'mean_{self.metric}']}")

# make logging verbose again
set_level("chaine._core.crf", "INFO")

return results

def _metric(self, trial: dict[str, dict]) -> float:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "chaine"
version = "2.0.0a3"
version = "2.0.0a4"
description = "Linear-chain conditional random fields for natural language processing"
authors = ["Severin Simmler <[email protected]>"]
readme = "README.md"
Expand Down

0 comments on commit 1692ea4

Please sign in to comment.