icat.anchors.Anchor#

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

Bases: Parameterized

The main parent anchor class, this should be subclassed, not directly used.

Parameters:
  • container (AnchorList) – The anchor list that this anchor is a part of. If you are creating the anchor manually, leave this None, it will get populated automatically.

  • anchor_name (str) – The label to show for this anchor.

  • weight (float) – Scalar multiple to apply to the output feature, this modifies how strongly a particular feature is likely to influence the model.

  • in_view (bool) – Whether to show this anchor in anchorviz.

  • in_model (bool) – Whether to include this feature in the training process.

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

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 this anchor's parameters.

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

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 = ''#

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

NAME: str = ''#

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

anchor_name = 'New Anchor'#

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

static anchor_types()#

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

cache: dict[str, any]#

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

fire_on_anchor_changed(key, value)#

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

Parameters:

key (str) –

property global_cache: dict[str, any]#

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

This is useful to use if a particular anchor type has computation heavy steps that should only need to run once, e.g. if a transformer needs to pre-compute the embeddings of all points in the dataset (and every anchor using that transformer should have access to the same embeddings.)

in_model = True#

Whether to include this feature in the training process. (it will be included in the featurization call and will update locations inside anchorviz, it simply won’t be passed to the model.)

in_view = True#

Whether to show this anchor in anchorviz.

load(path)#

Load anchor from specified path.

Parameters:

path (str) –

name = 'Anchor'#
on_anchor_changed(callback)#

Register a callback for the anchor_changed event.

Callbacks for this event should take three parameters: * Name (string) (this is the internal panel name, which we use as the anchor id.) * Property name (string) that’s changing on the anchor. * Value that the property on the anchor was changed to.

Parameters:

callback (Callable) –

row_view()#
Return type:

Row

save(path)#

Save anchor to specified path.

Parameters:

path (str) –

to_dict()#

Get a dictionary of this anchor’s parameters. Useful for easily implementing save functionality.

Return type:

dict[str, any]

weight = 1.0#

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