webshap
Version:
Explain any ML models anywhere
20 lines (19 loc) • 779 B
TypeScript
/**
* Weighted least square solver
* @author: Jay Wang
*/
import math from '../../src/utils/math-import';
/**
* Solves linear least squares problems for given input matrix `x`,
* target matrix `y`, and weight matrix `w`.
* The solution is (X'WX)^(-1)X'WY
*
* @param x - The input matrix, with shape (m, n)
* @param y - The target matrix, with shape (m, 1)
* @param w - The weight matrix, with shape (m, 1) or (m, m)
* @returns - The matrix with the shape (n, 1), representing the solution of
* the linear least squares problem.
* @throws Error - If x and y have different number of samples, y has more
* than one column, or the size of w is neither (m ,1) nor (m, m).
*/
export declare const lstsq: (x: math.Matrix, y: math.Matrix, w: math.Matrix) => math.Matrix;