Debug#
We provide a debugger module to facilitate the fine-tuning of the knowledge base of a Draco instance. You can learn more about the applications of this API in the applications section.
DracoDebug
#
- class draco.debug.DracoDebug(specs, draco=__DEFAULT_DRACO__)#
Class to aid the debugging of visualization specifications against the knowledge base of a Draco instance. Methods exposed by this class give insight into the constraints and weights defined in the Draco instance and how they are violated by the supplied visualization specifications.
- __init__(specs, draco=__DEFAULT_DRACO__)#
Initializes a new debugger instance.
- Parameters:
specs (
dict
[str
,Union
[Iterable
[str
],str
]]) –dict
of specifications to analyze, keys representing the spec name and values the corresponding ASP declarations.draco (
Draco
) – TheDraco
instance to be debugged.
- property chart_preferences: DataFrame#
Returns a
DataFrame
with four columns:chart_name
: Specification name, a key ofself.specs
pref_name
: Preference (feature) name,element of
self.feature_names
pref_description
: Preference (feature) description.count
: The number of times the specidentified by
chart_name
violatespref_name
.
weight
: The weight associated withpref_name
.
The returned
DataFrame
always haslen(self.specs) * len(self.feature_names)
rows.- Returns:
The above-described pandas
DataFrame
.
- property feature_descriptions: dict[str, str]#
- Returns:
a dict mapping feature names to their descriptions
- property feature_names: set[str]#
- Returns:
a set of the names of the features (constraints) of the underlying Draco instance
DracoDebugPlotter
#
- class draco.debug.DracoDebugPlotter(chart_preferences)#
Class to aid the plotting of Draco debug data produced by
DracoDebug.chart_preferences
.- __init__(chart_preferences)#
Initializes a new plotter instance, to be used to create charts visualizing the Draco debug data.
- Parameters:
chart_preferences (
DataFrame
) – theDataFrame
returned byDracoDebug.chart_preferences
- create_chart(*, cfg=None, violated_prefs_only=False, plot_size=None)#
Creates a vertically concatenated chart made up of an aligned bar chart visualizing feature weights and a heatmap visualizing the number of times each spec violates each feature.
- Parameters:
cfg (
DracoDebugChartConfig
|ChartConfig
|None
) – the configuration based on which the chart title and sorting is set. A default configuration will be used of this is not specified, featuring an alphabetical sort by feature name and spec name.violated_prefs_only (
bool
) – whether to only include features that are violated by at least one spec. Defaults toFalse
.plot_size (
tuple
[float
,float
] |None
) – the size of the plot described as a tuple of (width, height).
- Return type:
VConcatChart
- Returns:
the above-described Altair chart