code: function logisticLoss(p, weights) {
    const [label, features] = p;
    const grad = [];
    let dotProd = 0;
  
    for (let i = 0; i < features.length; i++)
      dotProd += (features[i] || 0) * (weights[i] || 0);
  
    const tmp = 1 / (1 + Math.exp(-dotProd)) - label;
  
    for (let i = 0; i < features.length; i++)
      grad[i] = (features[i] || 0) * tmp;
  
    return grad;
  }
docs: valid for labels in [-1, 1]