About Sequenzo


Sequenzo is a Python package for social sequence analysis. It is designed for categorical trajectories, large datasets, and the everyday workflow of researchers who prepare data, compare sequences, build typologies, visualize patterns, and fit probabilistic sequence models in Python.
Use Sequenzo when you need to:
- turn longitudinal categorical data into a validated
SequenceDataobject; - compare trajectories with one of 24 distance methods;
- build and evaluate sequence typologies;
- visualize sequence patterns for papers, slides, or reports;
- scale clustering with CLARA when full distance matrices become too large;
- move into group comparison, multidomain analysis, event histories, or HMM-style models.
New Modules and Features in Recent Releases
Recent releases expanded Sequenzo beyond the standard distance-and-clustering workflow:
- HMM-family models: HMM, MHMM, NHMM, and MNHMM workflows for latent sequence dynamics.
- Event-history tools: sequence history data, SAMM workflows, and spell survival analysis.
- Multidomain and polyadic analysis: tools for trajectories that unfold across several domains or linked actors.
- Big-data workflows: CLARA-style sampling and uniqueness checks for large sequence datasets.
- Summary statistics and indicators: functions for describing datasets, time points, spells, entropy, turbulence, and other sequence characteristics.
See What's New for release-by-release details.
Sequence Foundations and Inspirations
Its methodological foundations build upon prior work in the R software tradition, especially the TraMineR (Gabadinho et al. 2011) R package, which established many of the core concepts, representations, and analytical tools in sequence analysis, as well as subsequent methodological extensions developed within TraMineRextras (Gabadinho et al. 2021).
Sequenzo also draws inspiration from WeightedCluster (Studer, 2013) for typology construction, seqHMM (Helske & Helske, 2019) for probabilistic modeling using hidden Markov models, and ggseqplot (Raab, 2022) for the design of relative frequency sequence visualizations (Fasang & Liao, 2013).
We gratefully acknowledge these pioneering contributions and the broader community in social sequence analysis. Sequenzo connects long-standing methodological traditions with the computational practices of the Python data science community, including machine learning and large-scale data workflows.
Many users first meet sequence analysis through concrete data problems. This page gives the context: what sequence data look like, which questions the method answers, and where Sequenzo fits.
What is social sequence analysis, and why does it matter?
Sequence Analysis (SA) compares ordered categorical states or events. It began in biology, then moved into the social sciences for studying life courses and other trajectories (Abbott, 1983; Liao et al., 2022). On this website, sequence analysis and social sequence analysis refer to that social-science use.
It is especially useful for understanding how people's lives unfold, capturing transitions such as:
- Family transitions (single → married → having children)
- Career paths (graduation → first job → career changes)
- Migration trajectories (moving from City A → City B → City A)
Unlike numeric time series such as stock prices or temperatures, social sequence data are usually categorical. They represent stages such as being single, married, unemployed, studying, or working.
These states are often unordered, and transitions can happen at different moments for different people. Standard numeric time-series tools are therefore a poor fit. Sequence analysis uses distances, alignments, state summaries, and models built for categorical trajectories.
Sequence analysis is predominantly used in sociology and demography to study individual life trajectories. However, its potential application in broader fields, including economics, management, marketing, human resources, healthcare, education, and customer behavior, remains largely untapped.
What kinds of questions can sequence analysis answer?
At the individual (micro) level:
- Career Patterns: How do career paths differ between men and women across different cultures?
- Family Formation: How have marriage and family formation patterns changed across generations?
- Migration Patterns: What typical migration trajectories do people follow when moving to new countries?
- Health Research: How do patients move between different health conditions or symptoms over time?
- Customer Insights: What typical pathways do customers take before becoming loyal or disengaged?
Beyond individuals, sequence analysis can also study larger entities. Economic geography, for example, uses trajectories of regions and cities to examine convergence, divergence, and agglomeration (Losacker & Kuebart, 2024).
In general, in meso and macro-level analyses, entities can be cities, regions, companies, or countries. For instance:
- Urban Development: How do cities evolve in terms of economic status, population growth, and infrastructure development?
- Regional Economic Patterns: What trajectories do regions follow regarding employment structures or industrial composition over decades?
- Corporate Life-Cycles: What typical growth, stagnation, or innovation trajectories do companies experience throughout their existence?
- Country-Level Transitions: How do countries transition between political regimes, economic systems, or developmental stages over historical periods?
Sequenzo helps researchers, policy analysts, and industry data teams answer these questions with reproducible Python workflows.
Introducing Sequenzo: A Fast Python Package for Sequence Analysis
Sequence analysis has enormous potential for understanding complex trajectories and patterns across many fields, but it faces significant scaling challenges. Large samples, long observation windows, and multidomain designs can make full pairwise distance matrices expensive in time and memory.
Sequenzo brings this methodological tradition into the scientific Python stack, with an emphasis on pandas-friendly data handling, scalable computation, and workflows that fit naturally with NumPy, scikit-learn, matplotlib, and modern research pipelines.
For R users, see Functions Comparison and Performance Differences.
Key features
Sequence Data Handling: Manage and convert longitudinal data formats, define categorical state spaces, and detect missing values.
Visualization Tools: Create clear visualizations such as the state distribution plot and index plot to effectively illustrate sequence data.
Sequence Characteristics Indicators: Compute sequence length, state durations, entropy, complexity, turbulence, and related measures.
Dissimilarity Measures: Compute Optimal Matching, Hamming, Longest Common Subsequence, prefix-based, Chi-squared, Euclidean, and related sequence distances.
Clustering Analysis: Efficiently groups similar trajectories into meaningful clusters to identify representative patterns by hierarchical clustering, k-medoids, and partitioning around medoids (PAM).
Representative Sequence Identification: Identify medoids and representative observed trajectories.
Probabilistic Modeling with Hidden Markov Models: Fit HMM, MHMM, NHMM, and MNHMM models to recover latent dynamics behind observed sequences.
Big Data: Use CLARA-style workflows (Studer et al., 2024) when full pairwise distance matrices become too expensive.
With optimized algorithms and parallel computation, Sequenzo reduces computational burden and makes sequence analysis practical at larger scales. Whether for academic research, business analytics, or policy work, Sequenzo brings sequence analysis into the Python data-science stack.
Now Sequenzo is available on macOS, Windows, and Linux. It can be installed directly via pip install sequenzo with no compiler or build tools required for the platform/Python combinations listed below.
| Platform | Python Versions |
|---|---|
| macOS | 3.9, 3.10, 3.11, 3.12, 3.13, 3.14 |
| Windows | 3.9, 3.10, 3.11, 3.12, 3.13 |
| Linux (glibc) | 3.9, 3.10, 3.11, 3.12, 3.13, 3.14 |
| Linux (musl) | 3.9, 3.10, 3.11, 3.12, 3.13, 3.14 |
Coming from R?
Many Sequenzo users have worked with R packages such as TraMineR, WeightedCluster, and seqHMM. Sequenzo does not replace those packages. It extends the same methodological tradition into Python, with a focus on performance, scale, and integration with pandas, NumPy, scikit-learn, and matplotlib.
If you are moving from R, start with Installing, run the Quickstart, and use the Typical Workflow to see how sequence definition, distance computation, clustering, visualization, and model-based analysis connect.
Team
Paper Authors
- Yuqi Liang, University of Oxford
- Xinyi Li, Northeastern University
- Yapeng Wei, University of Oxford
- Jan Heinrich Ernst Meyerhoff-Liang, Institute for New Economic Thinking Oxford
Package Contributors
Coding contributors:
Documentation contributors:
- Liangxingyun He, Stockholm School of Economics, Sweden
- Yukun Ming, Universidad Carlos III de Madrid (Spain)
- Sizhu Qu, Northeastern University (US)
- Ziting Yang, Rochester University (US)
Others
- With special thanks to our initial testers (alphabetically ordered): Joji Chia, Kass Gonzalez, Sinyee Lu, Sohee Shin
- Website and related technical support: Mactavish
- Sequence data sources compilation - History: Jingrui Chen
- Visual design consultant: Changyu Yi
- Assistance with early-stage performance testing of Sequenzo: Qian Wang, Ruxin Xue, Min Zhao, Tia (Qi Dai).
Acknowledgements
- Amazing authors of R packages in social sequence analysis, including TraMineR (Gabadinho et al. 2011), WeightedCluster (Studer, 2013), and seqHMM (Helske & Helske, 2019)
- Methodological advisor in sequence analysis: Professor Tim Liao (University of Illinois Urbana-Champaign)
- Yuqi's PhD advisor Professor Ridhi Kashyap (University of Oxford), and mentor Charles Rahal (University of Oxford)
- Social Sequence Analysis Association
- Helpful discussions and comments:
- Yuqi's original programming mentor: JiangHuShiNian
References
Abbott, A. (1983). Sequences of social events: Concepts and methods for the analysis of order in social processes. Historical Methods: A Journal of Quantitative and Interdisciplinary History, 16(4), 129-147.
Fasang, A. E., & Liao, T. F. (2013). Visualizing Sequences in the Social Sciences: Relative Frequency Sequence Plots: Relative Frequency Sequence Plots. Sociological Methods & Research, 43(4), 643-676. https://doi.org/10.1177/0049124113506563 (Original work published 2014)
Helske, S., & Helske, J. (2019). Mixture hidden Markov models for sequence data: The seqHMM package in R. Journal of Statistical Software, 88, 1-32.
Liao, T. F., Bolano, D., Brzinsky-Fay, C., Cornwell, B., Fasang, A. E., Helske, S., Piccarreta, R., Raab, M., Ritschard, G., Struffolino, E. et al. (2022), 'Sequence analysis: Its past, present, and future', Social science research 107, 102772.
Losacker, S., & Kuebart, A. (2024). Introducing sequence analysis to economic geography. Progress in Economic Geography, 2(1), 100012.
Gabadinho, A., Ritschard, G., Muller, N. S. & Studer, M. (2011), 'Analyzing and visualizing state sequences in r with traminer', Journal of statistical software 40, 1–37.
Ritschard, G., Studer, M., Buergin, R., Liao, T.F., Gabadinho, A., Fonta, P.A., Muller, N.S. and Rousset, P. (2021). Package ‘TraMineRextras’. Comprehensive R Archive Network (CRAN).
Raab, M. (2022). ggseqplot: Render Sequence Plots using ‘ggplot2’. https://doi.org/10.32614/CRAN.package.ggseqplot
Studer, M. (2013). WeightedCluster library manual. A practical guide to creating typologies of trajectories in the social sciences with, 2013(24), 33.
Studer, M., Sadeghi, R., & Tochon, L. (2024). Sequence analysis for large databases (Vol. 104, pp. 1–42). LIVES Working Papers.
Content writer of this webpage: Yuqi Liang