July 2018
Intermediate to advanced
474 pages
13h 37m
English
This section walks through the steps to evaluate the TF-IDF NLP model.
predictionDF.crosstab('label', 'prediction').show()
from sklearn import metricsactual = predictionDF.select('label').toPandas()predicted = predictionDF.select('prediction').toPandas()print('accuracy score: {}%'.format(round(metrics.accuracy_score(actual, predicted),3)*100))
from pyspark.ml.evaluation import BinaryClassificationEvaluatorscores = predictionDF.select('label', 'rawPrediction')evaluator = BinaryClassificationEvaluator()print('The ROC score is {}%'.format(round(evaluator.evaluate(scores),3)*100)) ...Read now
Unlock full access