預測與評估

Python Spark SQL 入門

Mark Plutowski

Data Scientist

將模型套用到評估資料

predicted = df_trained.transform(df_test)
  • 預測欄:double
  • 機率欄:長度為 2 的向量
x = predicted.first
print("Right!" if x.label == int(x.prediction) else "Wrong")
Python Spark SQL 入門

評估分類準確度

model_stats = model.evaluate(df_eval)
type(model_stats)
pyspark.ml.classification.BinaryLogisticRegressionSummary)
print("\nPerformance: %.2f" % model_stats.areaUnderROC)
Python Spark SQL 入門

文字分類範例

  • 正類標籤:

    • ['her','him','he','she','them','us','they','himself','herself','we']
  • 範例數:5746

  • 範例數:2873 正類2873 負類
  • 訓練範例數:4607
  • 測試範例數:1139
  • 訓練迭代次數:21
  • 測試 AUC:0.87
Python Spark SQL 入門

預測結尾詞

  • 正類標籤:'it'

  • 範例數:438

  • 範例數:219 正類219 負類
  • 訓練範例數:340
  • 測試範例數:98
  • 測試 AUC:0.85
Python Spark SQL 入門

一起來練習吧!

Python Spark SQL 入門

Preparing Video For Download...