-
-
Notifications
You must be signed in to change notification settings - Fork 7
Description
User Story
As a data scientist, I want access to a comprehensive suite of matrix decomposition methods, so that I can perform advanced dimensionality reduction, feature extraction, and solve complex linear algebra problems efficiently within AiDotNet.
Problem: Missing Fundamental Matrix Decomposition Techniques
The src/DecompositionMethods module has a good structure for different decomposition types, but it lacks several fundamental and widely-used matrix decomposition techniques that are standard in leading machine learning and scientific computing frameworks.
Phase 1: Implement Core Matrix Decompositions
Goal: Add essential matrix decomposition methods for linear algebra and data analysis.
AC 1.1: Create SVD.cs (13 points)
Requirement: Implement Singular Value Decomposition (SVD).
- File:
src/DecompositionMethods/MatrixDecomposition/SVD.cs - Class:
public class SVD<T> - Method:
public (Matrix<T> U, Vector<T> S, Matrix<T> Vt) Decompose(Matrix<T> matrix): Decomposes a matrix into U, S, and V transpose.
AC 1.2: Create NMF.cs (13 points)
Requirement: Implement Non-Negative Matrix Factorization (NMF).
- File:
src/DecompositionMethods/MatrixDecomposition/NMF.cs - Class:
public class NMF<T> - Method:
public (Matrix<T> W, Matrix<T> H) Decompose(Matrix<T> matrix, int nComponents): Decomposes a non-negative matrix into W and H.
AC 1.3: Create LUDecomposition.cs (8 points)
Requirement: Implement LU Decomposition.
- File:
src/DecompositionMethods/MatrixDecomposition/LUDecomposition.cs - Class:
public class LUDecomposition<T> - Method:
public (Matrix<T> L, Matrix<T> U, int[] P) Decompose(Matrix<T> matrix): Decomposes a matrix into lower (L) and upper (U) triangular matrices with pivoting (P).
AC 1.4: Create QRDecomposition.cs (8 points)
Requirement: Implement QR Decomposition.
- File:
src/DecompositionMethods/MatrixDecomposition/QRDecomposition.cs - Class:
public class QRDecomposition<T> - Method:
public (Matrix<T> Q, Matrix<T> R) Decompose(Matrix<T> matrix): Decomposes a matrix into an orthogonal (Q) and upper triangular (R) matrix.
AC 1.5: Unit Tests for Core Decompositions (10 points)
Requirement: Verify the correctness of SVD, NMF, LU, and QR decompositions.
- File:
tests/UnitTests/DecompositionMethods/MatrixDecompositionTests.cs - Test Cases: Test
Decomposemethods with various matrices, comparing results against known values or reference implementations.
Phase 2: Implement Advanced Matrix Decompositions
Goal: Add more specialized decomposition methods for signal separation and matrix analysis.
AC 2.1: Create ICA.cs (13 points)
Requirement: Implement Independent Component Analysis (ICA).
- File:
src/DecompositionMethods/MatrixDecomposition/ICA.cs - Class:
public class ICA<T> - Method:
public Matrix<T> Decompose(Matrix<T> mixedSignals, int nComponents): Separates mixed signals into independent components.
AC 2.2: Create EigenDecomposition.cs (8 points)
Requirement: Implement Eigen Decomposition.
- File:
src/DecompositionMethods/MatrixDecomposition/EigenDecomposition.cs - Class:
public class EigenDecomposition<T> - Method:
public (Vector<T> Eigenvalues, Matrix<T> Eigenvectors) Decompose(Matrix<T> matrix): Decomposes a square matrix into eigenvalues and eigenvectors.
AC 2.3: Create CholeskyDecomposition.cs (8 points)
Requirement: Implement Cholesky Decomposition.
- File:
src/DecompositionMethods/MatrixDecomposition/CholeskyDecomposition.cs - Class:
public class CholeskyDecomposition<T> - Method:
public Matrix<T> Decompose(Matrix<T> matrix): Decomposes a symmetric positive definite matrix into a lower triangular matrix.
AC 2.4: Unit Tests for Advanced Decompositions (10 points)
Requirement: Verify the correctness of ICA, Eigen, and Cholesky decompositions.
- File:
tests/UnitTests/DecompositionMethods/AdvancedMatrixDecompositionTests.cs - Test Cases: Test
Decomposemethods with appropriate matrices, comparing results against known values.
Definition of Done
- All checklist items are complete.
- All specified matrix decomposition methods are implemented and unit-tested.
- All new tests pass.
⚠️ CRITICAL ARCHITECTURAL REQUIREMENTS
Before implementing this user story, you MUST review:
- 📋 Full Requirements:
.github/USER_STORY_ARCHITECTURAL_REQUIREMENTS.md - 📐 Project Rules:
.github/PROJECT_RULES.md
Mandatory Implementation Checklist
1. INumericOperations Usage (CRITICAL)
- Include
protected static readonly INumericOperations<T> NumOps = MathHelper.GetNumericOperations<T>();in base class - NEVER hardcode
double,float, or specific numeric types - use genericT - NEVER use
default(T)- useNumOps.Zeroinstead - Use
NumOps.Zero,NumOps.One,NumOps.FromDouble()for values - Use
NumOps.Add(),NumOps.Multiply(), etc. for arithmetic - Use
NumOps.LessThan(),NumOps.GreaterThan(), etc. for comparisons
2. Inheritance Pattern (REQUIRED)
- Create
I{FeatureName}.csinsrc/Interfaces/(root level, NOT subfolders) - Create
{FeatureName}Base.csinsrc/{FeatureArea}/inheriting from interface - Create concrete classes inheriting from Base class (NOT directly from interface)
3. PredictionModelBuilder Integration (REQUIRED)
- Add private field:
private I{FeatureName}<T>? _{featureName};toPredictionModelBuilder.cs - Add Configure method taking ONLY interface (no parameters):
public IPredictionModelBuilder<T, TInput, TOutput> Configure{FeatureName}(I{FeatureName}<T> {featureName}) { _{featureName} = {featureName}; return this; }
- Use feature in
Build()with default:var {featureName} = _{featureName} ?? new Default{FeatureName}<T>(); - Verify feature is ACTUALLY USED in execution flow
4. Beginner-Friendly Defaults (REQUIRED)
- Constructor parameters with defaults from research/industry standards
- Document WHY each default was chosen (cite papers/standards)
- Validate parameters and throw
ArgumentExceptionfor invalid values
5. Property Initialization (CRITICAL)
- NEVER use
default!operator - String properties:
= string.Empty; - Collections:
= new List<T>();or= new Vector<T>(0); - Numeric properties: appropriate default or
NumOps.Zero
6. Class Organization (REQUIRED)
- One class/enum/interface per file
- ALL interfaces in
src/Interfaces/(root level) - Namespace mirrors folder structure (e.g.,
src/Regularization/→namespace AiDotNet.Regularization)
7. Documentation (REQUIRED)
- XML documentation for all public members
-
<b>For Beginners:</b>sections with analogies and examples - Document all
<param>,<returns>,<exception>tags - Explain default value choices
8. Testing (REQUIRED)
- Minimum 80% code coverage
- Test with multiple numeric types (double, float)
- Test default values are applied correctly
- Test edge cases and exceptions
- Integration tests for PredictionModelBuilder usage
See full details: .github/USER_STORY_ARCHITECTURAL_REQUIREMENTS.md