A one-sample matrix pseudoinverse
Penguin learning project
The project uses 342 complete Palmer penguin records: 240 training-pool and 102 held-out rows. The selected training rows determine feature scaling and model parameters. Source CSV
This project trains weights with softmax, unlike the homepage lab, which uses nearest species averages. Same penguin measurements; different classification methods. Predictions can differ.
Vectors and matrices · Combine numbers using vector and matrix operations.
Project vectors have two features; the training matrix has n rows and two columns. Mathematical tools may operate on these values when their assumptions apply.
Consider this concept alongside the project; its source assumptions may differ. These observations do not prove a theorem.
Input: 12 × 2; Held-out evaluation: 102 · #58 · 40.6 mm, 193 mm. Known answer: Adélie; Prediction: Adélie · [≈0.7383, ≈0.2444, ≈0.01737].
Used in these source sections: 2.4 A second descent
With one sample whose d coordinates are ±1, its squared norm is d. The source gives this explicit pseudoinverse of its outer-product matrix.
The toy sample is X=(1,−1), so d=2.
The pseudoinverse appears in the source variance calculation.
Source formula example
exact · The result is exact for these finite toy inputs, apart from ordinary computer rounding.
Symbols
- Moore–Penrose pseudoinverse of Σ.
- One binary vector in {−1,1}ᵈ.
Source formula example
This source example uses its own inputs and assumptions. Editing it does not change the project.
Edit a value or the code, then run the example. This is a finite demonstration, not a proof of the paper’s theorem.
This example’s data flow
Code changed. Reset to restore this example’s data flow.
You choose
input.second= -1
Calculated here
Result expression: { x, normSquared, outer, pseudoinverse, projection }
x=[1, input.second]Uses:input.secondnormSquared=x.reduce((sum, value) => sum + value * value, 0)Uses:xouter=x.map((a) => x.map((b) => a * b))Uses:xpseudoinverse=outer.map((row) => row.map((value) => value / normSquared ** 2))Uses:outer,normSquaredprojection=outer.map((row, i) => row.map( (_, j) => (i === j ? 1 : 0) - pseudoinverse[i].reduce((sum, value, k) => sum + value * outer[k][j], 0), ), )Uses:outer,pseudoinverse
Returns
x- array (2 items): [1, -1]
normSquared- 2
outer- array (2 items): [array (2 items): [1, -1], array (2 items): [-1, 1]]
pseudoinverse- array (2 items): [array (2 items): [0.25, -0.25], array (2 items): [-0.25, 0.25]]
projection- array (2 items): [array (2 items): [0.5, 0.5], array (2 items): [0.5, 0.5]]
Read numbers from input and return the result. JavaScript basics.
Result
Technical statement
For a nonzero vector x, the pseudoinverse of xxᵀ is xxᵀ/‖x‖⁴. Binary coordinates make ‖x‖²=d, giving the second expression. This code uses d=2 and also computes P=I−Σ⁺Σ, the orthogonal projection onto the kernel of Σ.
Source: One-sample pseudoinverse