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.)

debug(**kwargs)

Inspect .param.debug method for the full docstring

defaults(**kwargs)

Inspect .param.defaults method for the full docstring

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.

force_new_dynamic_value(**kwargs)

Inspect .param.force_new_dynamic_value method for the full docstring

get_param_values(**kwargs)

Inspect .param.get_param_values method for the full docstring

get_value_generator(**kwargs)

Inspect .param.get_value_generator method for the full docstring

inspect_value(**kwargs)

Inspect .param.inspect_value method for the full docstring

load(path)

Load anchor from specified path.

message(**kwargs)

Inspect .param.message method for the full docstring

on_anchor_changed(callback)

Register a callback for the anchor_changed event.

params(**kwargs)

Inspect .param.params method for the full docstring

pprint(*args, **kwargs)

print_param_defaults(*args, **kwargs)

Inspect .param.print_param_defaults method for the full docstring

print_param_values(**kwargs)

Inspect .param.print_param_values method for the full docstring

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.

script_repr([imports, prefix])

Deprecated variant of __repr__ designed for generating a runnable script.

set_default(*args, **kwargs)

Inspect .param.set_default method for the full docstring

set_dynamic_time_fn(**kwargs)

Inspect .param.set_dynamic_time_fn method for the full docstring

set_param(**kwargs)

Inspect .param.set_param method for the full docstring

state_pop()

Restore the most recently saved state.

state_push()

Save this instance's state.

to_dict()

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

verbose(**kwargs)

Inspect .param.verbose method for the full docstring

warning(**kwargs)

Inspect .param.warning method for the full docstring

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]