Spark MLlIb: Train and Evaluate Logistic Regression Model

1) Train Model

 val lr = new LogisticRegression()
      .setMaxIter(100)
      .setRegParam(0.3)
      .setElasticNetParam(0.5)

 //Train Model
 val model = lr.fit(trainingData)

 println(s"Coefficients: ${model.coefficients} Intercept: ${model.intercept}")

 //Make predictions on test data
 val predictions = model.transform(testData)

2) Evaluation

 //Evaluate the precision and recall
 val countProve = predictions.where("label == prediction").count()
 val count = predictions.count()

 println(s"Count of true predictions: $countProve Total Count: $count")

results matching ""

    No results matching ""