code: function run(sc) {
      var lines = sc.textFile(directory);
      var points = lines.map(function (line, LabeledPoint, Vectors) {
          var parts = line.split(",");
          var y = parseFloat(parts[0]);
          var tok = parts[1].split(" ");
          var x = [];
          for (var i = 0; i < tok.length; ++i) {
              x[i] = parseFloat(tok[i]);
          }
  
          return new LabeledPoint(y, Vectors.dense(x));
  
      }, [LabeledPoint, Vectors]).cache();
  
  
      // Another way to configure LogisticRegression
      //
      // LogisticRegressionWithSGD lr = new LogisticRegressionWithSGD();
      // lr.optimizer().setNumIterations(iterations)
      //               .setStepSize(stepSize)
      //               .setMiniBatchFraction(1.0);
      // lr.setIntercept(true);
      // var model = lr.train(points.rdd());
  
      var model = LogisticRegressionWithSGD.train(points, iterations, stepSize);
  
      return model.weights();
  
  }
docs: Logistic regression based classification using ML Lib.