Saltar al contenido principal

TopTermsExplorer

Explorer
DashAI.back.exploration.explorers.TopTermsExplorer

Rank the terms and n-grams of text items by count or TF-IDF.

Each item, or each value on a dataset, is one text. Count ranks terms by their total occurrences; TF-IDF ranks each term by its highest weight in any one item, which favours terms concentrated in a few items.

Parameters​

top_n : integer, default=20
How many terms to show, between 1 and 200.
min_words : integer, default=1
Fewest words in a term: 1 for single words, 2 for pairs.
max_words : integer, default=2
Most words in a term; not less than the minimum.
score : string, default=Count
Count ranks terms by how often they appear. TF-IDF favours terms that are frequent in a few items but rare elsewhere.
stop_words : string, default=English and Spanish
Common words left out, such as 'the' or 'de'.
lowercase : boolean, default=True
Count upper and lower case forms as the same term.

Methods​

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

Defined on TopTermsExplorer

Build a horizontal bar chart of the top terms.

Parameters

dataset : DashAIDataset
The selected text.
explorer_info : Explorer
The explorer record.

Returns

plotly.graph_objects.Figure
The top terms, best at the top.

rank(self, values: List[str]) -> List[tuple]

Defined on TopTermsExplorer

Return the top terms of the texts with their scores.

Parameters

values : List[str]
The texts.

Returns

List[tuple]
(term, score) pairs, best first; empty when no term is left.

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

Defined on TopTermsExplorer

Validate the schema and that the term length range is ordered.

Parameters

params : Dict[str, Any]
The explorer parameters.

Returns

bool
False when the minimum words per term exceed the maximum.

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, input cardinality constraints, and any optional capability flags declared by the explorer.

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

Defined on TextAnalysisExplorer

Load the saved figure as a plotly artifact.

Parameters

exploration_path : str
The file written by save_notebook.
options : Dict[str, Any]
Rendering options (unused).

Returns

List[Artifact]
One plotly artifact.

get_schema(cls) -> dict

Defined on ConfigObject

Generates the component related Json Schema.

Returns

dict
Dictionary representing the Json Schema of the component.

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

Defined on TextAnalysisExplorer

Keep the selected column and the item columns a document provides.

Parameters

loaded_dataset : DashAIDataset
The loaded explorer input.
columns : List[Dict[str, Any]]
The selected columns.

Returns

DashAIDataset
The selected columns, followed by kind, page and position when the input has them.

save_notebook(self, notebook_info: Any, explorer_info: Any, save_path: Any, result: Any) -> str

Defined on TextAnalysisExplorer

Save the plotly figure of the exploration as JSON.

Parameters

notebook_info : Notebook
The notebook record (unused).
explorer_info : Explorer
The explorer record, whose id names the file.
save_path : Path
The directory to save into.
result : plotly.graph_objects.Figure
The figure from launch_exploration.

Returns

str
The saved file path as a POSIX string.

set_context(self, context: Dict[str, Any]) -> None

Defined on BaseExplorer

Set optional runtime context for explorers that need extra inputs.

text_column(dataset: Any, explorer_info: Any) -> List[str]

Defined on TextAnalysisExplorer

Return the selected text values, with missing values as empty text.

Parameters

dataset : DashAIDataset
The prepared dataset.
explorer_info : Explorer
The explorer record naming the selected column.

Returns

List[str]
The values of the first selected column.

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.