How oliviergarciadev/fanalysis works
Project type and purpose
• This is an open-source Python library (“fanalysis”) that implements three factorial analysis methods (Simple Correspondence Analysis, Multiple Correspondence Analysis, Principal Components Analysis).
• It exposes these methods both as standalone functions/classes and as transformers compatible with scikit-learn pipelines.
• The repository includes source code, a test suite (unittest comparing against R FactoMineR), tutorial notebooks, and a setup script for packaging.
File structure
• Top-level:
• setup.py (packaging/install)
• README.md (project overview)
• LICENSE, .gitignore
• doc/ (Jupyter/PDF tutorials for each analysis)
• fanalysis/ (the Python package)
• fanalysis/tests/ (unit tests and expected-output fixtures)
• Within fanalysis/:
• base.py: abstract base class FactorialAnalysis with common logic (fit, transform, fit_transform).
• ca.py, mca.py, pca.py: concrete subclasses implementing each analysis.
• __init__.py: package entry point.
• Tests are text fixtures plus test_*.py that load fixtures, run the algorithms, and compare results.
Extract architecture insights from README
• Dependencies: NumPy, Pandas, scikit-learn, Matplotlib.
• Dual usage: as descriptive analysis and as reduction step in ML pipelines.
• Installation via pip (setup.py).
Main components
a. User/Application Layer
– Client code or Jupyter notebooks that import fanalysis and call methods or plug into scikit-learn pipelines.
b. Core Library (fanalysis package)
– base.py: abstract class
– CA, MCA, PCA modules inheriting from base
– Utilities for eigen-decomposition, coordinate computations, contributions, cos2, labels
c. External Dependencies
– NumPy (arrays, linear algebra)
– Pandas (DataFrame input/output)
– scikit-learn (pipeline interface)
– Matplotlib (optional plotting)
d. Test Suite
– Test runner (unittest)
– Fixture data (expected outputs from R FactoMineR)
e. Documentation & Tutorials
– Jupyter notebooks and PDFs under doc/
Component interactions & data flow
• The User/Application invokes fanalysis.FactorialAnalysis subclasses via fit/transform APIs.
• fanalysis modules internally call NumPy for matrix operations, Pandas for data handling, and optionally Matplotlib for plotting.
• When used in scikit-learn pipelines, fanalysis objects are wrapped in Pipeline objects.
• The Test Suite executes fanalysis methods on fixture data, reads expected outputs, and asserts equality.
• setup.py bundles the package and declares external dependencies for pip installation.
Architectural patterns & design principles
• Template Method pattern: base.py defines the skeleton (fit, transform), subclasses supply specifics.
• Adapter pattern: fanalysis classes implement scikit-learn TransformerMixin and BaseEstimator, making them pluggable in ML workflows.
• Separation of concerns: computational logic vs. I/O (Pandas) vs. plotting (Matplotlib) vs. testing.
Final checklist
• [ ] Core library split into base + three analysis modules
• [ ] External dependencies labeled and connected
• [ ] User/client and test suite entry points shown
• [ ] Packaging/install layer indicated
• [ ] Notes on architectural patterns (Template Method, Adapter)