prince

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

https://github.com/maxhalford/prince

Science Score: 54.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
  • Academic publication links
  • Committers with academic emails
    3 of 15 committers (20.0%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (11.3%) to scientific vocabulary

Keywords

ca correspondence-analysis factor-analysis famd mca mfa multiple-correspondence-analysis multiple-factor-analysis pandas pca principal-component-analysis procrustes python scikit-learn svd

Keywords from Contributors

polynomials mesh sequences interactive hacking network-simulation
Last synced: 6 months ago · JSON representation ·

Repository

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

Basic Info
Statistics
  • Stars: 1,396
  • Watchers: 26
  • Forks: 186
  • Open Issues: 0
  • Releases: 0
Topics
ca correspondence-analysis factor-analysis famd mca mfa multiple-correspondence-analysis multiple-factor-analysis pandas pca principal-component-analysis procrustes python scikit-learn svd
Created over 9 years ago · Last pushed 7 months ago
Metadata Files
Readme Contributing Funding License Citation

README.md

prince_logo


documentation pypi pepy pepy_month Unit tests Code quality license


Prince is a Python library for multivariate exploratory data analysis in Python. It includes a variety of methods for summarizing tabular data, including principal component analysis (PCA) and correspondence analysis (CA). Prince provides efficient implementations, using a scikit-learn API.

I made Prince when I was at university, back in 2016. I spent a significant amount of time in 2022 to revamp the entire package. It is thoroughly tested and supports many features, such as supplementary row/columns, as well as row/column weights.

Example usage

```py

import prince

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

pca = prince.PCA(ncomponents=5) pca = pca.fit(decastar, supplementarycolumns=['rank', 'points']) pca.eigenvalues_summary eigenvalue % of variance % of variance (cumulative) component 0 3.114 31.14% 31.14% 1 2.027 20.27% 51.41% 2 1.390 13.90% 65.31% 3 1.321 13.21% 78.52% 4 0.861 8.61% 87.13%

pca.transform(dataset).tail() component 0 1 2 3 4 competition athlete OlympicG Lorenzo 2.070933 1.545461 -1.272104 -0.215067 -0.515746 Karlivans 1.321239 1.318348 0.138303 -0.175566 -1.484658 Korkizoglou -0.756226 -1.975769 0.701975 -0.642077 -2.621566 Uldal 1.905276 -0.062984 -0.370408 -0.007944 -2.040579 Casarsa 2.282575 -2.150282 2.601953 1.196523 -3.571794

```

```py

chart = pca.plot(dataset)

```

This chart is interactive, which doesn't show on GitHub. The green points are the column loadings.

```py

chart = pca.plot( ... dataset, ... showrowlabels=True, ... showrowmarkers=False, ... rowlabelscolumn='athlete', ... colorrowsby='competition' ... )

```

Installation

sh pip install prince

🎨 Prince uses Altair for making charts.

Methods

mermaid flowchart TD cat?(Categorical data?) --> |"✅"| num_too?(Numerical data too?) num_too? --> |"✅"| FAMD num_too? --> |"❌"| multiple_cat?(More than two columns?) multiple_cat? --> |"✅"| MCA multiple_cat? --> |"❌"| CA cat? --> |"❌"| groups?(Groups of columns?) groups? --> |"✅"| MFA groups? --> |"❌"| shapes?(Analysing shapes?) shapes? --> |"✅"| GPA shapes? --> |"❌"| PCA

Principal component analysis (PCA)

Correspondence analysis (CA)

Multiple correspondence analysis (MCA)

Multiple factor analysis (MFA)

Factor analysis of mixed data (FAMD)

Generalized procrustes analysis (GPA)

Correctness

Prince is tested against scikit-learn and FactoMineR. For the latter, rpy2 is used to run code in R, and convert the results to Python, which allows running automated tests. See more in the tests directory.

Citation

Please use this citation if you use this software as part of a scientific publication.

bibtex @software{Halford_Prince, author = {Halford, Max}, license = {MIT}, title = {{Prince}}, url = {https://github.com/MaxHalford/prince} }

License

The MIT License (MIT). Please see the license file for more information.

Owner

  • Name: Max Halford
  • Login: MaxHalford
  • Kind: user
  • Location: France
  • Company: @carbonfact

🌱 Head of Data @carbonfact

Citation (CITATION.cff)

# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!

cff-version: 1.2.0
title: Prince
message: >-
  Please use this citation if you use this software as part
  of a scientific publication.
type: software
authors:
  - given-names: Max
    family-names: Halford
    email: maxhalford25@gmail.com
    orcid: "https://orcid.org/0000-0003-1464-4520"
repository-code: "https://github.com/MaxHalford/prince"
url: "https://maxhalford.github.io/prince"
abstract: "Factor analysis in Python: PCA, CA, MCA, MFA, FAMD, GPA"
license: MIT

GitHub Events

Total
  • Issues event: 7
  • Watch event: 119
  • Delete event: 7
  • Issue comment event: 10
  • Push event: 26
  • Pull request event: 15
  • Fork event: 7
  • Create event: 7
Last Year
  • Issues event: 7
  • Watch event: 119
  • Delete event: 7
  • Issue comment event: 10
  • Push event: 26
  • Pull request event: 15
  • Fork event: 7
  • Create event: 7

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 403
  • Total Committers: 15
  • Avg Commits per committer: 26.867
  • Development Distribution Score (DDS): 0.099
Past Year
  • Commits: 42
  • Committers: 2
  • Avg Commits per committer: 21.0
  • Development Distribution Score (DDS): 0.048
Top Committers
Name Email Commits
Max Halford m****5@g****m 363
Charles Guan c****n@c****u 10
Macarena Fernandez Urquiza m****a@g****m 5
dependabot[bot] 4****] 4
Francis Lacoste f****e@s****m 4
Maxime m****5@c****u 3
Jose D. Hernandez-Betancur 4****e 3
Mario Kahlhofer m****r@j****t 2
Franck Pommereau f****u@g****m 2
Uziel Linares u****z@g****m 2
regonn p****r@r****z 1
Steven Moran b****t@g****m 1
Serhii Kupriienko s****o@a****m 1
Matthew Calcote m****e@c****m 1
Liutong Zhou l****u@c****u 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 98
  • Total pull requests: 35
  • Average time to close issues: about 1 year
  • Average time to close pull requests: about 1 month
  • Total issue authors: 93
  • Total pull request authors: 14
  • Average comments per issue: 3.43
  • Average comments per pull request: 1.26
  • Merged pull requests: 25
  • Bot issues: 0
  • Bot pull requests: 11
Past Year
  • Issues: 2
  • Pull requests: 12
  • Average time to close issues: about 2 hours
  • Average time to close pull requests: 8 days
  • Issue authors: 2
  • Pull request authors: 3
  • Average comments per issue: 2.5
  • Average comments per pull request: 1.25
  • Merged pull requests: 5
  • Bot issues: 0
  • Bot pull requests: 7
Top Authors
Issue Authors
  • normanius (3)
  • Melkaz (2)
  • luesibuesi (2)
  • adeebabdulsalam (2)
  • m1ngle (1)
  • luismavs (1)
  • dialvarezs (1)
  • nico695 (1)
  • babinu-uthup-4JESUS-zz (1)
  • wayfarer91-tog (1)
  • kabirmdasraful (1)
  • lenafm (1)
  • ghost (1)
  • christophe-williams (1)
  • noemifasties (1)
Pull Request Authors
  • dependabot[bot] (19)
  • MaxHalford (12)
  • flacoste (3)
  • MaximeKan (2)
  • SR42 (1)
  • skupr-anaconda (1)
  • fpom (1)
  • macfernandez (1)
  • jodhernandezbe (1)
  • charlesincharge (1)
  • ulinares (1)
  • bambooforest (1)
  • Vaseekaran-V (1)
  • blu3r4y (1)
Top Labels
Issue Labels
enhancement (5) help wanted (3) needs investigating (3) bug (3) invalid (2) new (1)
Pull Request Labels
dependencies (19) python (1)

Packages

  • Total packages: 3
  • Total downloads:
    • pypi 257,178 last-month
  • Total docker downloads: 85
  • Total dependent packages: 6
    (may contain duplicates)
  • Total dependent repositories: 101
    (may contain duplicates)
  • Total versions: 69
  • Total maintainers: 1
pypi.org: prince

Factor analysis in Python: PCA, CA, MCA, MFA, FAMD, GPA

  • Versions: 61
  • Dependent Packages: 6
  • Dependent Repositories: 91
  • Downloads: 257,178 Last month
  • Docker Downloads: 85
Rankings
Downloads: 1.1%
Dependent repos count: 1.6%
Dependent packages count: 1.9%
Average: 1.9%
Docker downloads count: 3.0%
Maintainers (1)
Last synced: 6 months ago
conda-forge.org: prince-factor-analysis
  • Versions: 5
  • Dependent Packages: 0
  • Dependent Repositories: 1
Rankings
Stargazers count: 13.1%
Forks count: 13.9%
Dependent repos count: 24.1%
Average: 25.7%
Dependent packages count: 51.5%
Last synced: 6 months ago
anaconda.org: prince

Prince is a Python library for multivariate exploratory data analysis in Python. It includes a variety of methods for summarizing tabular data, including principal component analysis (PCA) and correspondence analysis (CA). Prince provides efficient implementations, using a scikit-learn API.

  • Versions: 3
  • Dependent Packages: 0
  • Dependent Repositories: 9
Rankings
Stargazers count: 22.7%
Forks count: 24.2%
Average: 31.6%
Dependent repos count: 38.7%
Dependent packages count: 41.0%
Last synced: 6 months ago

Dependencies

.github/actions/install-env/action.yml actions
  • actions/cache v3 composite
  • actions/checkout v3 composite
  • actions/setup-python v4 composite
  • r-lib/actions/setup-r v2 composite
  • r-lib/actions/setup-r-dependencies v2 composite
  • snok/install-poetry v1 composite
.github/workflows/code-quality.yml actions
  • ./.github/actions/install-env * composite
  • actions/checkout v3 composite
.github/workflows/hugo.yml actions
  • ./.github/actions/install-env * composite
  • actions/checkout v3 composite
  • actions/configure-pages v3 composite
  • actions/deploy-pages v1 composite
  • actions/upload-pages-artifact v1 composite
.github/workflows/unit-tests.yml actions
  • ./.github/actions/install-env * composite
  • actions/checkout v3 composite
tests/DESCRIPTION cran
  • FactoMineR * imports
poetry.lock pypi
  • altair 4.2.2
  • appnope 0.1.3
  • asttokens 2.2.1
  • attrs 23.1.0
  • backcall 0.2.0
  • backports-zoneinfo 0.2.1
  • beautifulsoup4 4.12.2
  • black 22.12.0
  • bleach 6.0.0
  • cffi 1.15.1
  • cfgv 3.3.1
  • click 8.1.3
  • colorama 0.4.6
  • comm 0.1.3
  • debugpy 1.6.7
  • decorator 5.1.1
  • defusedxml 0.7.1
  • distlib 0.3.6
  • entrypoints 0.4
  • exceptiongroup 1.1.1
  • executing 1.2.0
  • fastjsonschema 2.16.3
  • fbpca 1.0
  • filelock 3.12.0
  • identify 2.5.24
  • importlib-metadata 6.4.1
  • importlib-resources 5.12.0
  • iniconfig 2.0.0
  • ipykernel 6.22.0
  • ipython 8.12.0
  • jedi 0.18.2
  • jinja2 3.1.2
  • joblib 1.2.0
  • jsonschema 4.17.3
  • jupyter-client 8.2.0
  • jupyter-core 5.3.0
  • jupyterlab-pygments 0.2.2
  • markupsafe 2.1.2
  • matplotlib-inline 0.1.6
  • mistune 2.0.5
  • mypy-extensions 1.0.0
  • nbclient 0.7.3
  • nbconvert 7.3.1
  • nbformat 5.8.0
  • nest-asyncio 1.5.6
  • nodeenv 1.8.0
  • numpy 1.24.2
  • packaging 23.1
  • pandas 2.0.0
  • pandocfilters 1.5.0
  • parso 0.8.3
  • pathspec 0.11.1
  • pexpect 4.8.0
  • pickleshare 0.7.5
  • pkgutil-resolve-name 1.3.10
  • platformdirs 3.2.0
  • pluggy 1.0.0
  • pre-commit 3.3.2
  • prompt-toolkit 3.0.38
  • psutil 5.9.5
  • ptyprocess 0.7.0
  • pure-eval 0.2.2
  • pycparser 2.21
  • pygments 2.15.0
  • pyrsistent 0.19.3
  • pytest 7.3.1
  • python-dateutil 2.8.2
  • pytz 2023.3
  • pytz-deprecation-shim 0.1.0.post0
  • pywin32 306
  • pyyaml 6.0
  • pyzmq 25.0.2
  • rpy2 3.5.11
  • ruff 0.0.270
  • scikit-learn 1.2.2
  • scipy 1.9.3
  • setuptools 67.8.0
  • six 1.16.0
  • soupsieve 2.4.1
  • stack-data 0.6.2
  • threadpoolctl 3.1.0
  • tinycss2 1.2.1
  • tomli 2.0.1
  • toolz 0.12.0
  • tornado 6.3.3
  • traitlets 5.9.0
  • typing-extensions 4.5.0
  • tzdata 2023.3
  • tzlocal 4.3
  • virtualenv 20.23.0
  • wcwidth 0.2.6
  • webencodings 0.5.1
  • zipp 3.15.0
pyproject.toml pypi
  • altair ^4.2.2 || ^5.0.0
  • pandas ^1.4.1 || ^2.0.0
  • python ^3.8
  • scikit-learn ^1.0.2