minerva.analysis.model_analysis
Classes
Perform t-SNE analysis on the embeddings generated by a model. |
|
Main interface for model analysis. A model analysis is a post-training |
Module Contents
- class minerva.analysis.model_analysis.TSNEAnalysis(label_names=None, height=800, width=800, text_size=12, title=None, x_axis_title='x', y_axis_title='y', legend_title='Label', output_filename='tsne.png', seed=42, n_components=2)[source]
Bases:
_ModelAnalysis
Perform t-SNE analysis on the embeddings generated by a model. A t-SNE plot is generated using the embeddings and saved in the path directory. The plot is saved as a PNG image file.
Plot a t-SNE plot of the embeddings generated by a model.
Parameters
- label_namesOptional[Dict[Union[int, str], str]], optional
Labels to use for the plot, instead of the original labels in the data (y). The keys are the original labels and the values are the new labels to use in the plot. If None, the original labels are used as they are. By default None
- heightint, optional
Height of the figure, by default 800
- widthint, optional
Width of the figure, by default 800
- text_sizeint, optional
Size of font used in plot, by default 12
- titlestr, optional
Title of graph, by default None
- x_axis_titlestr, optional
Name of x-axis, by default “x”
- y_axis_titlestr, optional
Name of y-axis, by default “y”
- legend_titlestr, optional
Name for legend title, by default “Label”
- output_filenamePathLike, optional
Name of the output file to save the plot as a PNG image file. The file will be saved in the path directory with this name. By default “tsne.png”
- seedint, optional
Random seed for t-SNE, by default 42
- n_componentsint, optional
Number of components to use in t-SNE, by default 2
- compute(model, data)[source]
- Parameters:
model (lightning.LightningModule)
data (lightning.LightningDataModule)
- height = 800
- label_names = None
- legend_title = 'Label'
- n_components = 2
- output_filename
- seed = 42
- text_size = 12
- title = None
- width = 800
- x_axis_title = 'x'
- y_axis_title = 'y'
- Parameters:
label_names (Optional[Dict[Union[int, str], str]])
height (int)
width (int)
text_size (int)
title (Optional[str])
x_axis_title (str)
y_axis_title (str)
legend_title (str)
output_filename (minerva.utils.typing.PathLike)
seed (int)
n_components (int)
- class minerva.analysis.model_analysis._ModelAnalysis(path=None)[source]
Main interface for model analysis. A model analysis is a post-training analysis that can be run on a trained model to generate insights about the model’s performance. It has a path attribute that specifies the directory where the analysis results will be saved. The compute method should be implemented by subclasses to perform the actual analysis. All insights generated by the analysis should be saved in the path directory. Note that, differently from Metric, _ModelAnalysis does not return any value. Instead, the results of the analysis should be saved in the path directory. All subclasses of _ModelAnalysis should implement the compute method. Inside a pipeline the path will be automatically set to the pipeline.log_dir attribute.
- Parameters:
path (Optional[minerva.utils.typing.PathLike])
- _path = None
- abstract compute(model, data)[source]
- Parameters:
model (lightning.LightningModule)
data (lightning.LightningDataModule)
- property path