icat.anchors.DictionaryAnchor#
- class icat.anchors.DictionaryAnchor(container=None, **params)#
Bases:
AnchorA 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
Noneif defining an anchor manually, any timeadd_anchoris 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.)
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.
load(path)Load anchor from specified path.
on_anchor_changed(callback)Register a callback for the anchor_changed event.
regex()Return a regex string that would capture what this anchor is featurizing on.
row_view()save(path)Save anchor to specified path.
to_dict()Get a dictionary of all relevant parameters that define this anchor.
Attributes
Subclasses of
Anchorcan define this DESCRIPTION to show up in the UI explaining the given anchor type.Subclasses of
Anchorcan define this NAME to show up in the UI as the default name for this anchor type.anchor_nameNot to be confused with just
name, which is the panel component id.global_cacheAn anchor list level cache, (dictionary of key-value pairs) any keys set here are accessible by all other anchors.
in_modelWhether to include this feature in the training process.
in_viewWhether to show this anchor in anchorviz.
The list of keywords this anchor is searching for.
The direct 'backend model' for what's in the keywords text field.
paramThe column in the dataset containing the texts to search through.
weightScalar multiple to apply to all output features, the user can change this to modify how much a particular feature influences the model.
cacheA 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
Anchorcan define this DESCRIPTION to show up in the UI explaining the given anchor type.
- NAME: str = 'Dictionary'#
Subclasses of
Anchorcan 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
keywordsparameter.
- 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]