Skip to main content

ClassOverlapExplorer

Explorer
DashAI.back.exploration.explorers.ClassOverlapExplorer

Explorer that measures how much the classes of a dataset overlap.

It reports three of the geometrical complexity measures surveyed in Lorena et al. (2019), computed from the data alone, with no model involved:

F1 Maximum Fisher discriminant ratio. Near 0 when at least one feature separates the classes on its own, near 1 when none does. N1 Fraction of points sitting on a class boundary, taken from a minimum spanning tree over the sample. A large value means a long, populated frontier between classes. N2 Ratio between the distance to the nearest same-class neighbour and the distance to the nearest different-class neighbour. A large value means the classes interleave rather than forming compact groups.

All three are normalised so that lower means easier to separate.

Use this explorer before training to tell an unpromising dataset from an unpromising model: if the classes already overlap heavily, a disappointing accuracy is a property of the data rather than of the learner, and the useful next step is feature engineering or relabelling rather than model search.

Parameters

target_column, default=
Required. Name or index of the column holding the class labels. It is added to the exploration automatically, so it does not need to be selected as a column.
max_samples : integer, default=2000
Maximum number of rows used for the distance-based measures N1 and N2. Larger datasets are subsampled keeping the class proportions.
random_state, default=0
Seed used when the dataset has to be subsampled.

Methods

get_results(self, exploration_path: str, options: Dict[str, Any]) -> Dict[str, Any]

Defined on ClassOverlapExplorer

Load and return the saved measures table for the frontend.

Parameters

exploration_path : str
Path to the JSON file saved by save_notebook.
options : Dict[str, Any]
Rendering options from the frontend (unused).

Returns

Dict[str, Any]
Dictionary with keys "data" (nested dict of the table, keyed by column then row, which is the orientation the artifact conversion expects), "type" ("tabular") and "config".

launch_exploration(self, dataset: 'DashAIDataset', explorer_info: DashAI.back.dependencies.database.models.Explorer) -> Any

Defined on ClassOverlapExplorer

Compute the complexity measures and lay them out as a table.

Parameters

dataset : DashAIDataset
Dataset holding the feature columns and the target column.
explorer_info : Explorer
The explorer database record (unused).

Returns

Any
A pandas.DataFrame indexed by row label, with a "value" column and a "detail" column describing each entry.

prepare_dataset(self, loaded_dataset: 'DashAIDataset', columns: List[Dict[str, Any]]) -> 'DashAIDataset'

Defined on ClassOverlapExplorer

Extend column selection to include the target column.

Parameters

loaded_dataset : DashAIDataset
The full dataset.
columns : List[Dict[str, Any]]
Explicitly selected column descriptors.

Returns

DashAIDataset
Dataset containing the selected feature columns plus the target.

save_notebook(self, notebook_info: DashAI.back.dependencies.database.models.Notebook, explorer_info: DashAI.back.dependencies.database.models.Explorer, save_path: 'Path', result: Any) -> str

Defined on ClassOverlapExplorer

Save the measures table to a JSON file on disk.

Parameters

notebook_info : Notebook
The notebook database record (unused).
explorer_info : Explorer
The explorer record used for filename generation.
save_path : Path
Directory where the file will be saved.
result : Any
The pandas.DataFrame returned by launch_exploration.

Returns

str
The path of the saved JSON file as a POSIX string.

get_credential(self, name: str)

Defined on ConfigObject

Resolve a registered credential component by name.

Parameters

name : str
Credential component class name (e.g. "HuggingFaceCredential").

Returns

BaseCredential
An instance of the requested credential component.

get_metadata(cls) -> Dict[str, Any]

Defined on BaseExplorer

Get metadata for the explorer, used by the DashAI frontend.

Returns

Dict[str, Any]
Dictionary containing display name, description, image preview path, category, icon, color, allowed semantic types, allowed dtypes, and input cardinality constraints.

get_schema(cls) -> dict

Defined on ConfigObject

Generates the component related Json Schema.

Returns

dict
Dictionary representing the Json Schema of the component.

validate_and_transform(self, raw_data: dict) -> dict

Defined on ConfigObject

It takes the data given by the user to initialize the model and returns it with all the objects that the model needs to work.

Parameters

raw_data : dict
A dictionary with the data provided by the user to initialize the model.

Returns

dict
A validated dictionary with the necessary objects.

validate_columns(cls, explorer_info: DashAI.back.dependencies.database.models.Explorer, column_spec: Dict[str, Dict[str, str]]) -> bool

Defined on BaseExplorer

Validate that the selected columns satisfy the explorer's constraints.

Parameters

explorer_info : Explorer
The database record for the explorer instance, including the selected columns.
column_spec : Dict[str, Dict[str, str]]
A mapping from column name to a dict with at least "type" (semantic type name) and "dtype" (dtype string).

Returns

bool
True if all column constraints are satisfied, False otherwise.

validate_parameters(cls, params: Dict[str, Any]) -> bool

Defined on BaseExplorer

Validate explorer parameters against the explorer's schema.

Parameters

params : Dict[str, Any]
The configuration parameters to validate.

Returns

BaseExplorerSchema
The validated and parsed schema instance. Subclasses that override this method may return a bool to indicate pass/fail without returning the model instance.