Library / SDK
MaxHalford/prince avatar
MaxHalford/prince

Prince for multivariate exploratory data analysis in Python

:crown: Multivariate exploratory data analysis in Python — PCA, CA, MCA, MFA, FAMD, GPA

1,486 stars197 forksPythonMIT

At a glance

What is it?
Prince provides a scikit-learn-style Python interface for PCA, CA, MCA, MFA, FAMD, GPA and PGA. It covers several tabular data structures, but users must select the estimator that matches their columns and analytical objective.
Who is it for?
Prince suits Python users who need exploratory dimensions, scores, loadings and Altair charts from pandas DataFrames. It does not fit teams seeking a documented supervised modelling, causal inference or statistical inference workflow.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository last received commits 1 day ago.
What is it written in?
Mainly Python, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on October 22, 2026, and from our analysis. They are not legal advice.

Editorial analysis

Prince's role in exploratory analysis

Prince addresses the problem of reducing structured tabular data to a smaller collection of dimensions that analysts can inspect through scores, loadings, eigenvalues and plots. It is intended for Python users who want several multivariate exploratory methods behind a consistent scikit-learn-style interface. The documented estimator workflow consists of fitting a model to a DataFrame, transforming observations into component coordinates and creating an Altair chart.

The package covers more than numerical PCA. Its methods include principal component analysis, correspondence analysis, multiple correspondence analysis, multiple factor analysis, factor analysis of mixed data, generalized procrustes analysis and principal geodesic analysis. This range is the main reason to consider Prince instead of selecting a single decomposition routine. However, the estimators are not interchangeable. Their expected inputs differ according to whether the DataFrame contains numerical variables, categorical variables, groups, shape representations or manifold-valued observations.

The README presents Prince as a library for summarizing tabular data, not as a complete statistical analysis environment. It documents score transformation, supplementary rows and columns, row and column weights, result summaries and interactive plots. It does not document predictive targets, cross-validation, confidence intervals, causal identification or production monitoring. That boundary matters when deciding whether the project fits a request for exploratory structure or a different statistical objective.

Prince's estimator and plotting workflow

The decathlon example shows the normal analysis path. It loads a dataset through `prince.datasets.load_decathlon()`, filters the table to rows where `competition == "Decastar"`, creates `prince.PCA(n_components=5)` and calls `fit` with `rank` and `points` designated as supplementary columns. The resulting `eigenvalues_summary` reports the eigenvalue, percentage of variance and cumulative percentage of variance for each component.

A fitted estimator can transform rows into component coordinates. In the documented example, `pca.transform(dataset)` returns a pandas table indexed by competition and athlete, with numeric columns named 0 through 4. Keeping fit and transform as separate operations makes the API suitable for workflows in which one table defines the analysis and another table is projected into its component space.

Plotting remains attached to the fitted estimator. The default `pca.plot(dataset)` call produces an interactive chart according to the README. Another documented call controls labels, markers and color grouping by setting `show_row_labels=True`, `show_row_markers=False`, `row_labels_column='athlete'` and `color_rows_by='competition'`. Prince uses Altair for chart creation. The repository does not document a dedicated command for serving, exporting or displaying that chart, so the containing Python or notebook environment determines how it is presented.

This design is convenient for exploration because the same estimator exposes fitting, transformation, summaries and plotting. It does not mean that every Prince estimator has identical result properties. The README gives enough detail for PCA, but its general overview does not document equivalent output tables for CA, MCA, MFA, FAMD, GPA or PGA.

Installing Prince and fitting the documented PCA model

The README instructs users to install the package from PyPI with `pip install prince`. The package metadata requires Python 3.10 or later. Its runtime dependencies are `scikit-learn>=1.5.1`, `pandas>=2.2.0`, `altair>=5.0.0` and `typing-extensions>=4.6`, so the resulting environment includes the numerical and plotting libraries used by the documented workflow.

The following block follows the README example exactly. It loads the decathlon dataset, filters for the `Decastar` competition, fits five PCA components and treats `rank` and `points` as supplementary columns.

python
import prince

dataset = prince.datasets.load_decathlon()
decastar = dataset.query('competition == "Decastar"')

pca = prince.PCA(n_components=5)
pca = pca.fit(decastar, supplementary_columns=['rank', 'points'])

Users can then inspect the eigenvalue and variance summary shown in the README. It contains columns for `eigenvalue`, `% of variance` and `% of variance (cumulative)`, with rows beginning at component 0. The README reports 31.14% cumulative variance for the first component and 87.13% after component 4 for this dataset.

The documented transformation call returns the final rows of the projected dataset. Its row index contains competition and athlete labels, while the component columns contain numeric coordinates.

python
pca.transform(dataset).tail()

The first plotting call creates the README's interactive PCA chart.

python
chart = pca.plot(dataset)

The second call shows the documented controls for labels, markers and colors. The result assigns the chart to `chart`, as in the README.

python
chart = pca.plot(
    dataset,
    show_row_labels=True,
    show_row_markers=False,
    row_labels_column='athlete',
    color_rows_by='competition'
)

The README does not identify a required IDE, notebook server or browser command for viewing the chart.

Selecting the correct Prince estimator

Method selection is a data-modeling decision rather than a matter of choosing the estimator with the shortest name. The README's decision diagram asks whether columns are organized into groups, whether the data is categorical, whether numerical columns are present, whether the problem concerns shapes and whether observations lie on a manifold.

For ungrouped numerical data, the diagram ends at PCA. CA follows when the input is categorical and has two categorical columns. MCA applies to multiple categorical columns, while FAMD is selected when categorical and numerical columns occur together. MFA is the branch for columns organized into groups. GPA is presented for analysing shapes, and PGA for data on a manifold.

These branches expose several concrete failure modes. Choosing PCA for categorical columns can apply the wrong analysis to the representation. Choosing CA for more than two categorical columns ignores the method selected for the broader multiple-category case. Passing mixed variables to MCA rather than FAMD conflicts with the README's routing. Treating ordinary vectors as manifold observations selects PGA where the representation does not support that interpretation. Finally, grouping information is relevant to MFA, so a flat DataFrame may not retain what the intended analysis requires.

The repository overview gives only short links for several individual methods. It does not include their full input schemas, defaults or result-table formats on its main page. Prospective users must therefore check the method documentation before assuming that a DataFrame accepted by one estimator will also work with another.

Prince versus direct scikit-learn and FactoMineR workflows

The most concrete alternative named by the repository is scikit-learn, particularly for numerical analysis through PCA. The README says Prince is tested against scikit-learn, and `scikit-learn>=1.5.1` is also a Prince runtime dependency. A project that only needs a standard numerical PCA pipeline may already have a direct scikit-learn path in its dependency stack. Prince becomes more relevant when the same codebase needs access to CA, MCA, MFA, FAMD, GPA and PGA through a related estimator interface.

FactoMineR is the second explicit comparison. According to the README, Prince is tested against FactoMineR through `rpy2`, which runs code in R and converts the results to Python for automated checks. That is a different implementation environment. Prince exposes the documented methods as a Python package. The repository describes numerical comparison rather than claiming that their APIs, preprocessing defaults or reporting workflows are identical.

The practical difference is integration cost. A scikit-learn-only team may prefer its established PCA implementation if it does not need Prince's additional methods. A Python team seeking several exploratory decompositions can gain a common API and Altair plotting, but must accept Prince's documented input constraints. A team requiring the exact FactoMineR comparison path must account for R and `rpy2`, which are development dependencies rather than part of Prince's normal runtime installation.

Correctness checks, licensing and upgrade boundaries

Prince's correctness section identifies three external comparison paths. The README states that Prince is tested against scikit-learn and FactoMineR, with `rpy2` used to execute FactoMineR code in R and convert results into Python. It also states that PGA is tested against `geomstats`. The repository includes a `tests` directory and configures pytest doctests in `pyproject.toml`, including doctests from Python modules and Markdown files.

Those checks document how maintainers compare results, but they do not replace checking a new dataset. The README does not define treatment rules for missing values, unsupported categorical values or every index configuration. It also does not claim that cross-tool tests cover every estimator parameter. Users should compare relevant outputs when a result will drive a scientific or operational decision.

The project metadata records version 0.21.0 and dependency lower bounds. It is not archived, and its last push was on 2026-10-08. No GitHub releases are listed, so there is no release cadence to infer from the repository record. An upgrade can change interactions with the minimum supported `scikit-learn` and `pandas` versions, especially when code relies on DataFrame dtypes, indices or transformed table structure.

Prince uses the MIT License. The repository points users to the `LICENSE` file for its terms. That is a permissive license commonly chosen for reusable Python libraries, but this review does not substitute for legal advice about a particular deployment.

Editorial conclusion

Prince suits Python users who need exploratory dimensions, scores, loadings and Altair charts from pandas DataFrames. It does not fit teams seeking a documented supervised modelling, causal inference or statistical inference workflow. Before adoption, verify the estimator against the structure of the dataset, including its data types, row labels, groups, supplementary variables and any mixed categorical and numerical columns.

Frequently asked questions

How do I install Prince?

The README gives `pip install prince` as the installation command. The package metadata requires Python 3.10 or later and lists scikit-learn, pandas, Altair and typing-extensions as runtime dependencies.

Which analysis methods does Prince provide?

Prince documents PCA, CA, MCA, MFA, FAMD, GPA and PGA. Its README includes a decision diagram that associates these methods with grouped, categorical, numerical, shape and manifold data.

Can Prince analyse mixed categorical and numerical data?

Yes, FAMD is the documented method for a table containing both categorical and numerical columns. MCA is listed for multiple categorical columns, while PCA is the ordinary numerical branch in the README's selection diagram.

Does Prince create interactive charts?

The README states that Prince uses Altair and that the PCA chart is interactive. It also documents options for row labels, row markers and coloring rows by a DataFrame column.

How does the repository check Prince's correctness?

The README says Prince is tested against scikit-learn and FactoMineR. The FactoMineR comparison uses `rpy2` to run R code and convert results to Python, while PGA is tested against `geomstats`.

Official sources

  1. Issues
  2. License: MIT
  3. MaxHalford/prince on GitHub
  4. Project website
  5. README
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/maxhalford-prince.svg)](https://hysenlabs.com/projects/maxhalford-prince)