Skip to content

Commit

Permalink
Pushing change for logging
Browse files Browse the repository at this point in the history
  • Loading branch information
shubham-s-agarwal committed May 9, 2024
1 parent decfbfb commit fbcdb70
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions medcat/config_meta_cat.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
from typing import Dict, Any
from medcat.config import MixingConfig, BaseModel, Optional, Extra
import logging


class General(MixingConfig, BaseModel):
"""The General part of the MetaCAT config"""
device: str = 'cpu'
log_level: int = logging.INFO
disable_component_lock: bool = False
seed: int = 13
description: str = "No description"
Expand Down
2 changes: 2 additions & 0 deletions medcat/meta_cat.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ def __init__(self,
config = ConfigMetaCAT()
self.config = config
set_all_seeds(config.general['seed'])
logging.basicConfig(level=self.config.general.log_level)
logger.setLevel(self.config.general.log_level)

if tokenizer is not None:
# Set it in the config
Expand Down
3 changes: 2 additions & 1 deletion medcat/utils/meta_cat/data_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ def encode_category_values(data: Dict, existing_category_value2id: Optional[Dict
for i in range(len(data)):
if data[i][2] in category_value2id.values():
label_data_[data[i][2]] = label_data_[data[i][2]] + 1
logger.info(f"Class distribution: {label_data_}")
# Undersampling data
if category_undersample is None or category_undersample == '':
min_label = min(label_data_.values())
Expand All @@ -232,7 +233,7 @@ def encode_category_values(data: Dict, existing_category_value2id: Optional[Dict
for i in range(len(data_undersampled)):
if data_undersampled[i][2] in category_value2id.values():
label_data[data_undersampled[i][2]] = label_data[data_undersampled[i][2]] + 1
logger.info(f"Updated label_data: {label_data}")
# logger.info(f"Updated label_data: {label_data}")

return data_undersampled, data, category_value2id

Expand Down

0 comments on commit fbcdb70

Please sign in to comment.