:py:mod:`medcat.config_meta_cat` ================================ .. py:module:: medcat.config_meta_cat Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: medcat.config_meta_cat.General medcat.config_meta_cat.Model medcat.config_meta_cat.Train medcat.config_meta_cat.ConfigMetaCAT .. py:class:: General Bases: :py:obj:`medcat.config.MixingConfig`, :py:obj:`medcat.config.BaseModel` The General part of the MetaCAT config .. py:class:: Config .. py:attribute:: extra .. py:attribute:: validate_assignment :value: True .. py:attribute:: device :type: str :value: 'cpu' .. py:attribute:: disable_component_lock :type: bool :value: False .. py:attribute:: seed :type: int :value: 13 .. py:attribute:: description :type: str :value: 'No description' Should provide a basic description of this MetaCAT model .. py:attribute:: category_name :type: medcat.config.Optional[str] What category is this meta_cat model predicting/training .. py:attribute:: category_value2id :type: Dict Map from category values to ID, if empty it will be autocalculated during training .. py:attribute:: vocab_size :type: medcat.config.Optional[int] Will be set automatically if the tokenizer is provided during meta_cat init .. py:attribute:: lowercase :type: bool :value: True If true all input text will be lowercased .. py:attribute:: cntx_left :type: int :value: 15 Number of tokens to take from the left of the concept .. py:attribute:: cntx_right :type: int :value: 10 Number of tokens to take from the right of the concept .. py:attribute:: replace_center :type: medcat.config.Optional[Any] If set the center (concept) will be replaced with this string .. py:attribute:: batch_size_eval :type: int :value: 5000 Number of annotations to be meta-annotated at once in eval .. py:attribute:: annotate_overlapping :type: bool :value: False If set meta_anns will be calcualted for doc._.ents, otherwise for doc.ents .. py:attribute:: tokenizer_name :type: str :value: 'bbpe' Tokenizer name used with of MetaCAT .. py:attribute:: save_and_reuse_tokens :type: bool :value: False This is a dangerous option, if not sure ALWAYS set to False. If set, it will try to share the pre-calculated context tokens between MetaCAT models when serving. It will ignore differences in tokenizer and context size, so you need to be sure that the models for which this is turned on have the same tokenizer and context size, during a deployment. .. py:attribute:: pipe_batch_size_in_chars :type: int :value: 20000000 How many characters are piped at once into the meta_cat class .. py:attribute:: span_group :type: medcat.config.Optional[str] If set, the spacy span group that the metacat model will assign annotations. Otherwise defaults to doc._.ents or doc.ents per the annotate_overlapping settings .. py:class:: Model Bases: :py:obj:`medcat.config.MixingConfig`, :py:obj:`medcat.config.BaseModel` The model part of the metaCAT config .. py:class:: Config .. py:attribute:: extra .. py:attribute:: validate_assignment :value: True .. py:attribute:: model_name :type: str :value: 'lstm' When changing model, make sure to change the tokenizer as well :type: NOTE .. py:attribute:: model_variant :type: str :value: 'bert-base-uncased' .. py:attribute:: model_freeze_layers :type: bool :value: True .. py:attribute:: num_layers :type: int :value: 2 .. py:attribute:: input_size :type: int :value: 300 .. py:attribute:: hidden_size :type: int :value: 300 .. py:attribute:: dropout :type: float :value: 0.5 .. py:attribute:: phase_number :type: int :value: 0 Indicates whether or not two phase learning is being performed. 1: Phase 1 - Train model on undersampled data 2: Phase 2 - Continue training on full data 0: None - 2 phase learning is not performed .. py:attribute:: category_undersample :type: str :value: '' .. py:attribute:: model_architecture_config :type: Dict .. py:attribute:: num_directions :type: int :value: 2 2 - bidirectional model, 1 - unidirectional .. py:attribute:: nclasses :type: int :value: 2 Number of classes that this model will output .. py:attribute:: padding_idx :type: int .. py:attribute:: emb_grad :type: bool :value: True If True the embeddings will also be trained .. py:attribute:: ignore_cpos :type: bool :value: False If set to True center positions will be ignored when calculating representation .. py:class:: Train Bases: :py:obj:`medcat.config.MixingConfig`, :py:obj:`medcat.config.BaseModel` The train part of the metaCAT config .. py:class:: Config .. py:attribute:: extra .. py:attribute:: validate_assignment :value: True .. py:attribute:: batch_size :type: int :value: 100 .. py:attribute:: nepochs :type: int :value: 50 .. py:attribute:: lr :type: float :value: 0.001 .. py:attribute:: test_size :type: float :value: 0.1 .. py:attribute:: shuffle_data :type: bool :value: True Used only during training, if set the dataset will be shuffled before train/test split .. py:attribute:: class_weights :type: medcat.config.Optional[Any] .. py:attribute:: compute_class_weights :type: bool :value: False If true and if class weights are not provided, the class weights will be calculated based on the data .. py:attribute:: score_average :type: str :value: 'weighted' What to use for averaging F1/P/R across labels .. py:attribute:: prerequisites :type: dict .. py:attribute:: cui_filter :type: medcat.config.Optional[Any] If set only this CUIs will be used for training .. py:attribute:: auto_save_model :type: bool :value: True Should do model be saved during training for best results .. py:attribute:: last_train_on :type: medcat.config.Optional[int] When was the last training run .. py:attribute:: metric :type: Dict[str, str] What metric should be used for choosing the best model .. py:attribute:: loss_funct :type: str :value: 'cross_entropy' Loss function for the model .. py:attribute:: gamma :type: int :value: 2 Focal Loss - how much the loss focuses on hard-to-classify examples. .. py:class:: ConfigMetaCAT Bases: :py:obj:`medcat.config.MixingConfig`, :py:obj:`medcat.config.BaseModel` The MetaCAT part of the config .. py:class:: Config .. py:attribute:: extra .. py:attribute:: validate_assignment :value: True .. py:attribute:: general :type: General .. py:attribute:: model :type: Model .. py:attribute:: train :type: Train