AnalysisResult

class hybrid_learning.concepts.analysis.results.AnalysisResult(results)[source]

Bases: ResultsHandle

Handle for saving, loading and inspection of analysis results. The results are saved in results. See there for the format.

Public Methods:

items()

Emulate an items view that yields an analysis result per layer ID.

result_for(layer_id)

Return the results for a single layer.

save(folder_path)

Save analysis results.

to_pandas()

Provide pandas.DataFrame multi-indexed by layer and run w/ info for each run.

Inherited from : py: class:ResultsHandle

save(folder_path)

Save analysis results.

to_pandas()

Provide pandas.DataFrame multi-indexed by layer and run w/ info for each run.

Special Methods:

__init__(results)

Inherited from : py: class:ResultsHandle

__repr__()

Return repr(self).


Parameters

results (Dict[str, Dict[int, Tuple[Sequence[ConceptEmbedding], Series]]]) –

__init__(results)[source]
Parameters

results (Dict[str, Dict[int, Tuple[Sequence[ConceptEmbedding], Series]]]) –

items()[source]

Emulate an items view that yields an analysis result per layer ID.

Return type

ItemsView[str, AnalysisResult]

classmethod load(folder_path)[source]

Load analysis results previously saved. The saving format is assumed to be that of save().

Parameters

folder_path (str) –

Return type

AnalysisResult

result_for(layer_id)[source]

Return the results for a single layer.

Parameters

layer_id (str) –

Return type

AnalysisResult

save(folder_path)[source]

Save analysis results. The format is one retrievable by load(). The results are saved in the following files within folder_path

  • <layer> <run> <i>.pt: torch PT file with ith embedding resulting from <run> on <layer>; can be loaded to an embedding using hybrid_learning.concepts.models.embeddings.ConceptEmbedding.load()

  • stats.csv: CSV file holding a pandas.DataFrame with each rows holding an embedding statistics; additional columns are 'layer', 'run', and 'embedding_{i}', where the 'embedding_{i}' column holds the path to the ith PT-saved embedding corresponding of the row relative to the location of stats.csv

Note

Also the .npz legacy format is accepted and determined from the file ending.

Parameters

folder_path (str) – the root folder to save files under; must not yet exist

to_pandas()[source]

Provide pandas.DataFrame multi-indexed by layer and run w/ info for each run. The information for each run is the one obtained by emb_info_to_pandas().

Returns

a pandas.DataFrame with run result information multi-indexed by (layer, run)

results: Dict[str, Dict[int, Tuple[Sequence[ConceptEmbedding], pandas.core.series.Series]]]

The dict storage of the managed results. Format: {layer_id: {run: ([embedding1, embedding2, ...], results_series)}}.