medcat.rel_cat
Module Contents
Classes
The RelCAT class used for training 'Relation-Annotation' models, i.e., annotation of relations |
- class medcat.rel_cat.RelCAT(cdb, tokenizer, config=ConfigRelCAT(), task='train', init_model=False)
Bases:
medcat.pipeline.pipe_runner.PipeRunner
- The RelCAT class used for training ‘Relation-Annotation’ models, i.e., annotation of relations
between clinical concepts.
- Parameters:
cdb (CDB) – cdb, this is used when creating relation datasets.
tokenizer (TokenizerWrapperBERT) – The Huggingface tokenizer instance. This can be a pre-trained tokenzier instance from a BERT-style model. For now, only BERT models are supported.
config (ConfigRelCAT) – the configuration for RelCAT. Param descriptions available in ConfigRelCAT docs.
task (str, optional) – What task is this model supposed to handle. Defaults to “train”
init_model (bool, optional) – loads default model. Defaults to False.
- name = 'rel_cat'
- log
- __init__(cdb, tokenizer, config=ConfigRelCAT(), task='train', init_model=False)
- Parameters:
cdb (medcat.cdb.CDB) –
tokenizer (medcat.utils.relation_extraction.tokenizer.TokenizerWrapperBERT) –
config (medcat.config_rel_cat.ConfigRelCAT) –
- save(save_path)
- Saves model and its dependencies to specified save_path folder.
The CDB is obviously not saved, it is however necessary to save the tokenizer used.
- Parameters:
save_path (str) – folder path in which to save the model & deps.
- Return type:
None
- _get_model()
Used only for model initialisation.
- _create_test_train_datasets(data, split_sets=False)
- Parameters:
data (Dict) –
split_sets (bool) –
- train(export_data_path='', train_csv_path='', test_csv_path='', checkpoint_path='./')
- Parameters:
export_data_path (str) –
train_csv_path (str) –
test_csv_path (str) –
checkpoint_path (str) –
- evaluate_(output_logits, labels, ignore_idx)
- evaluate_results(data_loader, pad_id)
- pipe(stream, *args, **kwargs)
- Parameters:
stream (Iterable[spacy.tokens.Doc]) –
- Return type:
Iterator[spacy.tokens.Doc]
- __call__(doc)
- Parameters:
doc (spacy.tokens.Doc) –
- Return type:
spacy.tokens.Doc