text_plain_output_1.png image_output_1.png
from pyspark.ml.classification import LogisticRegression

import numpy as np

import numpy as np # linear algebra

import pyspark.ml.evaluation as evals

import pyspark.ml.tuning as tune

from pyspark.ml.classification import LogisticRegression
lr = LogisticRegression()

import pyspark.ml.evaluation as evals
evaluator = evals.BinaryClassificationEvaluator(metricName='areaUnderROC')

import pyspark.ml.tuning as tune
grid = tune.ParamGridBuilder()
grid = grid.addGrid(lr.regParam, np.arange(0, 0.1, 0.01))
grid = grid.addGrid(lr.elasticNetParam, [0, 1])
grid = grid.build()

best_lr = lr.fit(training)

test_results = best_lr.transform(test)
print(evaluator.evaluate(test_results))