import { ClassifierBase } from '../base'; import { Params } from '../base/estimator'; export type LDASolver = 'svd' | 'eigen'; export interface LinearDiscriminantAnalysisProps { /** * 'svd' (default, matches sklearn): no covariance matrix is formed, so it * is robust to many features and rank-deficient data. 'eigen' solves the * generalized eigenproblem Sw^-1 Sb and supports shrinkage. * sklearn's 'lsqr' solver is intentionally not implemented: it produces * the same classifier as 'eigen' but cannot transform. */ solver?: LDASolver; /** Shrinkage strength in [0, 1] for the within-class covariance ('eigen' solver only). */ shrinkage?: number; /** Class priors (in sorted-class order). Defaults to class frequencies. */ priors?: number[]; /** Dimensionality for `transform`; at most min(nClasses - 1, nFeatures). */ nComponents?: number; /** Rank-estimation threshold for the SVD solver. */ tol?: number; } /** * Linear Discriminant Analysis matching sklearn's * `LinearDiscriminantAnalysis` for the 'svd' and 'eigen' solvers: a linear * classifier with class-conditional Gaussian densities sharing one covariance * matrix, that doubles as a supervised dimensionality reduction (transform * projects onto the most discriminative axes). */ export declare class LinearDiscriminantAnalysis extends ClassifierBase { private solver; private shrinkage?; private priors?; private nComponents?; private tol; private classes; private classPriors; private means; private xbar; /** projection matrix, nFeatures x nDiscriminantAxes */ private scalings; /** per-class linear scores: coef[k] . x + intercept[k], shape [nClasses][nFeatures] */ private coefState; private intercept; private explainedVarianceRatio; private maxComponents; private nFeatures; private fitted; constructor(props?: LinearDiscriminantAnalysisProps); getParams(): Params; fit(X: number[][], y: number[]): void; /** * sklearn's `_solve_svd`: never forms a covariance matrix. Std-scale the * class-centered data, SVD it to whiten within-class directions (rank cut * at `tol`), then SVD the whitened between-class means. */ private solveSVD; /** Biased covariance (divide by n) with optional shrinkage toward mean-eigenvalue identity. */ private static shrunkCovariance; /** * sklearn's `_solve_eigen`: generalized eigenproblem Sb v = lambda Sw v, * solved via Cholesky of Sw (eigenvectors normalized so v' Sw v = 1, * matching scipy.linalg.eigh). */ private solveEigen; private assertFitted; /** Per-class linear scores, shape [nSamples][nClasses]. */ private decisionScores; predict(testX: number[][]): number[]; /** Softmax over the per-class linear scores (sklearn parity). */ predictProba(testX: number[][]): number[][]; /** * Binary: 1-D signed scores for `classes[1]` (sklearn convention). * Multiclass: per-class scores, shape [nSamples][nClasses]. */ decisionFunction(testX: number[][]): number[] | number[][]; /** Project data onto the discriminant axes (at most nComponents columns). */ transform(X: number[][]): number[][]; fitTransform(X: number[][], y: number[]): number[][]; getClasses(): number[]; /** Weight matrix in sklearn shape: [1][nFeatures] for binary, [nClasses][nFeatures] otherwise. */ getCoef(): number[][]; get coef(): number[][]; /** Intercepts in sklearn shape: length 1 for binary, nClasses otherwise. */ getIntercept(): number[]; getMeans(): number[][]; getPriors(): number[]; getScalings(): number[][]; getExplainedVarianceRatio(): number[]; }