ml/sgd-linear-model.js
function regularizeL1(weights, gradientCount, stepSize) {
  const [gradient, count] = gradientCount;

  for (let i = 0; i < gradient.length; i++) {
    let grad = (gradient[i] || 0) / count;
    weights[i] = weights[i] || 0;
    weights[i] -= stepSize * grad + (weights[i] > 0 ? 1 : -1);
  }
}
function regularizeL1(weights, gradientCount, stepSize) {
  const [gradient, count] = gradientCount;

  for (let i = 0; i < gradient.length; i++) {
    let grad = (gradient[i] || 0) / count;
    weights[i] = weights[i] || 0;
    weights[i] -= stepSize * grad + (weights[i] > 0 ? 1 : -1);
  }
}
function regularizeL1 ( weights , gradientCount , stepSize ) { const [ gradient , count ] = gradientCount ; for ( let i = 0 ; i < gradient . length ; i ++ ) { let grad = ( gradient [ i ] || 0 ) / count ; weights [ i ] = weights [ i ] || 0 ; weights [ i ] -= stepSize * grad + ( weights [ i ] > 0 ? 1 : - 1 ) ; } }
L1, a.k.a Lasso
L1 a . k . a Lasso