Custom Config
hovercan be customized through its module config.
Let's explore a few use cases.
This page assumes that you have know the basics
i.e. simple usage of dataset and annotator. Please visit the quickstart tutorial if you haven't done so.
Running Python right here
Think of this page as almost a Jupyter notebook. You can edit code and press Shift+Enter to execute.
Behind the scene is a Binder-hosted Python environment. Below is the status of the kernel:
To download a notebook file instead, visit here.
Color Palette for Labeled Data Points
You may want to customize the color palette for better contrast or accessibility, which can depend on specific scenarios.
The snippet below shows an example of default colors assigned to 6 classes. hover by default samples Turbo256 to accommodate a large number of classes while keeping good contrast.
import hover
from hover.utils.bokeh_helper import auto_label_color
from rich.console import Console
console = Console()
labels = ["A", "B", "C", "D", "E", "F"]
color_dict = auto_label_color(labels)
abstain = hover.config['data.values']['abstain_decoded']
for _label in [abstain, *labels]:
console.print(f"\u2b24{_label}", style=color_dict[_label])
You can change the palette using any bokeh palette, or any iterable of hex colors like "#000000".
hover.config["visual"]["abstain_hexcolor"] = "#bababa"
Config changes should happen early
hover.config assignments need to happen before plotting your data.
- This is because
hoverlocks config values for consistency as soon as each config value is read by other code. - Ideally you should change config immediately after
import hover.
Color of Unlabeled Data Points
For unlabeled data points, hover uses a light gray color "#dcdcdc". This is not configured in the color palette above, but here:
hover.config["visual"]["abstain_hexcolor"] = "#bababa"
Dimensionality Reduction Method
hover uses dimensionality reduction in a lot of places. It can be cumbersome to find these places and use your preferred method. In such cases a module-level override can be handy:
hover.config["data.embedding"]["default_reduction_method"] = "ivis"
Browse more configs
There are more configurations that are more niche which we will skip here. You can find a full list of configurations, default values, and hints here:
hover.config.hint()
Happy customizing!
Let's explore a few use cases.