code: public static <K> double estimatePenalty(double l1, Map<K, Double> weights) {
          double penalty = 0.0;
          if(l1 > 0.0) {
              double sumAbsWeights = 0.0;
              for(double w : weights.values()) {
                  sumAbsWeights += Math.abs(w);
              }
              penalty = l1*sumAbsWeights;
          }
          return penalty;
      }
docs: Estimates the penalty by adding the L1 regularization.
  
  @param l1
  @param weights
  @param <K>
  @return