icat.anchors.DictionaryAnchor#

class icat.anchors.DictionaryAnchor(container=None, **params)#

Bases: Anchor

A bag-of-words feature that returns raw count value sum of the number of occurrences of each word in the given keywords.

Parameters:

container (AnchorList) – The containing anchor list parent instance. This can usually be left None if defining an anchor manually, any time add_anchor is called, the anchor list will take care of setting this on all children anchors.

Example

my_keywords_anchor = DictionaryAnchor(anchor_name="ML", keywords=["machine learning", "artificial intelligence"])
my_model.add_anchor(my_keywords_anchor)

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)

Get a count of keywords in this anchor for every text in the data.

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

regex()

Return a regex string that would capture what this anchor is featurizing on.

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.

keywords

The list of keywords this anchor is searching for.

keywords_str

The direct 'backend model' for what's in the keywords text field.

name

param

text_col

The column in the dataset containing the texts to search through.

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

DESCRIPTION: str = 'Bag of words (feature is count of specified keyword occurrences.)'#

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

NAME: str = 'Dictionary'#

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

featurize(data)#

Get a count of keywords in this anchor for every text in the data. Note that this uses the text_col set on this anchor.

Parameters:

data (DataFrame) –

Return type:

Series

keywords = []#

The list of keywords this anchor is searching for.

keywords_str = ''#

The direct ‘backend model’ for what’s in the keywords text field. This is really only needed for internal use, any programmatic manipulation of the anchor’s keywords should be done through the keywords parameter.

name = 'DictionaryAnchor'#
regex()#

Return a regex string that would capture what this anchor is featurizing on.

Return type:

str

row_view()#
Return type:

Row

text_col = ''#

The column in the dataset containing the texts to search through.

to_dict()#

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

Return type:

dict[str, any]