icat.anchors.SimilarityAnchorBase#

class icat.anchors.SimilarityAnchorBase(container=None, *args, **kwargs)#

Bases: Anchor

A base class to inherit from for anchors that featurize based on some metric of similarity to a set of one or more target reference texts.

Methods

__init__([container])

anchor_types()

Get a list of references to all defined Anchor subclasses in scope (directly and indirectly.)

featurize(data)

Create an anchor weight from the passed dataframe.

fire_on_anchor_changed(key, value)

Trigger the event to notify that some property on this anchor changed.

load(path)

Load anchor from specified path.

on_anchor_changed(callback)

Register a callback for the anchor_changed event.

remove_by_short(short_text)

Delete one of the reference texts based on the short version.

row_view()

save(path)

Save anchor to specified path.

to_dict()

Get a dictionary of all relevant parameters that define this anchor.

Attributes

DESCRIPTION

Subclasses of Anchor can define this DESCRIPTION to show up in the UI explaining the given anchor type.

NAME

Subclasses of Anchor can define this NAME to show up in the UI as the default name for this anchor type.

anchor_name

Not to be confused with just name, which is the panel component id.

global_cache

An anchor list level cache, (dictionary of key-value pairs) any keys set here are accessible by all other anchors.

in_model

Whether to include this feature in the training process.

in_view

Whether to show this anchor in anchorviz.

name

param

reference_short

A shortform version of the texts, either the row IDs if available, or just the first few words

reference_texts

The target texts to calculate the similarity to.

text_col

The text column from the data to use when measuring similarity.

weight

Scalar multiple to apply to all output features, the user can change this to modify how much a particular feature influences the model.

cache

A dictionary of key-value pairs specific to this one anchor instance that gets saved when save() is called (by default).

featurize(data)#

Create an anchor weight from the passed dataframe.

Note

Expected to be overridden in subclasses.

Parameters:

data (DataFrame) –

Return type:

Series

name = 'SimilarityAnchorBase'#
reference_short = []#

A shortform version of the texts, either the row IDs if available, or just the first few words

reference_texts = []#

The target texts to calculate the similarity to.

remove_by_short(short_text)#

Delete one of the reference texts based on the short version.

text_col = ''#

The text column from the data to use when measuring similarity.

to_dict()#

Get a dictionary of all relevant parameters that define this anchor.

Return type:

dict[str, any]