SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 1404.1100 · 2014

A Tutorial on Principal Component Analysis

arXiv · PDF · Open in the Atlas

Code that ran

10 of 11 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 10 have no contract verdict; 0 failures of our instrument; 1 no recorded run), measured 2026-11-22; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/1404.1100.json · badge: /api/ran/1404.1100.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
maxhalford/prince community (classifier label)
classifier basis not recorded on the link
10 ran · 1 no recorded run
FunctionStatusWhere it lives
build_ellipse Ran
ran on a synthesized input
maxhalford/prince/prince/plot.py
code served (permissive licence) · get_code("401a4194818f1a11")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 1, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np
from scipy import linalg

# Create sample 1D arrays for X and Y
X = np.array([1.0, 2.0, 3.0, 4.0, 5.0])
Y = np.array([2.0, 4.0, 5.0, 4.0, 6.0])

ARGS = {
    "X": X,
    "Y": Y,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, scipy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 1, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
check_is_dataframe_input Ran
ran on a synthesized input
maxhalford/prince/prince/utils.py
code served (permissive licence) · get_code("a380c57525bec844")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned function. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import functools
from collections.abc import Callable
from typing import ParamSpec, TypeVar
import pandas as pd

P = ParamSpec('P')
R = TypeVar('R')

def check_is_dataframe_input(func: Callable[P, R]) -> Callable[P, R]:
    @functools.wraps(func)
    def wrapper(*args, **kwargs):
        X = args[1]
        if not isinstance(X, pd.DataFrame):
            raise ValueError(f'The X argument must be a pandas DataFrame, but got {type(X).__name__}')
        return func(*args, **kwargs)
    return wrapper


# Create a simple function to be decorated
def dummy_function(self, X, y=None):
    return "success"


# Create a simple class to hold the decorated method
class DummyModel:
    @check_is_dataframe_input
    def predict(self, X, y=None):
        return "success"


# Create test arguments
df = pd.DataFrame({
    'feature1': [1, 2, 3],
    'feature2': [4.0, 5.0, 6.0],
    'feature3': ['a', 'b', 'c']
})

model_instance = DummyModel()

ARGS = {
    'func': model_instance.predict
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
pandas — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type function — a function output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a function output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
check_is_fitted Ran
ran on a synthesized input
maxhalford/prince/prince/utils.py
code served (permissive licence) · get_code("53135379e14fd93f")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned function. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import functools
from collections.abc import Callable
from typing import ParamSpec, TypeVar
from sklearn.utils import validation
import torch
import torch.nn as nn

P = ParamSpec('P')
R = TypeVar('R')

def check_is_fitted(method: Callable[P, R]) -> Callable[P, R]:
    @functools.wraps(method)
    def _impl(self, *method_args, **method_kwargs):
        validation.check_is_fitted(self)
        return method(self, *method_args, **method_kwargs)
    return _impl


# Create a simple sklearn-compatible estimator class
class SimpleEstimator:
    def __init__(self):
        self.is_fitted_ = True
    
    def predict(self, X):
        return X


# Create a simple method to decorate
@check_is_fitted
def simple_method(self, x):
    return x * 2


# Define the ARGS dict mapping parameters to values
ARGS = {
    'method': simple_method
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
sklearn, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type function — a function output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a function output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
compute_svd Ran
ran on a synthesized input
maxhalford/prince/prince/svd.py
code served (permissive licence) · get_code("e1845a3b3a8f3316")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned SVD. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import dataclasses
import numpy as np
import scipy
from sklearn.utils import extmath

@dataclasses.dataclass
class SVD:
    U: np.ndarray
    s: np.ndarray
    V: np.ndarray

# Create test data
np.random.seed(42)
X = np.random.randn(6, 4)
n_components = 3
n_iter = 2
row_weights = np.array([1.0, 1.2, 0.9, 1.1, 0.8, 1.3])
column_weights = np.array([1.0, 0.9, 1.1, 0.8])

ARGS = {
    "X": X,
    "n_components": n_components,
    "n_iter": n_iter,
    "engine": "sklearn",
    "random_state": 42,
    "row_weights": row_weights,
    "column_weights": column_weights,
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, scipy, sklearn — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type SVD — a SVD output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a SVD output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
make_labels_and_names Ran
ran on a synthesized input
maxhalford/prince/prince/utils.py
code served (permissive licence) · get_code("b82049109a993489")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import pandas as pd
import numpy as np

# Test case 1: pandas DataFrame with named index and columns
df_with_names = pd.DataFrame(
    np.random.randn(4, 3),
    index=pd.Index(['row0', 'row1', 'row2', 'row3'], name='MyRows'),
    columns=pd.Index(['col0', 'col1', 'col2'], name='MyCols')
)

# Test case 2: numpy array (2D)
numpy_array = np.random.randn(4, 3)

# Use the DataFrame case as the main argument
ARGS = {
    'X': df_with_names
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, pandas — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
select_active_columns Ran
ran on a synthesized input
maxhalford/prince/prince/ca.py
code served (permissive licence) · get_code("87aa5108b3a372ac")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned function. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import functools
from collections.abc import Callable
from typing import Any, ParamSpec, TypeVar, cast
import pandas as pd
import numpy as np

P = ParamSpec('P')
R = TypeVar('R')

def select_active_columns(method: Callable[P, R]) -> Callable[P, R]:
    @functools.wraps(method)
    def _impl(self: Any, X: Any=None, *method_args: Any, **method_kwargs: Any) -> R:
        if hasattr(self, 'active_cols_') and isinstance(X, pd.DataFrame):
            return method(self, X[self.active_cols_], *method_args, **method_kwargs)
        return method(self, X, *method_args, **method_kwargs)
    return cast(Callable[P, R], _impl)


# Create a simple class with a decorated method to test the decorator
class SimpleModel:
    def __init__(self):
        self.active_cols_ = ['col_a', 'col_b']
    
    @select_active_columns
    def fit(self, X, y=None):
        return X.shape


# Create test data
df = pd.DataFrame({
    'col_a': [1, 2, 3],
    'col_b': [4, 5, 6],
    'col_c': [7, 8, 9]
})

model_instance = SimpleModel()

# The decorator function takes a method (Callable) as its only parameter
test_method = model_instance.fit.__wrapped__

ARGS = {
    'method': test_method
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, pandas — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type function — a function output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a function output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
select_active_rows Ran
ran on a synthesized input
maxhalford/prince/prince/ca.py
code served (permissive licence) · get_code("52e691ce86333610")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned function. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import functools
from collections.abc import Callable
from typing import Any, ParamSpec, TypeVar, cast
import pandas as pd
import torch
import torch.nn as nn

torch.manual_seed(0)

P = ParamSpec('P')
R = TypeVar('R')

def select_active_rows(method: Callable[P, R]) -> Callable[P, R]:
    @functools.wraps(method)
    def _impl(self: Any, X: Any=None, *method_args: Any, **method_kwargs: Any) -> R:
        if hasattr(self, 'active_rows_') and isinstance(X, pd.DataFrame):
            return method(self, X.loc[self.active_rows_], *method_args, **method_kwargs)
        return method(self, X, *method_args, **method_kwargs)
    return cast(Callable[P, R], _impl)


# Create a minimal class with active_rows_ attribute and a method to decorate
class MinimalModel:
    def __init__(self):
        self.active_rows_ = [0, 1]
    
    @select_active_rows
    def process(self, X, extra_arg=None):
        return X


# Create test data
df = pd.DataFrame({
    'col1': [1.0, 2.0, 3.0],
    'col2': [4.0, 5.0, 6.0],
    'col3': [7.0, 8.0, 9.0]
})

model_instance = MinimalModel()

# The function signature has these parameters:
# - method: Callable[P, R]
# - (self, X, *method_args, **method_kwargs are in _impl but not in select_active_rows signature)

# The decorator is applied to a method, so we pass a decorated method
decorated_method = select_active_rows(model_instance.process)

ARGS = {
    'method': model_instance.process
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
pandas, torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type function — a function output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a function output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
select_active_variables Ran
ran on a synthesized input
maxhalford/prince/prince/pca.py
code served (permissive licence) · get_code("cdc0e8fa3c2b8a1e")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned function. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import functools
from collections.abc import Callable
from typing import TYPE_CHECKING, Any, ParamSpec, TypeVar, cast
import pandas as pd
import numpy as np

P = ParamSpec('P')
R = TypeVar('R')

def select_active_variables(method: Callable[P, R]) -> Callable[P, R]:
    @functools.wraps(method)
    def _impl(self: Any, X: Any=None, *method_args: Any, **method_kwargs: Any) -> R:
        if hasattr(self, 'feature_names_in_') and isinstance(X, pd.DataFrame):
            return method(self, X[self.feature_names_in_], *method_args, **method_kwargs)
        return method(self, X, *method_args, **method_kwargs)
    return cast(Callable[P, R], _impl)


class MockModel:
    """A minimal sklearn-like model with feature_names_in_ attribute"""
    def __init__(self):
        self.feature_names_in_ = ['feat_a', 'feat_b']
    
    @select_active_variables
    def predict(self, X, *args, **kwargs):
        """Mock prediction method"""
        return np.ones(len(X))


def mock_method(self, X, *args, **kwargs):
    """A simple method to be decorated"""
    return X


# Create test data
df_data = pd.DataFrame({
    'feat_a': [1.0, 2.0],
    'feat_b': [3.0, 4.0],
    'feat_c': [5.0, 6.0]
})

# Create instance with feature_names_in_ attribute
instance = MockModel()

# Build the decorator with the mock method
decorated_method = select_active_variables(mock_method)

ARGS = {
    'method': mock_method
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, pandas — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type function — a function output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a function output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
stylize_axis Ran
ran on a synthesized input
maxhalford/prince/prince/plot.py
code served (permissive licence) · get_code("5ad83f57b4d2d2ec")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Axes. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import matplotlib.pyplot as plt
from collections import OrderedDict

GRAY = OrderedDict([('light', '#bababa'), ('dark', '#404040')])

def stylize_axis(ax, grid=True):
    if grid:
        ax.grid()
    ax.xaxis.set_ticks_position('none')
    ax.yaxis.set_ticks_position('none')
    ax.axhline(y=0, linestyle='-', linewidth=1.2, color=GRAY['dark'], alpha=0.6)
    ax.axvline(x=0, linestyle='-', linewidth=1.2, color=GRAY['dark'], alpha=0.6)
    return ax

fig, ax = plt.subplots()

ARGS = {
    'ax': ax,
    'grid': True
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
matplotlib — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Axes — a Axes output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a Axes output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
unscaled_procrustes Ran
ran on a synthesized input
maxhalford/prince/prince/gpa.py
code served (permissive licence) · get_code("fa46e7074c2047ba")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple, ndim 3, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np
from scipy.linalg import orthogonal_procrustes

# Create small distinct-sized arrays for reference and data
# reference: 5 points in 3 dimensions
# data: 5 points in 3 dimensions (same shape but different values to test alignment)

np.random.seed(0)

reference = np.array([
    [1.0, 2.0, 3.0],
    [2.0, 3.0, 4.0],
    [3.0, 4.0, 5.0],
    [4.0, 5.0, 6.0],
    [5.0, 6.0, 7.0]
], dtype=np.double)

data = np.array([
    [5.1, 4.9, 3.1],
    [4.0, 5.1, 4.0],
    [3.1, 3.9, 5.0],
    [2.0, 4.0, 6.1],
    [1.1, 5.9, 7.0]
], dtype=np.double)

ARGS = {
    "reference": reference,
    "data": data
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
numpy, scipy — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple, ndim 3, dtype family float — a tuple output has no array shape of its own; none is stated
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
load_energy_mix Not yet run
unverified (harvested, no recorded run)
maxhalford/prince/prince/datasets.py
code served (permissive licence) · get_code("857609b1581915f0")
How it ran

no invocation recorded.

Also present in other papers' code

Of 11 samples lifted from this paper's linked repositories, 11 carry a function identity and 0 do not. Of the 11 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 11 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-22.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Principal component analysis (PCA) is a mainstay of modern data analysis - a black box that is widely used but (sometimes) poorly understood. The goal of this paper is to dispel the magic behind this black box. This manuscript focuses on building a solid intuition for how and why principal component analysis works. This manuscript crystallizes this knowledge by deriving from simple intuitions, the mathematics behind PCA. This tutorial does not shy away from explaining the ideas informally, nor does it shy away from the mathematics. The hope is that by addressing both aspects, readers of all levels will be able to gain a better understanding of PCA as well as the when, the how and the why of applying this technique.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("1404.1100")
get_code_for_paper("1404.1100")
have("1404.1100")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/1404.1100.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/1404.1100.svg)](https://syntology.ai/paper/1404.1100)

Connect an agent — have() is free.