spacr.qt.widgets.feature_explorer

The feature explorer — the ranked list, and the distributions behind it.

The chrome over spacr.qt.widgets.feature_rank. Everything about how separated a feature is lives there, together with which statistic was used and what it cannot see; this module is a table of the ranking and a small multiple of the distributions.

Two things the panel refuses to let the ranking hide

The statistic’s blind spot is on screen, not in a manual. The picker’s tooltip carries STATISTIC_FAILURE_MODES verbatim, and a feature flagged is_shape_not_shift — the classes differ in spread, which a rank statistic scores at 0.5 — is marked in the list even though it ranks low.

n is in the table. Every row shows the smallest class behind the score, because a separation over four objects and one over four thousand are the same number, and the difference between them is the whole question.

Drawing it

The panel draws the top features as a strip of small histograms, one row per feature, the classes overlaid on shared bin edges — the same rule spacr.qt.widgets.graph_spec.scales_for() applies across facets. Two class histograms drawn on their own edges are two pictures of nothing.

Classes

FeatureExplorerPanel

Rank features by how well they separate the classes, and draw the top.

Module Contents

class spacr.qt.widgets.feature_explorer.FeatureExplorerPanel(parent=None)[source]

Bases: PySide6.QtWidgets.QWidget

Rank features by how well they separate the classes, and draw the top.

Parameters:

parent – parent widget.

Build the feature ranking table beside its distribution plot.

Each statistic’s blind spot is on the picker’s tooltip rather than in a manual: which differences it cannot see is the thing a reader needs before trusting a ranking made with it.

Parameters:

parent – parent widget, or None.

closeEvent(event)[source]

Stop background work before going away.

Parameters:

event – the Qt close event.

current_spec() → spacr.qt.widgets.feature_rank.ExplorerSpec[source]

The spec as the controls read RIGHT NOW.

Distinct from spec, which is what the last run used: the two differ while the user is changing the controls, and a panel that conflated them would report a ranking against settings it did not use.

Returns:

the spec the controls describe.

rank_now() → spacr.qt.widgets.feature_rank.ExplorerResult | None[source]

Re-rank and redraw. Returns the result, or None on a refusal.

selected_feature() → str[source]

Which feature the user has selected, if any.

Returns:

the feature name, or "".

set_frame(frame: pandas.DataFrame | None) → None[source]

Point the panel at a table and offer its class columns.

Parameters:

frame – the object table, or None to empty the class picker. Its candidate_labels() are offered, keeping the previous choice when it is still there, and the ranking reruns.

set_spec(spec: spacr.qt.widgets.feature_rank.ExplorerSpec) → None[source]

Push a whole spec in — restoring a saved analysis.

Parameters:

spec – the ExplorerSpec to adopt; its label, statistic, top count and whether a permutation null is on are shown in the controls, and the ranking reruns.

summary() → str[source]

What was ranked, over how much, and what was skipped.

Returns:

a one-line summary, empty before a run.

property result: spacr.qt.widgets.feature_rank.ExplorerResult | None[source]

The last ranking computed, if any.

Returns:

the result, or None before a run.

property spec: spacr.qt.widgets.feature_rank.ExplorerSpec[source]

What the panel is currently set to rank.

Returns:

the explorer spec.