archetypax.tools package

Submodules

archetypax.tools.evaluation module

Quantitative assessment tools for archetypal model validity and performance.

This module provides specialized metrics and visualizations for evaluating archetypal analysis results. These tools address the critical gap between model fitting and quality verification by offering:

  1. Objective quantification of model performance across multiple dimensions

  2. Statistical validation of archetype meaningfulness and separation

  3. Specialized measures for interpretability and representational quality

  4. Comparative frameworks for model selection and hyperparameter tuning

These capabilities are essential for ensuring model reliability, selecting optimal configurations, and providing confidence in derived insights - particularly in scientific, business intelligence, and decision support applications.

class archetypax.tools.evaluation.ArchetypalAnalysisEvaluator(model: ArchetypalAnalysis)[source]

Bases: object

Comprehensive evaluation suite for validating archetypal analysis quality.

This class provides specialized metrics and visualizations for assessing model performance across multiple critical dimensions. Rather than relying on a single metric, it offers a holistic evaluation approach that examines:

  • Reconstruction fidelity and information preservation

  • Archetype distinctiveness and interpretability

  • Geometric properties of the archetype simplex

  • Clustering quality and pattern discovery effectiveness

  • Feature utilization patterns and importance distributions

This multi-faceted assessment is essential for model validation, hyperparameter tuning, and ensuring that the archetypal representation provides meaningful insights into the underlying data structure.

__init__(model: ArchetypalAnalysis)[source]

Initialize the evaluator with a fitted archetypal model.

Sets up the evaluation framework by extracting and caching key model properties needed for efficient metric calculation. These properties include archetype configurations, weight distributions, and dominant archetype assignments that will be used across multiple evaluation methods.

Parameters:

model – Fitted ArchetypalAnalysis model with discovered archetypes and calculated weights

archetype_feature_importance() DataFrame[source]

Identify which features define and distinguish each archetype.

This analysis reveals the characteristic features that make each archetype unique, translating abstract archetypes into interpretable patterns. Understanding feature importance enables:

  • Interpretation of what each archetype represents in domain terms

  • Identification of defining characteristics for each extreme pattern

  • Feature selection based on archetypal relevance

  • Targeted analysis of specific variables driving pattern differences

The resulting feature importance profiles are essential for deriving actionable insights and explaining archetypal patterns to stakeholders.

Returns:

DataFrame with normalized feature importance scores for each archetype, where higher absolute values indicate more distinctive usage

archetype_separation() dict[str, float][source]

Measure the geometric distinctiveness between discovered archetypes.

This metric quantifies how well-separated archetypes are in feature space, which is crucial for interpretability and meaningful pattern detection. Well-separated archetypes indicate:

  • Clear differentiation between discovered patterns

  • Minimal redundancy in the archetypal representation

  • Stronger interpretability of what each archetype represents

  • More robust and stable optimization results

Poor separation suggests potential issues like local minima traps, excessive archetypes, or inherent pattern similarity in the data.

Returns:

  • Minimum distance between any two archetypes

  • Maximum pairwise distance in the set

  • Average inter-archetype distance

  • Ratio of minimum to maximum distance (uniformity measure)

Return type:

Dictionary with separation metrics including

clustering_metrics(X: ndarray) dict[str, float][source]

Evaluate the archetypes’ effectiveness as cluster centroids.

This analysis bridges archetypal analysis with clustering by treating dominant archetype assignments as cluster memberships. This perspective provides critical insights into:

  • How well archetypes identify natural groupings in the data

  • The coherence of samples dominated by the same archetype

  • Separation between different archetype-defined groups

  • The comparative quality versus traditional clustering techniques

These metrics help validate that archetypes not only reconstruct the data accurately but also discover meaningful structural patterns.

Parameters:

X – Original data matrix for clustering evaluation

Returns:

  • Silhouette score (higher values indicate better-defined clusters)

  • Davies-Bouldin index (lower values indicate better separation)

Return type:

Dictionary with clustering quality metrics

comprehensive_evaluation(X: ndarray) dict[str, Any][source]

Run all evaluation metrics and return comprehensive results.

Parameters:

X – Original data matrix

Returns:

Dictionary with all evaluation metrics

convex_hull_metrics() dict[str, Any][source]

Calculate metrics related to the convex hull formed by the archetypes.

This method evaluates whether the archetypes form a non-degenerate convex hull by calculating its volume/area and comparing it to the data’s convex hull.

Returns:

  • volume/area of the convex hull

  • ratio compared to data hull volume/area

  • dimensionality of the hull

Return type:

Dictionary with convex hull metrics including

dominant_archetype_purity() dict[str, Any][source]

Analyze how distinctly samples associate with their primary archetypes.

This metric quantifies how uniquely each sample is represented by a single archetype rather than being a mixture of many. High purity indicates that:

  • Archetypes represent distinct, well-separated patterns in the data

  • Samples can be meaningfully assigned to specific archetypes

  • The model has discovered genuine structure rather than arbitrary positions

  • Classification and interpretation of new samples will be more reliable

Low purity suggests overlapping archetypes or that more archetypes may be needed to represent the data’s inherent structure.

Returns:

  • Per-archetype purity scores

  • Overall dataset purity

  • Purity variation statistics

  • Raw maximum weight values

Return type:

Dictionary with purity metrics including

explained_variance(X: ndarray) float[source]

Measure the proportion of data variance captured by the archetypal model.

This intuitive metric expresses model quality as a percentage of total data variation explained, similar to PCA’s explained variance ratio. This perspective offers several advantages:

  • Provides an easily interpretable score between 0-1

  • Enables direct comparison with other dimensionality reduction methods

  • Helps determine if the chosen number of archetypes is sufficient

  • Indicates whether important patterns have been missed

Higher values indicate that the archetypal representation captures more of the information present in the original data.

Parameters:

X – Original data matrix for variance calculation

Returns:

Explained variance ratio (0-1, higher values indicate better fit)

plot_archetype_feature_comparison(top_n: int = 5, feature_names: list[str] | None = None) None[source]

Plot radar chart or bar chart comparing top N most important features for each archetype.

Parameters:
  • top_n – Number of top features to display

  • feature_names – Optional list of feature names

plot_convex_hull(feature_indices: list[int] | None = None, figsize: tuple[int, int] = (10, 8)) None[source]

Plot the convex hull formed by archetypes in 2D or 3D.

Parameters:
  • feature_indices – Indices of features to use for visualization (2 or 3 features)

  • figsize – Size of the figure

plot_distance_matrix() None[source]

Plot distance matrix between archetypes.

plot_entropy_vs_reconstruction(X: ndarray, n_samples: int = 1000) None[source]

Plot relationship between sample entropy and reconstruction error.

Parameters:
  • X – Original data matrix

  • n_samples – Number of samples to plot (random subset)

plot_feature_importance_heatmap(feature_names: list[str] | None = None) None[source]

Plot heatmap of feature importance across archetypes.

Parameters:

feature_names – Optional list of feature names

plot_purity_distribution() None[source]

Plot the distribution of dominant archetype weights (purity).

plot_weight_distributions(bins: int = 20) None[source]

Plot histograms of weight distributions for each archetype.

Parameters:

bins – Number of histogram bins

print_evaluation_report(X: ndarray) None[source]

Print a comprehensive evaluation report.

Parameters:

X – Original data matrix

reconstruction_error(X: ndarray, metric: str = 'frobenius') float[source]

Quantify how accurately the model reproduces the original data.

This fundamental metric measures the information loss between original data and its archetypal reconstruction. The reconstruction error serves several critical purposes:

  • Validating that the model captures essential data patterns

  • Comparing different archetype counts for optimal complexity

  • Identifying potential overfitting or underfitting

  • Providing an objective basis for model selection

The implementation offers multiple error metrics to accommodate different sensitivity needs and statistical preferences.

Parameters:
  • X – Original data matrix to reconstruct

  • metric – Error calculation method: ‘frobenius’ - Matrix norm (sensitive to outliers) ‘mae’ - Mean absolute error (more robust) ‘mse’ - Mean squared error (standard in many contexts) ‘relative’ - Normalized by data magnitude (for comparison)

Returns:

Calculated reconstruction error (lower values indicate better fit)

weight_diversity() dict[str, float][source]

Measure how diverse the weight distributions are across samples.

Returns:

Dictionary with diversity metrics

class archetypax.tools.evaluation.BiarchetypalAnalysisEvaluator(model)[source]

Bases: object

Evaluator for Biarchetypal Analysis results.

Provides metrics and visualizations to assess model quality for biarchetypal models, which use two sets of archetypes to represent data.

__init__(model)[source]

Initialize the evaluator.

Parameters:

model – Fitted BiarchetypalAnalysis model

archetype_separation()[source]

Calculate separation metrics between archetypes.

Returns:

Dictionary of separation metrics

comprehensive_evaluation(X: ndarray) dict[source]

Perform a comprehensive evaluation of the model.

Parameters:

X – Data matrix

Returns:

Dictionary of evaluation metrics

dominant_archetype_purity() dict[source]

Calculate purity metrics for dominant archetypes.

Returns:

Dictionary of purity metrics

explained_variance(X: ndarray) float[source]

Calculate the explained variance of the model.

Parameters:

X – Data matrix

Returns:

Explained variance (0-1)

print_evaluation_report(X: ndarray) None[source]

Print a comprehensive evaluation report.

Parameters:

X – Original data matrix

print_summary(results: dict)[source]

Print a summary of the evaluation results.

Parameters:

results – Dictionary of evaluation results

reconstruction_error(X: ndarray, metric: str = 'frobenius') float[source]

Calculate the reconstruction error of the model.

Parameters:
  • X – Data matrix

  • metric – Error metric to use (‘frobenius’, ‘mae’, ‘mse’, or ‘relative’)

Returns:

Reconstruction error value

weight_diversity() dict[source]

Calculate diversity metrics for archetype weights.

Returns:

Dictionary of diversity metrics

archetypax.tools.interpret module

Advanced tools for extracting meaningful insights from archetypal representations.

This module provides specialized metrics and techniques for translating mathematical archetypal models into domain-relevant interpretations. These tools address the critical challenge of making abstract archetypal patterns understandable by:

  1. Quantifying interpretability characteristics of discovered archetypes

  2. Revealing feature-level insights about what each archetype represents

  3. Determining optimal archetype configurations for maximum meaningfulness

  4. Assessing stability and reliability of derived interpretations

These capabilities are essential for bridging the gap between algorithmic discovery and practical application, enabling stakeholders to leverage archetypal analysis for meaningful decision-making, pattern discovery, and knowledge extraction.

class archetypax.tools.interpret.ArchetypalAnalysisInterpreter(models_dict: dict[int, ArchetypalAnalysis] | None = None)[source]

Bases: object

Advanced interpreter for extracting meaningful insights from archetypal models.

This class provides specialized metrics and visualization tools for translating abstract mathematical archetypes into understandable, domain-relevant patterns. Beyond basic evaluation, this interpreter focuses on:

  • Quantifying interpretability characteristics of archetypes

  • Determining optimal archetype configurations for maximum meaningfulness

  • Assessing feature importance and pattern distinctiveness

  • Measuring stability and consistency of discovered archetypes

These capabilities address the critical challenge of making archetypal analysis results accessible and actionable for domain experts and decision-makers, particularly in exploratory analysis and knowledge discovery applications.

__init__(models_dict: dict[int, ArchetypalAnalysis] | None = None) None[source]

Initialize the interpreter with optional model collection.

This constructor can either create an empty interpreter for later model addition or initialize with a pre-fitted collection of models with different archetype counts. The latter enables comparative analysis across model complexities for optimal configuration selection.

Parameters:

models_dict – Optional dictionary mapping archetype counts to fitted models for comparative interpretation

add_model(n_archetypes: int, model: ArchetypalAnalysis) ArchetypalAnalysisInterpreter[source]

Register a fitted archetypal model for interpretation.

This method builds the interpreter’s model collection incrementally, allowing comparative analysis across different archetype configurations. Each model is validated to ensure it has been properly fitted before inclusion in the comparative framework.

Parameters:
  • n_archetypes – Number of archetypes in the model (key for retrieval)

  • model – Fitted archetypal model to include in the analysis

Returns:

Self - for method chaining

cluster_purity(weights: ndarray, threshold: float = 0.6) tuple[ndarray, float][source]

Assess archetype interpretability through assignment clarity.

This metric evaluates how cleanly each archetype captures a distinct subset of data points, based on the principle that interpretable archetypes should represent clear, distinguishable patterns. High purity indicates:

  • The archetype represents a coherent, well-defined pattern

  • Data points can be meaningfully assigned to specific archetypes

  • The model has discovered genuine structure rather than arbitrary positions

  • Users can confidently interpret new samples through dominant archetypes

Low purity suggests archetypes may be capturing overlapping patterns or that the underlying data lacks clear archetypal structure.

Parameters:
  • weights – Weight matrix (n_samples, n_archetypes)

  • threshold – Minimum weight to consider an archetype dominant

Returns:

  1. purity scores for each archetype and

  2. average purity across all archetypes

Return type:

Tuple containing

evaluate_all_models(X: ndarray) dict[int, dict[str, Any]][source]

Evaluate interpretability metrics for all models.

Parameters:

X – Original data matrix

Returns:

Dictionary of results per number of archetypes

feature_consistency(X: ndarray, n_archetypes: int, n_trials: int = 5, top_k: int = 5, random_seed: int = 42) ndarray[source]

Evaluate the stability of feature importance across multiple initializations.

This reliability assessment measures whether the same features consistently define each archetype across different optimization runs. Consistency is critical for interpretation because:

  • Unstable feature importance undermines confidence in interpretations

  • Reliable patterns indicate genuine data structure rather than optimization artifacts

  • Consistent archetypes enable more dependable knowledge extraction

  • Higher consistency justifies stronger claims about discovered patterns

This analysis is particularly important in exploratory contexts where results guide hypothesis generation or decision-making.

Parameters:
  • X – Data matrix for fitting trial models

  • n_archetypes – Archetype count to evaluate

  • n_trials – Number of different initializations for consistency testing

  • top_k – Number of top features to consider in consistency calculation

  • random_seed – Base random seed (incremented for each trial)

Returns:

Array of consistency scores for each archetype (higher values indicate more stable feature importance across initializations)

feature_distinctiveness(archetypes: ndarray) ndarray[source]

Quantify how uniquely each archetype represents specific feature patterns.

This interpretability metric measures how well each archetype captures unique feature patterns not represented by other archetypes. High distinctiveness indicates:

  • The archetype represents a truly unique data pattern

  • Features have meaningful peak values in this archetype

  • The archetype makes a non-redundant contribution to the model

  • Interpretation can focus on specific distinguishing characteristics

Low distinctiveness suggests potential redundancy or that the archetype represents a subtle pattern variation rather than a fundamentally distinct type.

Parameters:

archetypes – Archetype matrix (n_archetypes, n_features)

Returns:

Array of distinctiveness scores for each archetype, where higher values indicate more distinctive feature utilization

information_gain(X: ndarray) list[tuple[int, float]][source]

Measure the marginal value of each additional archetype.

This critical metric quantifies the incremental explanatory power gained by adding each archetype, essential for determining the optimal model complexity. The analysis reveals:

  • Diminishing returns pattern as archetypes are added

  • Potential “elbow points” where additional archetypes yield minimal benefit

  • Balance between model parsimony and explanatory power

  • Evidence of underfitting or overfitting

This perspective is particularly valuable for communicating model complexity decisions and ensuring resource-efficient analysis.

Parameters:

X – Original data matrix for reconstruction testing

Returns:

List of (n_archetypes, gain) pairs showing the marginal benefit of increasing model complexity

plot_interpretability_metrics()[source]

Plot interpretability metrics for different numbers of archetypes.

sparsity_coefficient(archetypes: ndarray, percentile: float = 80) ndarray[source]

Measure interpretability through feature utilization concentration.

This metric quantifies how selectively each archetype utilizes features, based on the cognitive science principle that humans can most effectively interpret patterns defined by a small number of prominent characteristics. High sparsity indicates:

  • The archetype focuses on a specific subset of features

  • Interpretation can highlight a manageable number of key attributes

  • The pattern has clear defining characteristics

  • Domain experts can more easily understand and label the archetype

Low sparsity suggests a complex pattern utilizing many features, which may be harder to interpret but potentially more faithful to complex phenomena.

Parameters:
  • archetypes – Archetype matrix (n_archetypes, n_features)

  • percentile – Threshold for considering features as prominent (higher values produce more selective feature identification)

Returns:

Array of sparsity scores for each archetype (higher values indicate more focused feature utilization and better interpretability)

suggest_optimal_archetypes(method: str = 'balance') int[source]

Suggest optimal number of archetypes based on interpretability metrics.

Parameters:

method – Method to use for selection (‘balance’, ‘interpretability’, or ‘information_gain’)

Returns:

Optimal number of archetypes

class archetypax.tools.interpret.BiarchetypalAnalysisInterpreter(models_dict: dict[tuple[int, int], BiarchetypalAnalysis] | None = None)[source]

Bases: object

Interpreter for Biarchetypal Analysis results, focusing on interpretability metrics.

Provides quantitative measures for biarchetype interpretability and optimal number selection.

__init__(models_dict: dict[tuple[int, int], BiarchetypalAnalysis] | None = None) None[source]

Initialize the interpreter.

Parameters:

models_dict – Optional dictionary of {n_archetypes_first, n_archetypes_second: model} pairs

add_model(n_archetypes_first: int, n_archetypes_second: int, model: BiarchetypalAnalysis) BiarchetypalAnalysisInterpreter[source]

Add a fitted model to the interpreter.

cluster_purity(weights: ndarray, threshold: float = 0.6) tuple[ndarray, float][source]

Calculate purity of each archetype’s associated data points.

Parameters:
  • weights – Weight matrix (n_samples, n_archetypes)

  • threshold – Threshold for considering an archetype as dominant

Returns:

Tuple of purity scores per archetype, average purity

compute_information_gain(X: ndarray) None[source]

Calculate information gain between different archetype number combinations.

Parameters:

X – Original data matrix

evaluate_all_models(X: ndarray) dict[tuple[int, int], dict[str, Any]][source]

Evaluate interpretability metrics for all models.

Parameters:

X – Original data matrix

Returns:

Dictionary of results per combination of archetypes

feature_distinctiveness(archetypes: ndarray) ndarray[source]

Calculate how distinctive each archetype is in terms of feature values.

Parameters:

archetypes – Archetype matrix (n_archetypes, n_features)

Returns:

Array of distinctiveness scores for each archetype

plot_interpretability_heatmap() Figure[source]

Plot heatmaps of interpretability metrics for different archetype number combinations.

Returns:

The matplotlib figure object

sparsity_coefficient(archetypes: ndarray, percentile: float = 80) ndarray[source]

Calculate sparsity of each archetype’s feature representation.

Parameters:
  • archetypes – Archetype matrix (n_archetypes, n_features)

  • percentile – Percentile threshold for considering features as prominent

Returns:

Array of sparsity scores for each archetype (higher is more interpretable)

suggest_optimal_biarchetypes(method: str = 'balance') tuple[int, int][source]

Suggest optimal archetype number combination based on interpretability metrics.

Parameters:

method – Method to use for selection (‘balance’, ‘interpretability’, or ‘information_gain’)

Returns:

Optimal combination of n_archetypes_first, n_archetypes_second

archetypax.tools.visualization module

Advanced visualization tools for extracting insights from archetypal models.

This module provides specialized visualization capabilities that transform abstract archetypal representations into intuitive visual insights. These visualizations bridge the gap between mathematical models and human understanding by:

  1. Revealing geometric relationships between data points and archetypes

  2. Exposing patterns in feature utilization across different archetypes

  3. Demonstrating reconstruction quality and model performance

  4. Enabling exploration of relationships in both standard and biarchetypal space

These capabilities are essential for model interpretation, result communication, and extracting actionable insights from archetypal analysis.

class archetypax.tools.visualization.ArchetypalAnalysisVisualizer[source]

Bases: object

Comprehensive visualization suite for archetypal analysis insights.

This class provides specialized visualization methods that transform abstract archetypal models into intuitive visual representations. Rather than just plotting data, these methods reveal the underlying structures and relationships discovered by archetypal analysis, enabling:

  • Interpretation of archetype meaning and significance

  • Assessment of model quality and reconstruction fidelity

  • Communication of results to technical and non-technical audiences

  • Discovery of patterns in high-dimensional archetypal space

These visualizations bridge the critical gap between mathematical models and human understanding, making archetypal analysis results accessible and actionable.

static plot_archetype_distribution(model: ArchetypalAnalysis) None[source]

Plot the distribution of dominant archetypes across samples.

Parameters:

model – Fitted ArchetypalAnalysis model

static plot_archetype_profiles(model: ArchetypalAnalysis, feature_names: list[str] | None = None) None[source]

Plot feature profiles of each archetype.

Parameters:
  • model – Fitted ArchetypalAnalysis model

  • feature_names – Optional list of feature names for axis labels

static plot_archetypes_2d(model: ArchetypalAnalysis, X: ndarray, feature_names: list[str] | None = None) None[source]

Reveal geometric relationships between data and archetypes in 2D space.

This visualization exposes the fundamental geometrical interpretation of archetypal analysis by showing how archetypes position themselves at the extremes of the data distribution and form a convex hull. The plot reveals:

  • Position of archetypes relative to the data cloud

  • Dominance relationships between data points and archetypes

  • The convex hull structure formed by the archetypes

  • Feature-specific patterns that define each archetype

This representation is particularly valuable for initial model validation, intuitive explanation of what archetypes represent, and identification of outliers or unexpected patterns.

Parameters:
  • model – Fitted ArchetypalAnalysis model with discovered archetypes

  • X – Original data matrix in 2D space

  • feature_names – Optional feature names for meaningful axis labels

static plot_loss(model: ArchetypalAnalysis) None[source]

Visualize convergence behavior through loss trajectory analysis.

This diagnostic visualization reveals the optimization dynamics of the model by tracking loss values across iterations. It provides critical insights into:

  • Convergence speed and stability

  • Potential issues with learning rates or initialization

  • Evidence of premature convergence or local minima traps

  • Effectiveness of early stopping criteria

Understanding these dynamics is essential for hyperparameter tuning, model validation, and diagnosing unexpected results.

Parameters:

model – Fitted ArchetypalAnalysis model with loss history

static plot_membership_weights(model: ArchetypalAnalysis, n_samples: int | None = None) None[source]

Visualize how samples relate to archetypes through weight distribution patterns.

This heatmap visualization reveals the fundamental composition patterns in the data by showing how each sample leverages different archetypes. The visualization exposes:

  • Dominant archetypes for each sample

  • Patterns of archetype co-utilization

  • Samples with similar composition profiles

  • Evidence of archetype redundancy or specialization

These insights are valuable for clustering analysis, identifying representative samples, detecting subpopulations, and understanding how archetypes interact to represent the data.

Parameters:
  • model – Fitted ArchetypalAnalysis model with weights

  • n_samples – Optional number of samples to visualize (default: all)

static plot_reconstruction_comparison(model: ArchetypalAnalysis, X: ndarray) None[source]

Assess model fidelity through side-by-side reconstruction comparison.

This visualization provides a direct assessment of how well the archetypal model captures the underlying data structure by comparing original and reconstructed data points. This comparison reveals:

  • Overall reconstruction quality and information preservation

  • Specific regions where the model performs well or poorly

  • Distortion patterns introduced by dimensionality reduction

  • Evidence of potential overfitting or underfitting

This assessment is critical for validating model quality, determining an appropriate number of archetypes, and communicating the tradeoff between interpretability and accuracy.

Parameters:
  • model – Fitted ArchetypalAnalysis model for reconstruction

  • X – Original data matrix to be reconstructed

static plot_simplex_2d(model: ArchetypalAnalysis, n_samples: int | None = 500) None[source]

Plot samples in 2D simplex space (only works for 3 archetypes).

Parameters:
  • model – Fitted ArchetypalAnalysis model

  • n_samples – Number of samples to plot (default: 500)

class archetypax.tools.visualization.BiarchetypalAnalysisVisualizer[source]

Bases: object

Visualization utilities for Biarchetypal Analysis.

static plot_biarchetypal_reconstruction(model: BiarchetypalAnalysis, X: ndarray) None[source]

Plot original data vs. reconstructions from each archetype set and combined.

Parameters:
  • model – Fitted BiarchetypalAnalysis model

  • X – Original data matrix

static plot_dual_archetypes_2d(model: BiarchetypalAnalysis, X: ndarray, feature_names: list[str] | None = None) None[source]

Plot data and both sets of archetypes in 2D.

Parameters:
  • model – Fitted BiarchetypalAnalysis model

  • X – Original data

  • feature_names – Optional feature names for axis labels

static plot_dual_membership_heatmap(model: BiarchetypalAnalysis, n_samples: int = 50) None[source]

Plot heatmap of membership weights for both sets of archetypes.

Parameters:
  • model – Fitted BiarchetypalAnalysis model

  • n_samples – Number of samples to visualize

static plot_dual_simplex_2d(model: BiarchetypalAnalysis, n_samples: int = 200) None[source]

Plot samples in separate 2D simplex spaces for each archetype set (only works for 3 archetypes per set).

Parameters:
  • model – Fitted BiarchetypalAnalysis model

  • n_samples – Number of samples to plot

static plot_mixture_effect(model: BiarchetypalAnalysis, X: ndarray, mixture_steps: int = 5) None[source]

Plot the effect of different mixture weights between the two archetype sets.

Parameters:
  • model – Fitted BiarchetypalAnalysis model

  • X – Original data matrix

  • mixture_steps – Number of different mixture weights to try

Module contents

Tools for extracting insights from Archetypal Analysis results.

This package provides specialized utilities that transform archetypal models from mathematical abstractions into actionable insights. These tools address the critical gap between model fitting and practical application by enabling:

  1. Rigorous evaluation of model quality and reliability

  2. Interpretable translation of abstract archetypes into domain-specific meaning

  3. Compelling visualization that communicates patterns to technical and non-technical audiences

  4. Systematic tracking of archetype evolution during model training

These capabilities are essential for deriving value from archetypal analysis, particularly in exploratory data analysis, scientific research, and data-driven decision making contexts.

Components:

evaluation: Quantitative assessment of model quality and fit characteristics interpret: Semantic analysis of archetypes and their real-world significance visualization: Advanced plotting and visual analysis techniques tracker: Progressive monitoring of archetype development during training

Basic Usage:

from archetypax.tools import ArchetypalAnalysisVisualizer

# After fitting a model visualizer = ArchetypalAnalysisVisualizer(model)

# Plot archetypes visualizer.plot_archetypes()

# Visualize data in archetypal space visualizer.plot_simplex_embedding(data)