medcat.components.linking.two_step_context_based_linker
Classes:
-
PerEntityWeights– -
TwoStepLinker–Link to a biomedical database.
-
TwoStepLinkerConfig–
Functions:
Attributes:
-
TYPE_ID_PREFIX(str) – -
logger–
PerEntityWeights
PerEntityWeights(doc: MutableDocument)
Bases: MutableMapping[MutableEntity, dict[str, float]]
Methods:
-
keys–
Source code in medcat-v2/medcat/components/linking/two_step_context_based_linker.py
308 309 310 | |
keys
keys() -> KeysView[MutableEntity]
Source code in medcat-v2/medcat/components/linking/two_step_context_based_linker.py
344 345 | |
TwoStepLinker
Bases: AbstractCoreComponent
Link to a biomedical database.
Parameters:
Methods:
-
create_new_component– -
get_type– -
train–Train the linker.
Attributes:
-
cdb– -
config– -
name– -
two_step_config(TwoStepLinkerConfig) – -
vocab–
Source code in medcat-v2/medcat/components/linking/two_step_context_based_linker.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | |
name
class-attribute
instance-attribute
name = 'medcat2_two_step_linker'
create_new_component
classmethod
create_new_component(cnf: ComponentConfig, tokenizer: BaseTokenizer, cdb: CDB, vocab: Vocab, model_load_path: Optional[str]) -> TwoStepLinker
Source code in medcat-v2/medcat/components/linking/two_step_context_based_linker.py
257 258 259 260 261 262 | |
get_type
get_type() -> CoreComponentType
Source code in medcat-v2/medcat/components/linking/two_step_context_based_linker.py
76 77 | |
train
train(cui: str, entity: MutableEntity, doc: MutableDocument, negative: bool = False, names: Union[list[str], dict] = []) -> None
Train the linker.
This simply trains the context model.
Parameters:
-
(cuistr) –The CUI to train.
-
(entityBaseEntity) –The entity we're at.
-
(docBaseDocument) –The document within which we're working.
-
(negativebool, default:False) –Whether or not the example is negative. Defaults to False.
-
(nameslist[str] / dict, default:[]) –Optionally used to update the
statusof a name-cui pair in the CDB.
Source code in medcat-v2/medcat/components/linking/two_step_context_based_linker.py
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 | |
TwoStepLinkerConfig
Bases: SerialisableBaseModel
Attributes:
-
alpha_midpoint(float) –The midpoint for the sigmoid.
-
alpha_sharpness(float) –The sharpness for the sigmoid.
-
type_learning_rate_coefficient(float) –The coefficient for the type-based context model learning rate.
alpha_midpoint
class-attribute
instance-attribute
alpha_midpoint: float = 0.5
The midpoint for the sigmoid. alpha = sigmoid(alpha_sharpness(similarity - alpha_midpoint)) This is used for weighting the type similarity vs the concept similarity.
alpha_sharpness
class-attribute
instance-attribute
alpha_sharpness: float = 5.0
The sharpness for the sigmoid. alpha = sigmoid(alpha_sharpness(similarity - alpha_midpoint)) This is used for weighting the type similarity vs the concept similarity.
type_learning_rate_coefficient
class-attribute
instance-attribute
type_learning_rate_coefficient: float = 0.2
The coefficient for the type-based context model learning rate.
The idea is that since there's a far fewer classes for types, we need to lower the learning rate. In the Snomed examples we have around 10 000 more CUIs then types so a coefficient like 0.2 should be appropriate.
add_tuis_to_cui_info
Source code in medcat-v2/medcat/components/linking/two_step_context_based_linker.py
30 31 32 33 34 35 36 37 | |
changed_learning_rate
changed_learning_rate(config: Config, two_step_cnf: TwoStepLinkerConfig)
Source code in medcat-v2/medcat/components/linking/two_step_context_based_linker.py
348 349 350 351 352 353 354 355 356 357 358 359 | |
temp_attribute
Source code in medcat-v2/medcat/components/linking/two_step_context_based_linker.py
383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 | |