Spark2 生存分析Survival regression

智慧先行者發表於2016-12-09

  在spark.ml中,實現了加速失效時間(AFT)模型,這是一個用於檢查資料的引數生存迴歸模型。 它描述了生存時間對數的模型,因此它通常被稱為生存分析的對數線性模型。 不同於為相同目的設計的比例風險模型,AFT模型更容易並行化,因為每個例項獨立地貢獻於目標函式。

  當在具有常量非零列的資料集上匹配AFTSurvivalRegressionModel而沒有截距時,Spark MLlib為常量非零列輸出零係數。 這種行為不同於R survival :: survreg。

匯入包 

import org.apache.spark.sql.SparkSession
import org.apache.spark.sql.Dataset
import org.apache.spark.sql.Row
import org.apache.spark.sql.DataFrame
import org.apache.spark.sql.functions._

import org.apache.spark.ml.linalg.Vectors
import org.apache.spark.ml.feature.VectorAssembler
import org.apache.spark.ml.Pipeline
import org.apache.spark.ml.evaluation.RegressionEvaluator
import org.apache.spark.ml.regression.AFTSurvivalRegression
import org.apache.spark.ml.tuning.{ CrossValidator, ParamGridBuilder }

 

匯入樣本資料

    val spark = SparkSession.builder().appName("Spark Survival regression").config("spark.some.config.option", "some-value").getOrCreate()

    // For implicit conversions like converting RDDs to DataFrames 
    import spark.implicits._
   
     
    val dataList: List[(Double, Double, Double, Double,Double, Double, Double, Double,Double, Double)] = List(
      (16, 1, 1, 0, 0, 1, 24, 82, 14, 0),
      (1, 1, 1, 0, 1, 0, 26, 85, 12, 0),
      (4, 0, 1, 0, 0, 0, 25, 85, 12, 0),
      (3, 1, 1, 0, 1, 1, 21, 85, 9, 0),
      (36, 1, 1, 0, 1, 0, 22, 82, 12, 0),
      (36, 1, 1, 0, 0, 0, 18, 82, 11, 0),
      (16, 1, 1, 1, 1, 0, 20, 81, 9, 0),
      (8, 0, 1, 0, 1, 0, 24, 85, 12, 0),
      (20, 1, 1, 1, 0, 0, 24, 85, 12, 0),
      (44, 1, 1, 0, 0, 0, 24, 82, 14, 0),
      (20, 1, 1, 0, 1, 0, 26, 84, 12, 0),
      (30, 1, 1, 0, 1, 0, 22, 84, 12, 1),
      (24, 1, 1, 0, 0, 0, 19, 83, 12, 0),
      (13, 1, 1, 0, 0, 0, 22, 80, 14, 0),
      (6, 1, 1, 0, 0, 0, 27, 84, 16, 0),
      (2, 1, 1, 0, 0, 0, 22, 81, 12, 1),
      (5, 1, 1, 0, 0, 0, 26, 85, 13, 0),
      (192, 1, 1, 0, 0, 0, 21, 78, 12, 0),
      (4, 1, 1, 0, 0, 0, 20, 83, 12, 0),
      (12, 1, 1, 0, 1, 0, 22, 81, 12, 0),
      (4, 1, 2, 0, 0, 0, 24, 86, 12, 0),
      (16, 0, 2, 1, 1, 1, 21, 84, 12, 1),
      (24, 1, 1, 0, 0, 0, 27, 84, 14, 0),
      (16, 1, 1, 0, 1, 0, 23, 81, 12, 0),
      (3, 1, 1, 0, 0, 0, 26, 84, 14, 0),
      (16, 1, 1, 0, 1, 0, 24, 82, 14, 0),
      (28, 1, 1, 0, 0, 0, 23, 81, 12, 0),
      (1, 1, 1, 0, 1, 0, 19, 81, 12, 0),
      (13, 1, 1, 0, 0, 1, 23, 85, 14, 0),
      (36, 1, 1, 0, 0, 0, 21, 83, 10, 0),
      (32, 1, 1, 0, 1, 0, 20, 82, 12, 1),
      (16, 1, 1, 0, 1, 1, 21, 80, 12, 0),
      (2, 1, 1, 0, 0, 1, 21, 83, 12, 0),
      (8, 1, 1, 0, 0, 1, 24, 83, 14, 1),
      (1, 1, 1, 0, 0, 0, 22, 83, 10, 0),
      (24, 1, 2, 0, 0, 0, 18, 79, 11, 0),
      (64, 1, 1, 0, 1, 0, 20, 84, 12, 0),
      (8, 1, 1, 0, 0, 0, 23, 84, 10, 1),
      (2, 1, 1, 0, 0, 0, 16, 80, 9, 1),
      (12, 1, 1, 0, 0, 0, 22, 80, 13, 0),
      (18, 1, 1, 0, 0, 0, 24, 83, 12, 0),
      (32, 1, 1, 0, 0, 0, 24, 85, 14, 0),
      (2, 1, 1, 0, 0, 0, 19, 78, 12, 0),
      (7, 1, 1, 0, 0, 0, 26, 85, 16, 0),
      (5, 1, 1, 0, 0, 0, 22, 81, 12, 0),
      (44, 1, 1, 0, 0, 0, 22, 82, 16, 0),
      (2, 1, 1, 1, 1, 0, 21, 81, 12, 1),
      (4, 1, 1, 0, 1, 0, 18, 81, 10, 1),
      (2, 0, 1, 0, 0, 0, 21, 86, 12, 1),
      (6, 1, 1, 0, 0, 0, 25, 85, 16, 0),
      (4, 1, 1, 0, 0, 0, 22, 81, 12, 0),
      (36, 1, 1, 0, 0, 0, 24, 83, 12, 0),
      (12, 1, 1, 0, 0, 0, 22, 83, 13, 1),
      (24, 1, 1, 0, 0, 0, 20, 85, 12, 0),
      (42, 1, 1, 0, 0, 0, 25, 82, 16, 0),
      (16, 1, 1, 0, 1, 0, 21, 79, 13, 0),
      (44, 1, 1, 0, 0, 0, 25, 84, 12, 0),
      (44, 1, 1, 0, 0, 0, 26, 84, 16, 0),
      (10, 1, 1, 0, 0, 0, 22, 83, 12, 0),
      (4, 1, 1, 1, 0, 0, 20, 81, 11, 0),
      (12, 1, 1, 0, 1, 0, 26, 84, 12, 0),
      (28, 1, 1, 0, 0, 0, 22, 82, 12, 0),
      (24, 1, 1, 0, 0, 0, 18, 82, 11, 0),
      (6, 1, 1, 0, 1, 0, 19, 78, 11, 0),
      (28, 1, 1, 0, 0, 0, 21, 83, 12, 0),
      (12, 1, 1, 1, 1, 0, 21, 81, 12, 0),
      (34, 1, 1, 0, 0, 0, 24, 82, 12, 0),
      (2, 1, 1, 0, 0, 0, 21, 84, 13, 0),
      (48, 1, 1, 0, 0, 0, 21, 84, 14, 0),
      (16, 1, 1, 0, 0, 0, 20, 80, 12, 0),
      (26, 1, 1, 0, 0, 0, 26, 84, 12, 1),
      (6, 1, 1, 0, 1, 0, 24, 84, 14, 0),
      (2, 1, 3, 0, 0, 0, 22, 85, 12, 1),
      (24, 1, 1, 0, 0, 0, 24, 85, 12, 0),
      (6, 1, 1, 0, 0, 0, 23, 83, 12, 0),
      (16, 1, 1, 0, 1, 0, 28, 85, 16, 0),
      (16, 1, 1, 1, 0, 0, 20, 80, 12, 0),
      (8, 1, 1, 0, 1, 0, 21, 84, 12, 0),
      (28, 1, 1, 0, 0, 0, 23, 85, 14, 0),
      (7, 1, 1, 0, 0, 0, 24, 83, 15, 0),
      (5, 1, 1, 1, 1, 0, 19, 82, 8, 0),
      (18, 1, 1, 0, 1, 0, 22, 80, 12, 0),
      (4, 1, 1, 0, 1, 0, 19, 82, 12, 1),
      (18, 1, 1, 0, 0, 0, 19, 83, 12, 0),
      (6, 1, 2, 0, 0, 0, 19, 83, 12, 0),
      (1, 1, 1, 1, 1, 0, 20, 84, 8, 1),
      (10, 1, 1, 1, 1, 1, 17, 78, 8, 0),
      (1, 1, 1, 0, 1, 0, 23, 81, 13, 0),
      (1, 1, 1, 0, 0, 0, 17, 81, 11, 0),
      (12, 1, 3, 0, 0, 0, 22, 81, 12, 0),
      (12, 1, 3, 0, 0, 0, 23, 85, 14, 0),
      (40, 1, 1, 0, 0, 0, 25, 83, 12, 0),
      (12, 1, 1, 0, 1, 0, 22, 83, 12, 0),
      (14, 1, 1, 0, 1, 0, 17, 79, 11, 0),
      (52, 1, 1, 0, 1, 0, 21, 81, 12, 0),
      (5, 1, 1, 0, 1, 0, 16, 78, 10, 0),
      (3, 1, 1, 0, 1, 0, 19, 83, 12, 0),
      (28, 1, 1, 0, 0, 0, 19, 80, 10, 0),
      (16, 1, 1, 0, 1, 0, 20, 82, 12, 1),
      (8, 1, 1, 0, 0, 0, 25, 86, 16, 0),
      (4, 1, 1, 1, 1, 0, 20, 85, 10, 0),
      (13, 1, 1, 0, 0, 0, 25, 84, 12, 0),
      (20, 1, 1, 0, 1, 0, 18, 78, 10, 0),
      (12, 1, 1, 0, 0, 0, 21, 79, 12, 0),
      (4, 1, 1, 0, 0, 0, 22, 84, 12, 0),
      (52, 1, 1, 0, 1, 0, 20, 80, 12, 1),
      (23, 0, 1, 0, 0, 0, 27, 84, 12, 0),
      (16, 1, 3, 1, 0, 0, 17, 79, 9, 1),
      (4, 0, 1, 0, 1, 0, 23, 85, 13, 0),
      (6, 1, 1, 0, 0, 1, 26, 85, 12, 0),
      (4, 1, 1, 0, 0, 0, 22, 85, 12, 0),
      (1, 1, 1, 0, 0, 0, 25, 84, 13, 0),
      (16, 1, 1, 0, 0, 0, 18, 81, 12, 0),
      (18, 1, 2, 0, 1, 0, 20, 81, 14, 0),
      (3, 1, 1, 0, 0, 0, 23, 85, 12, 0),
      (16, 1, 1, 0, 0, 0, 24, 85, 14, 1),
      (96, 1, 1, 0, 0, 0, 21, 80, 13, 0),
      (24, 1, 3, 0, 0, 0, 19, 83, 9, 0),
      (48, 1, 2, 0, 1, 0, 18, 79, 12, 0),
      (4, 1, 1, 0, 0, 0, 19, 83, 11, 0),
      (2, 1, 3, 0, 0, 0, 18, 82, 12, 1),
      (16, 1, 1, 0, 1, 1, 19, 79, 11, 0),
      (28, 1, 1, 0, 0, 0, 19, 82, 12, 0),
      (1, 1, 1, 0, 0, 0, 23, 85, 12, 0),
      (52, 1, 1, 0, 0, 0, 23, 82, 14, 0),
      (32, 1, 2, 1, 0, 0, 20, 82, 14, 0),
      (20, 1, 3, 0, 0, 0, 20, 82, 12, 0),
      (12, 1, 3, 0, 0, 0, 20, 85, 12, 0),
      (8, 1, 3, 0, 0, 0, 17, 78, 11, 0),
      (36, 1, 1, 0, 0, 0, 24, 81, 16, 0),
      (8, 1, 1, 0, 0, 0, 24, 85, 12, 1),
      (24, 1, 1, 0, 0, 0, 20, 83, 11, 1),
      (36, 1, 1, 0, 0, 0, 24, 83, 16, 0),
      (16, 1, 1, 0, 0, 0, 24, 84, 12, 0),
      (3, 1, 1, 0, 1, 0, 22, 80, 12, 0),
      (32, 1, 1, 0, 0, 0, 22, 80, 15, 0),
      (16, 1, 1, 0, 0, 0, 22, 84, 12, 0),
      (48, 1, 1, 0, 0, 0, 23, 85, 16, 0),
      (1, 1, 1, 0, 0, 0, 21, 80, 12, 0),
      (36, 1, 1, 0, 1, 0, 25, 84, 12, 1),
      (30, 1, 1, 0, 0, 0, 24, 81, 12, 0),
      (2, 1, 1, 0, 0, 0, 19, 78, 12, 0),
      (52, 1, 1, 0, 0, 0, 20, 79, 13, 0),
      (36, 1, 1, 1, 0, 1, 21, 83, 13, 0),
      (28, 1, 1, 0, 0, 0, 23, 82, 12, 1),
      (48, 1, 1, 0, 0, 0, 21, 80, 16, 0),
      (16, 1, 3, 0, 1, 0, 19, 78, 7, 0),
      (4, 1, 1, 0, 0, 0, 25, 83, 12, 0),
      (1, 1, 1, 0, 0, 0, 25, 85, 12, 0),
      (6, 1, 1, 0, 0, 0, 20, 82, 12, 1),
      (12, 1, 1, 0, 0, 0, 20, 78, 12, 0),
      (24, 1, 1, 0, 1, 0, 19, 80, 11, 0),
      (40, 1, 1, 1, 0, 0, 22, 80, 10, 0),
      (8, 1, 1, 1, 0, 0, 26, 85, 19, 0),
      (4, 1, 1, 0, 1, 0, 22, 82, 12, 0),
      (20, 1, 2, 0, 0, 0, 23, 84, 12, 0),
      (6, 1, 2, 0, 0, 0, 19, 83, 12, 0),
      (12, 1, 1, 0, 0, 0, 21, 82, 12, 0),
      (8, 1, 1, 1, 0, 0, 23, 84, 16, 0),
      (3, 0, 1, 0, 0, 0, 28, 85, 16, 0),
      (12, 1, 1, 0, 0, 1, 25, 85, 16, 0),
      (16, 1, 1, 0, 0, 0, 19, 80, 12, 0),
      (20, 1, 1, 0, 1, 0, 19, 78, 8, 0),
      (12, 1, 2, 0, 1, 0, 18, 79, 12, 0),
      (16, 1, 3, 0, 0, 0, 20, 83, 12, 0),
      (17, 1, 1, 0, 1, 0, 25, 83, 11, 0),
      (60, 1, 3, 0, 0, 0, 19, 80, 11, 1),
      (12, 1, 3, 1, 0, 0, 19, 81, 10, 1),
      (4, 1, 1, 1, 0, 0, 17, 79, 10, 1),
      (16, 1, 1, 0, 0, 0, 21, 81, 14, 0),
      (3, 1, 1, 0, 1, 0, 21, 83, 12, 0),
      (3, 1, 1, 0, 1, 0, 25, 85, 12, 0),
      (16, 1, 1, 0, 0, 0, 19, 82, 12, 0),
      (24, 1, 1, 1, 0, 1, 19, 78, 12, 0),
      (21, 1, 1, 0, 1, 0, 19, 78, 12, 0),
      (32, 1, 1, 0, 0, 0, 20, 81, 12, 0),
      (8, 1, 1, 1, 1, 0, 26, 85, 11, 0),
      (6, 1, 1, 0, 0, 0, 23, 84, 12, 0),
      (16, 1, 1, 0, 1, 0, 17, 82, 11, 0),
      (12, 1, 1, 0, 1, 0, 24, 81, 12, 0),
      (16, 1, 1, 1, 0, 0, 18, 82, 12, 0),
      (16, 1, 1, 1, 1, 0, 28, 85, 12, 0),
      (8, 1, 1, 0, 0, 0, 26, 85, 16, 1),
      (20, 1, 1, 0, 1, 0, 21, 85, 12, 0),
      (40, 1, 1, 0, 0, 0, 22, 83, 12, 0),
      (12, 1, 1, 0, 0, 0, 22, 83, 12, 0),
      (36, 1, 1, 0, 0, 0, 25, 84, 16, 0),
      (18, 1, 1, 0, 0, 0, 20, 82, 13, 0),
      (48, 1, 1, 0, 0, 0, 20, 81, 12, 0),
      (7, 1, 1, 1, 1, 0, 18, 81, 10, 1),
      (1, 1, 1, 0, 0, 0, 25, 85, 12, 0),
      (24, 1, 1, 0, 0, 0, 21, 85, 12, 0),
      (12, 1, 3, 1, 0, 0, 17, 80, 9, 0),
      (36, 1, 3, 1, 0, 0, 17, 82, 8, 0),
      (3, 1, 3, 1, 0, 0, 18, 79, 10, 0),
      (1, 1, 3, 0, 0, 0, 23, 81, 6, 0),
      (5, 1, 3, 0, 0, 0, 20, 83, 10, 0),
      (24, 1, 3, 1, 0, 0, 19, 83, 11, 1),
      (21, 1, 1, 1, 0, 1, 19, 81, 12, 1),
      (1, 1, 1, 0, 1, 0, 17, 78, 11, 0),
      (8, 1, 1, 0, 0, 0, 21, 79, 12, 0),
      (24, 1, 2, 0, 0, 0, 24, 84, 16, 0),
      (68, 1, 1, 1, 0, 0, 20, 80, 12, 0),
      (20, 1, 1, 0, 0, 0, 19, 80, 14, 0),
      (2, 1, 1, 0, 1, 0, 16, 80, 9, 0),
      (12, 1, 1, 0, 0, 0, 25, 84, 12, 0),
      (40, 1, 1, 0, 0, 1, 24, 82, 14, 0),
      (4, 1, 1, 0, 0, 0, 26, 84, 12, 0),
      (1, 1, 1, 0, 0, 1, 25, 85, 12, 0),
      (32, 1, 1, 0, 1, 0, 25, 84, 11, 1),
      (1, 1, 3, 0, 0, 0, 19, 80, 10, 0),
      (6, 1, 1, 0, 0, 0, 24, 81, 16, 0),
      (13, 1, 1, 0, 0, 1, 27, 85, 16, 0),
      (2, 1, 1, 1, 1, 0, 22, 85, 12, 0),
      (50, 1, 2, 0, 0, 0, 19, 83, 11, 1),
      (32, 1, 1, 0, 1, 0, 21, 78, 12, 0),
      (12, 1, 1, 0, 1, 0, 16, 79, 9, 0),
      (2, 1, 2, 0, 0, 0, 22, 79, 12, 0),
      (8, 1, 2, 0, 0, 0, 23, 82, 12, 1),
      (20, 1, 2, 0, 0, 0, 21, 83, 15, 0),
      (12, 1, 1, 0, 0, 0, 26, 85, 12, 0),
      (8, 1, 1, 0, 0, 0, 21, 85, 12, 0),
      (1, 1, 1, 0, 0, 0, 24, 83, 13, 0),
      (16, 1, 1, 0, 1, 0, 21, 83, 11, 0),
      (24, 1, 1, 0, 0, 0, 17, 80, 11, 0),
      (4, 1, 1, 0, 0, 0, 24, 85, 13, 0),
      (22, 1, 2, 0, 0, 0, 25, 83, 12, 0),
      (5, 1, 2, 0, 0, 0, 20, 82, 12, 0),
      (36, 1, 2, 1, 0, 0, 23, 84, 12, 0),
      (12, 1, 1, 0, 0, 0, 23, 80, 12, 0),
      (52, 1, 1, 0, 0, 0, 19, 79, 13, 0),
      (9, 1, 1, 0, 0, 0, 25, 85, 16, 0),
      (6, 1, 1, 0, 0, 0, 22, 85, 14, 0),
      (26, 1, 1, 0, 0, 0, 21, 81, 13, 0),
      (8, 1, 1, 0, 0, 0, 26, 84, 16, 0),
      (18, 0, 1, 1, 0, 0, 23, 84, 14, 0),
      (2, 1, 3, 0, 0, 0, 27, 85, 19, 0),
      (20, 1, 1, 0, 0, 0, 23, 82, 16, 0),
      (16, 1, 1, 0, 0, 0, 25, 85, 14, 1),
      (2, 0, 1, 0, 0, 0, 22, 86, 12, 0),
      (48, 1, 1, 0, 0, 1, 20, 80, 12, 1),
      (4, 1, 1, 0, 1, 0, 23, 83, 11, 0),
      (8, 1, 1, 0, 0, 0, 22, 80, 12, 0),
      (40, 1, 1, 0, 1, 0, 19, 81, 12, 1),
      (14, 0, 1, 0, 0, 0, 27, 85, 19, 0),
      (80, 1, 1, 0, 0, 0, 25, 83, 16, 0),
      (13, 0, 1, 0, 0, 0, 24, 85, 16, 0),
      (20, 1, 1, 0, 1, 0, 26, 84, 16, 1),
      (44, 1, 1, 0, 0, 0, 18, 78, 12, 0),
      (12, 1, 1, 0, 0, 0, 20, 84, 13, 0),
      (20, 1, 1, 0, 0, 0, 22, 79, 14, 0),
      (32, 1, 1, 0, 0, 0, 24, 84, 12, 1),
      (2, 1, 1, 0, 0, 0, 23, 83, 12, 0),
      (28, 1, 2, 0, 0, 0, 22, 85, 14, 1),
      (6, 1, 2, 0, 0, 0, 21, 84, 12, 0),
      (6, 1, 1, 0, 1, 0, 26, 83, 12, 0),
      (38, 1, 1, 0, 0, 0, 22, 81, 12, 0),
      (16, 1, 1, 0, 1, 0, 21, 80, 14, 0),
      (1, 1, 1, 0, 0, 0, 26, 85, 12, 0),
      (7, 1, 1, 0, 0, 0, 26, 84, 12, 0),
      (10, 1, 1, 0, 1, 0, 23, 83, 12, 0),
      (3, 1, 1, 0, 0, 0, 23, 82, 16, 0),
      (36, 1, 1, 0, 0, 0, 21, 83, 12, 0),
      (12, 1, 1, 0, 0, 0, 20, 85, 12, 0),
      (8, 1, 2, 1, 0, 0, 19, 81, 11, 1),
      (14, 1, 1, 0, 0, 0, 22, 81, 12, 0),
      (4, 1, 1, 0, 1, 1, 20, 79, 11, 1),
      (1, 1, 1, 0, 1, 0, 22, 83, 12, 0),
      (2, 1, 1, 0, 0, 0, 24, 85, 13, 1),
      (1, 1, 1, 0, 1, 1, 21, 83, 12, 0),
      (4, 1, 1, 0, 0, 0, 24, 85, 12, 0),
      (24, 1, 1, 1, 0, 0, 22, 79, 14, 0),
      (12, 1, 1, 0, 0, 0, 23, 80, 15, 0),
      (12, 1, 1, 0, 1, 0, 21, 79, 12, 0),
      (20, 1, 1, 0, 0, 0, 26, 84, 12, 0),
      (7, 1, 1, 0, 0, 0, 21, 84, 12, 0),
      (12, 1, 1, 0, 1, 0, 17, 80, 10, 0),
      (8, 1, 1, 0, 1, 0, 16, 78, 9, 0),
      (6, 1, 1, 0, 1, 0, 19, 81, 11, 0),
      (16, 1, 1, 0, 0, 1, 23, 84, 15, 0),
      (48, 1, 1, 0, 0, 0, 20, 79, 13, 0),
      (2, 1, 1, 0, 0, 0, 22, 85, 12, 0),
      (1, 1, 1, 0, 0, 0, 22, 84, 12, 0),
      (16, 1, 1, 1, 1, 0, 18, 80, 11, 1),
      (8, 1, 1, 0, 0, 0, 21, 85, 14, 0),
      (24, 1, 1, 0, 0, 0, 23, 83, 15, 0),
      (4, 1, 1, 0, 0, 0, 20, 80, 12, 0),
      (2, 1, 2, 0, 0, 0, 23, 83, 12, 0),
      (5, 0, 1, 0, 0, 0, 27, 85, 16, 0),
      (24, 1, 2, 1, 0, 0, 20, 79, 12, 0),
      (1, 1, 2, 1, 0, 0, 18, 82, 11, 0),
      (12, 1, 1, 0, 0, 0, 21, 78, 13, 0),
      (10, 1, 1, 1, 0, 0, 19, 81, 12, 0),
      (48, 1, 1, 0, 0, 0, 21, 81, 11, 0),
      (24, 1, 1, 0, 0, 0, 21, 84, 13, 0),
      (56, 1, 1, 0, 0, 0, 25, 83, 13, 0),
      (52, 1, 1, 0, 0, 0, 21, 79, 12, 0),
      (6, 1, 1, 0, 1, 0, 19, 79, 10, 0),
      (32, 1, 1, 1, 0, 0, 17, 81, 10, 0),
      (8, 1, 1, 0, 1, 0, 22, 84, 12, 1),
      (6, 1, 1, 0, 0, 0, 17, 81, 10, 0),
      (24, 1, 1, 1, 1, 0, 18, 81, 11, 0),
      (2, 1, 3, 0, 0, 0, 19, 79, 12, 0),
      (20, 1, 3, 0, 0, 0, 23, 84, 12, 0),
      (40, 1, 2, 1, 1, 0, 23, 80, 12, 0),
      (4, 1, 2, 0, 0, 0, 20, 82, 12, 1),
      (3, 0, 1, 0, 1, 0, 24, 86, 11, 1),
      (24, 1, 1, 0, 1, 0, 19, 78, 9, 1),
      (8, 1, 1, 0, 0, 0, 20, 84, 12, 0),
      (24, 1, 1, 0, 0, 0, 21, 82, 12, 0),
      (36, 1, 1, 0, 0, 0, 19, 83, 12, 0),
      (1, 1, 1, 0, 1, 0, 21, 80, 12, 1),
      (8, 1, 1, 0, 0, 0, 19, 78, 12, 0),
      (8, 1, 1, 0, 1, 0, 23, 81, 12, 0),
      (40, 1, 1, 0, 0, 0, 20, 84, 12, 0),
      (5, 1, 1, 0, 0, 0, 16, 79, 9, 1),
      (24, 1, 1, 0, 0, 0, 23, 85, 16, 0),
      (2, 1, 3, 0, 0, 0, 21, 83, 12, 0),
      (6, 0, 1, 0, 0, 0, 26, 85, 12, 0),
      (24, 1, 1, 0, 0, 0, 22, 80, 14, 0),
      (42, 1, 1, 0, 1, 0, 21, 84, 11, 0),
      (12, 1, 1, 0, 0, 0, 16, 79, 10, 0),
      (48, 1, 2, 0, 0, 0, 19, 80, 12, 0),
      (12, 1, 1, 0, 0, 1, 20, 83, 10, 0),
      (7, 1, 3, 0, 0, 0, 23, 81, 12, 1),
      (10, 1, 1, 0, 1, 0, 24, 84, 12, 0),
      (1, 1, 1, 0, 0, 0, 21, 78, 12, 0),
      (2, 1, 1, 0, 0, 0, 23, 85, 12, 1),
      (3, 1, 1, 0, 0, 0, 21, 85, 12, 0),
      (6, 1, 1, 0, 1, 0, 19, 80, 11, 0),
      (40, 1, 1, 0, 1, 0, 20, 79, 12, 0),
      (38, 1, 1, 0, 0, 0, 22, 80, 12, 0),
      (1, 1, 1, 0, 0, 0, 18, 79, 11, 0),
      (2, 1, 1, 0, 1, 0, 19, 81, 10, 1),
      (8, 1, 1, 0, 1, 0, 21, 85, 11, 1),
      (20, 1, 1, 0, 0, 0, 17, 79, 10, 0),
      (2, 1, 1, 0, 0, 0, 20, 83, 11, 0),
      (2, 1, 1, 0, 0, 0, 20, 84, 11, 0),
      (3, 1, 1, 0, 0, 0, 26, 83, 12, 0),
      (13, 0, 1, 1, 0, 0, 27, 85, 13, 1),
      (20, 1, 1, 0, 0, 0, 21, 78, 12, 0),
      (3, 1, 3, 0, 1, 0, 18, 82, 11, 0),
      (10, 1, 1, 0, 0, 0, 23, 84, 13, 0),
      (2, 1, 1, 0, 1, 0, 22, 85, 12, 1),
      (24, 1, 1, 0, 0, 0, 19, 82, 12, 0),
      (2, 1, 1, 1, 0, 0, 23, 83, 12, 1),
      (10, 1, 1, 0, 1, 0, 21, 81, 12, 1),
      (28, 1, 1, 0, 1, 0, 16, 78, 9, 1),
      (7, 1, 1, 0, 0, 1, 21, 80, 12, 0),
      (2, 1, 1, 0, 0, 0, 26, 83, 13, 0),
      (1, 1, 1, 0, 0, 0, 25, 84, 12, 0),
      (40, 1, 1, 0, 0, 0, 21, 84, 12, 0),
      (104, 1, 1, 1, 1, 1, 20, 83, 12, 0),
      (1, 1, 1, 0, 1, 0, 18, 78, 11, 1),
      (16, 1, 1, 0, 0, 0, 18, 79, 10, 0),
      (7, 0, 1, 0, 0, 0, 22, 85, 12, 1),
      (40, 1, 1, 0, 0, 0, 23, 84, 12, 0),
      (8, 1, 1, 1, 0, 0, 20, 79, 12, 0),
      (2, 1, 1, 0, 1, 0, 18, 78, 12, 0),
      (3, 1, 1, 0, 0, 0, 19, 79, 12, 0),
      (1, 1, 1, 0, 0, 0, 26, 83, 12, 0),
      (14, 1, 1, 0, 1, 0, 21, 79, 11, 0),
      (2, 1, 1, 0, 0, 0, 20, 81, 12, 0),
      (15, 1, 1, 0, 0, 0, 24, 83, 12, 1),
      (6, 1, 1, 0, 0, 0, 19, 81, 12, 0),
      (8, 1, 1, 0, 1, 0, 22, 85, 12, 0),
      (1, 1, 1, 0, 0, 0, 21, 81, 13, 0),
      (7, 1, 1, 0, 0, 0, 25, 84, 16, 0),
      (24, 1, 1, 0, 0, 0, 24, 85, 14, 0),
      (3, 1, 1, 0, 1, 0, 21, 82, 12, 0),
      (12, 1, 1, 1, 0, 0, 19, 82, 12, 1),
      (2, 1, 1, 0, 0, 0, 19, 79, 11, 0),
      (10, 1, 1, 0, 1, 0, 23, 86, 12, 0),
      (26, 1, 1, 0, 1, 0, 21, 85, 13, 0),
      (7, 1, 1, 0, 0, 0, 22, 83, 12, 0),
      (1, 1, 1, 1, 1, 0, 20, 81, 8, 0),
      (2, 1, 3, 1, 0, 0, 19, 82, 11, 1),
      (32, 1, 3, 0, 0, 1, 23, 85, 15, 0),
      (20, 1, 1, 0, 0, 0, 25, 82, 16, 0),
      (6, 1, 1, 0, 0, 1, 21, 80, 13, 0),
      (1, 1, 1, 0, 1, 0, 20, 81, 9, 0),
      (4, 1, 1, 0, 0, 0, 25, 84, 14, 0),
      (10, 1, 1, 0, 0, 0, 21, 85, 15, 0),
      (6, 1, 1, 0, 0, 0, 18, 79, 9, 0),
      (24, 1, 1, 0, 0, 0, 21, 84, 13, 1),
      (24, 1, 1, 0, 0, 0, 20, 82, 13, 0),
      (24, 1, 1, 0, 0, 0, 24, 81, 16, 0),
      (6, 1, 1, 0, 0, 0, 19, 81, 12, 0),
      (7, 1, 1, 0, 0, 0, 26, 84, 12, 0),
      (2, 1, 1, 0, 0, 0, 22, 82, 12, 0),
      (32, 1, 1, 0, 0, 0, 21, 78, 14, 0),
      (1, 1, 1, 1, 0, 0, 20, 83, 12, 1),
      (6, 1, 1, 0, 1, 0, 22, 82, 12, 0),
      (2, 1, 1, 0, 1, 0, 21, 79, 12, 0),
      (8, 1, 1, 0, 0, 0, 22, 81, 12, 0),
      (24, 1, 1, 0, 0, 0, 20, 83, 12, 1),
      (12, 1, 1, 0, 0, 0, 25, 85, 12, 1),
      (18, 0, 1, 0, 1, 0, 21, 84, 12, 0),
      (10, 1, 1, 0, 1, 0, 20, 85, 12, 0),
      (12, 1, 1, 0, 1, 0, 22, 85, 10, 0),
      (3, 1, 1, 0, 1, 0, 20, 82, 12, 0),
      (40, 1, 1, 0, 0, 0, 26, 83, 12, 0),
      (72, 1, 1, 1, 0, 0, 23, 80, 15, 0),
      (8, 1, 1, 0, 1, 0, 21, 79, 12, 0),
      (60, 1, 1, 0, 0, 0, 23, 81, 13, 0),
      (48, 1, 1, 1, 1, 0, 19, 83, 8, 1),
      (2, 1, 1, 0, 0, 0, 15, 78, 10, 0),
      (20, 1, 1, 0, 0, 0, 21, 84, 12, 0),
      (60, 1, 1, 0, 0, 0, 19, 78, 12, 0),
      (2, 1, 1, 0, 0, 0, 22, 83, 12, 0),
      (2, 1, 1, 0, 0, 0, 23, 80, 12, 0),
      (44, 1, 1, 1, 1, 0, 25, 82, 10, 1),
      (12, 1, 1, 0, 1, 0, 22, 81, 12, 0),
      (1, 1, 1, 0, 0, 0, 27, 85, 12, 0),
      (6, 1, 1, 0, 0, 0, 26, 84, 16, 0),
      (24, 1, 1, 0, 0, 0, 22, 80, 15, 0),
      (8, 1, 1, 1, 1, 0, 22, 85, 12, 0),
      (10, 1, 1, 0, 0, 0, 22, 85, 12, 1),
      (8, 1, 1, 0, 0, 0, 22, 84, 12, 0),
      (44, 1, 1, 0, 0, 0, 23, 84, 14, 0),
      (8, 1, 1, 1, 1, 0, 21, 85, 12, 0),
      (32, 1, 1, 0, 1, 0, 21, 79, 13, 0),
      (15, 1, 1, 0, 0, 0, 25, 85, 12, 1),
      (5, 1, 1, 0, 1, 0, 24, 84, 12, 0),
      (12, 1, 1, 1, 1, 0, 20, 83, 12, 0),
      (8, 1, 1, 0, 0, 0, 23, 85, 16, 0),
      (40, 1, 1, 0, 1, 1, 24, 83, 13, 1),
      (24, 1, 1, 0, 0, 0, 20, 82, 13, 0),
      (1, 0, 1, 0, 0, 1, 26, 86, 16, 1),
      (6, 1, 1, 1, 0, 0, 21, 85, 14, 0),
      (6, 1, 1, 0, 0, 0, 20, 85, 13, 1),
      (8, 1, 1, 0, 0, 0, 18, 79, 12, 0),
      (16, 1, 1, 0, 0, 0, 24, 82, 15, 0),
      (2, 1, 1, 0, 0, 0, 16, 79, 9, 0),
      (32, 1, 1, 0, 0, 0, 20, 81, 12, 1),
      (1, 1, 1, 0, 1, 0, 24, 85, 12, 0),
      (2, 1, 1, 0, 0, 0, 20, 80, 13, 0),
      (1, 1, 2, 1, 0, 0, 22, 85, 13, 0),
      (6, 1, 1, 0, 1, 0, 17, 80, 9, 0),
      (1, 1, 1, 0, 0, 0, 19, 79, 12, 0),
      (1, 1, 1, 1, 0, 0, 19, 82, 9, 0),
      (8, 1, 1, 0, 1, 0, 23, 84, 12, 0),
      (1, 1, 1, 0, 1, 0, 23, 82, 13, 0),
      (28, 1, 3, 0, 0, 0, 23, 81, 16, 0),
      (1, 1, 1, 0, 1, 0, 24, 82, 12, 0),
      (8, 1, 1, 0, 0, 0, 24, 84, 16, 0),
      (28, 1, 1, 0, 0, 0, 22, 82, 14, 0),
      (12, 1, 2, 0, 0, 0, 16, 80, 9, 0),
      (4, 1, 2, 0, 0, 1, 17, 80, 10, 1),
      (6, 1, 2, 0, 0, 0, 17, 82, 11, 0),
      (52, 1, 1, 0, 0, 0, 20, 80, 13, 0),
      (7, 0, 1, 0, 1, 0, 27, 85, 14, 0),
      (52, 1, 1, 0, 1, 0, 24, 82, 12, 0),
      (28, 1, 1, 0, 1, 0, 17, 81, 10, 1),
      (2, 1, 1, 0, 0, 0, 19, 81, 12, 1),
      (4, 1, 1, 0, 0, 0, 19, 82, 11, 0),
      (52, 1, 1, 0, 0, 0, 26, 84, 14, 0),
      (3, 1, 1, 0, 0, 0, 21, 81, 12, 0),
      (10, 1, 1, 0, 1, 1, 22, 82, 12, 0),
      (4, 1, 1, 1, 1, 1, 21, 81, 12, 1),
      (16, 1, 1, 0, 1, 0, 16, 80, 10, 0),
      (20, 1, 3, 0, 0, 0, 18, 78, 11, 0),
      (9, 0, 3, 0, 0, 0, 27, 85, 13, 0),
      (12, 1, 3, 0, 0, 0, 18, 79, 10, 0),
      (6, 0, 1, 0, 0, 0, 21, 85, 12, 0),
      (2, 1, 3, 0, 0, 0, 22, 84, 12, 0),
      (8, 1, 1, 1, 1, 1, 20, 80, 12, 1),
      (48, 1, 3, 0, 0, 0, 22, 82, 13, 0),
      (12, 1, 3, 0, 0, 0, 23, 82, 12, 0),
      (1, 1, 3, 0, 0, 0, 24, 82, 12, 0),
      (8, 1, 3, 1, 0, 0, 25, 85, 15, 1),
      (8, 1, 3, 0, 0, 0, 26, 83, 14, 0),
      (4, 1, 3, 0, 1, 0, 21, 80, 13, 0),
      (48, 1, 3, 1, 0, 0, 19, 82, 12, 0),
      (3, 1, 3, 0, 1, 0, 20, 80, 12, 0),
      (32, 1, 3, 0, 1, 0, 18, 79, 11, 1),
      (28, 1, 3, 0, 0, 0, 19, 81, 12, 0),
      (24, 1, 3, 0, 0, 0, 20, 84, 8, 0),
      (8, 1, 3, 0, 0, 0, 21, 83, 12, 0),
      (40, 1, 2, 0, 0, 0, 20, 81, 12, 0),
      (4, 1, 2, 1, 0, 0, 19, 83, 12, 1),
      (48, 1, 2, 0, 0, 0, 20, 84, 12, 0),
      (15, 1, 2, 1, 0, 0, 17, 81, 10, 1),
      (48, 1, 2, 0, 0, 0, 17, 80, 10, 0),
      (1, 1, 1, 1, 0, 0, 20, 81, 12, 0),
      (6, 1, 2, 1, 0, 0, 18, 82, 11, 0),
      (8, 1, 2, 0, 0, 0, 21, 81, 13, 0),
      (24, 1, 2, 0, 0, 0, 21, 78, 12, 0),
      (56, 1, 2, 0, 0, 0, 23, 84, 12, 1),
      (6, 0, 2, 0, 0, 0, 26, 85, 14, 0),
      (1, 1, 2, 0, 0, 0, 20, 84, 13, 0),
      (24, 1, 2, 0, 1, 0, 19, 78, 12, 0),
      (4, 1, 2, 0, 0, 0, 24, 82, 12, 0),
      (1, 1, 2, 0, 0, 0, 24, 82, 14, 0),
      (4, 0, 2, 0, 0, 0, 26, 85, 13, 0),
      (16, 1, 2, 1, 0, 0, 19, 81, 12, 1),
      (4, 1, 2, 0, 0, 0, 25, 86, 14, 1),
      (24, 1, 2, 0, 0, 0, 20, 84, 13, 0),
      (3, 1, 2, 1, 0, 0, 19, 82, 11, 0),
      (2, 1, 2, 0, 0, 0, 22, 84, 15, 0),
      (28, 1, 2, 0, 0, 0, 20, 81, 13, 1),
      (10, 1, 1, 0, 0, 0, 25, 83, 16, 0),
      (24, 1, 1, 0, 0, 0, 18, 80, 11, 0),
      (16, 1, 1, 0, 1, 1, 22, 81, 16, 0),
      (36, 1, 1, 0, 0, 0, 24, 81, 17, 0),
      (5, 1, 1, 0, 0, 0, 27, 84, 16, 0),
      (6, 1, 1, 0, 0, 0, 26, 84, 17, 0),
      (48, 1, 1, 0, 0, 0, 25, 83, 15, 0),
      (48, 1, 1, 0, 1, 0, 21, 83, 12, 0),
      (12, 1, 1, 0, 1, 0, 19, 79, 12, 0),
      (4, 1, 3, 1, 0, 0, 18, 79, 11, 1),
      (18, 1, 2, 0, 0, 0, 20, 80, 13, 0),
      (1, 1, 2, 1, 1, 1, 18, 83, 12, 0),
      (50, 1, 3, 1, 0, 0, 19, 82, 12, 1),
      (20, 1, 1, 0, 0, 0, 23, 83, 8, 0),
      (12, 1, 1, 0, 0, 0, 19, 83, 11, 1),
      (12, 1, 2, 1, 0, 0, 23, 81, 12, 0),
      (96, 1, 3, 1, 0, 0, 19, 79, 8, 0),
      (12, 1, 3, 0, 0, 0, 23, 82, 13, 0),
      (12, 1, 3, 0, 0, 0, 24, 82, 16, 0),
      (2, 1, 1, 1, 1, 1, 22, 83, 10, 0),
      (1, 1, 1, 0, 1, 0, 23, 81, 12, 0),
      (1, 1, 2, 0, 1, 0, 21, 85, 12, 0),
      (28, 1, 2, 0, 0, 0, 20, 79, 12, 1),
      (4, 1, 1, 0, 1, 1, 23, 83, 12, 0),
      (22, 1, 1, 1, 1, 0, 20, 81, 13, 0),
      (2, 1, 1, 0, 0, 0, 17, 78, 10, 0),
      (4, 1, 1, 0, 0, 0, 18, 80, 11, 0),
      (1, 1, 1, 1, 1, 0, 21, 84, 12, 1),
      (6, 0, 2, 0, 0, 0, 28, 85, 18, 0),
      (1, 1, 2, 0, 0, 0, 21, 81, 14, 1),
      (8, 1, 2, 0, 1, 0, 20, 83, 12, 1),
      (48, 1, 2, 1, 0, 0, 21, 81, 11, 0),
      (24, 1, 2, 1, 0, 0, 26, 84, 15, 0),
      (8, 1, 2, 0, 0, 0, 22, 83, 12, 0),
      (4, 1, 2, 1, 1, 0, 17, 78, 10, 0),
      (20, 1, 2, 1, 1, 1, 18, 80, 11, 0),
      (4, 1, 1, 1, 0, 0, 20, 80, 10, 0),
      (11, 1, 1, 0, 0, 0, 26, 85, 16, 0),
      (15, 1, 1, 1, 1, 0, 19, 78, 10, 1),
      (16, 1, 1, 0, 0, 0, 23, 82, 14, 0),
      (1, 1, 1, 0, 0, 0, 20, 79, 7, 1),
      (24, 1, 2, 0, 0, 0, 25, 82, 12, 1),
      (15, 1, 2, 0, 0, 0, 20, 83, 13, 0),
      (6, 1, 2, 0, 0, 0, 22, 81, 13, 0),
      (1, 1, 1, 0, 1, 0, 19, 82, 12, 0),
      (32, 1, 1, 0, 1, 0, 24, 83, 12, 0),
      (2, 1, 3, 0, 0, 0, 26, 85, 15, 0),
      (3, 1, 2, 0, 0, 0, 19, 81, 12, 0),
      (16, 1, 1, 0, 0, 0, 20, 83, 12, 0),
      (6, 1, 2, 0, 0, 0, 19, 81, 12, 0),
      (3, 1, 1, 0, 0, 0, 21, 79, 13, 0),
      (42, 1, 1, 0, 0, 0, 23, 80, 15, 0),
      (3, 1, 1, 0, 1, 0, 20, 83, 12, 0),
      (32, 1, 1, 0, 0, 0, 25, 84, 16, 1),
      (8, 1, 1, 1, 1, 0, 15, 79, 7, 1),
      (4, 1, 2, 0, 0, 0, 23, 84, 13, 1),
      (3, 1, 2, 1, 1, 0, 18, 83, 10, 0),
      (7, 0, 1, 0, 0, 0, 26, 85, 16, 0),
      (4, 1, 1, 0, 1, 0, 25, 83, 17, 0),
      (6, 1, 1, 0, 1, 0, 26, 85, 16, 0),
      (20, 1, 1, 0, 0, 0, 27, 85, 17, 0),
      (18, 1, 3, 0, 1, 0, 21, 82, 12, 0),
      (3, 1, 1, 0, 1, 0, 25, 83, 14, 0),
      (16, 1, 2, 0, 0, 0, 24, 83, 16, 0),
      (26, 1, 1, 0, 0, 0, 25, 84, 16, 0),
      (1, 0, 1, 0, 0, 0, 28, 86, 16, 0),
      (20, 1, 1, 0, 0, 0, 27, 85, 18, 0),
      (12, 1, 1, 0, 1, 0, 15, 79, 8, 1),
      (16, 1, 3, 1, 0, 0, 23, 83, 6, 0),
      (32, 1, 1, 0, 0, 0, 22, 81, 12, 0),
      (60, 1, 1, 0, 0, 0, 21, 79, 12, 0),
      (24, 1, 1, 0, 0, 0, 24, 84, 16, 0),
      (7, 1, 1, 1, 1, 0, 17, 80, 9, 1),
      (1, 1, 2, 0, 0, 0, 23, 86, 13, 1),
      (16, 1, 1, 1, 0, 0, 17, 78, 10, 0),
      (48, 1, 1, 0, 0, 0, 20, 79, 12, 1),
      (12, 1, 1, 0, 0, 0, 20, 79, 13, 0),
      (4, 1, 3, 1, 0, 0, 25, 85, 13, 1),
      (8, 1, 3, 1, 0, 0, 18, 82, 10, 0),
      (4, 1, 3, 1, 0, 0, 18, 82, 11, 1),
      (4, 1, 3, 0, 0, 0, 18, 80, 12, 0),
      (18, 1, 3, 0, 1, 1, 20, 83, 10, 0),
      (48, 1, 3, 0, 0, 0, 24, 82, 12, 0),
      (24, 1, 2, 1, 0, 0, 21, 79, 14, 0),
      (8, 1, 3, 0, 0, 0, 22, 82, 12, 0),
      (52, 1, 3, 0, 0, 0, 19, 82, 12, 0),
      (1, 1, 1, 0, 1, 0, 19, 83, 10, 0),
      (12, 1, 2, 0, 0, 1, 23, 81, 16, 0),
      (4, 1, 3, 0, 0, 0, 20, 79, 14, 1),
      (12, 1, 3, 0, 0, 0, 19, 81, 12, 0),
      (8, 1, 3, 0, 0, 0, 17, 81, 10, 1),
      (2, 1, 1, 0, 0, 0, 21, 83, 14, 0),
      (96, 1, 1, 1, 1, 0, 18, 78, 10, 1),
      (8, 1, 3, 0, 0, 0, 19, 84, 12, 0),
      (8, 1, 2, 0, 0, 1, 22, 83, 13, 0),
      (40, 1, 1, 1, 0, 0, 22, 79, 12, 0),
      (10, 1, 3, 0, 0, 0, 21, 82, 12, 0),
      (12, 1, 3, 0, 0, 0, 19, 78, 12, 0),
      (12, 1, 3, 0, 0, 0, 22, 83, 14, 0),
      (9, 1, 3, 1, 0, 0, 27, 84, 18, 1),
      (6, 1, 2, 0, 0, 0, 22, 82, 13, 0),
      (16, 1, 1, 0, 1, 0, 28, 85, 12, 0),
      (1, 1, 3, 0, 0, 0, 25, 83, 11, 0),
      (6, 1, 3, 1, 0, 0, 21, 84, 12, 0),
      (4, 1, 3, 0, 0, 0, 18, 81, 10, 1),
      (2, 1, 3, 0, 0, 0, 19, 79, 11, 0),
      (4, 1, 3, 0, 0, 0, 20, 80, 11, 0),
      (8, 1, 1, 0, 1, 0, 27, 85, 11, 1),
      (6, 1, 1, 0, 0, 0, 25, 82, 16, 0),
      (40, 1, 1, 0, 0, 0, 23, 81, 11, 0),
      (24, 1, 3, 0, 0, 0, 22, 81, 16, 0),
      (1, 1, 3, 0, 0, 0, 24, 82, 13, 0),
      (5, 1, 3, 0, 0, 0, 20, 79, 12, 0),
      (2, 1, 3, 0, 0, 0, 22, 79, 13, 0),
      (8, 1, 3, 0, 1, 0, 24, 81, 12, 0),
      (4, 1, 3, 0, 0, 0, 21, 85, 13, 0),
      (12, 1, 3, 0, 0, 0, 22, 79, 3, 0),
      (12, 1, 3, 1, 0, 0, 18, 79, 6, 0),
      (3, 1, 3, 1, 1, 0, 16, 78, 7, 0),
      (48, 1, 1, 0, 0, 0, 23, 82, 14, 0),
      (8, 1, 3, 1, 0, 0, 16, 79, 8, 0),
      (14, 1, 1, 0, 1, 0, 23, 83, 11, 1),
      (9, 1, 3, 1, 0, 0, 21, 85, 12, 0),
      (4, 1, 1, 0, 1, 0, 24, 83, 12, 0),
      (14, 1, 3, 0, 0, 0, 26, 85, 14, 0),
      (3, 1, 3, 0, 0, 0, 19, 83, 10, 1),
      (3, 1, 3, 0, 0, 0, 20, 78, 11, 0),
      (6, 1, 3, 0, 0, 0, 23, 85, 12, 0),
      (12, 1, 1, 0, 0, 1, 22, 83, 12, 0),
      (8, 0, 1, 0, 1, 0, 25, 85, 12, 0),
      (3, 1, 3, 0, 0, 0, 24, 81, 12, 1),
      (3, 1, 3, 0, 0, 0, 19, 83, 12, 0),
      (10, 1, 3, 0, 0, 0, 22, 80, 12, 0),
      (3, 1, 3, 1, 1, 0, 19, 81, 11, 1),
      (44, 1, 3, 0, 0, 0, 25, 83, 16, 0),
      (2, 1, 1, 0, 0, 0, 22, 84, 13, 0),
      (1, 1, 1, 1, 0, 0, 16, 80, 8, 0),
      (1, 1, 2, 1, 0, 0, 23, 83, 12, 0),
      (12, 1, 2, 0, 0, 0, 23, 82, 14, 0),
      (4, 1, 2, 1, 0, 0, 19, 82, 12, 0),
      (16, 1, 2, 0, 1, 0, 18, 79, 11, 0),
      (5, 0, 1, 0, 0, 0, 22, 85, 12, 0),
      (24, 1, 1, 0, 0, 0, 20, 81, 9, 0),
      (6, 0, 1, 0, 0, 0, 28, 85, 14, 0),
      (52, 1, 1, 1, 0, 0, 20, 78, 12, 0),
      (2, 1, 3, 1, 0, 0, 15, 80, 8, 1),
      (2, 1, 1, 0, 1, 1, 25, 84, 13, 0),
      (10, 1, 1, 0, 0, 0, 24, 84, 12, 0),
      (48, 1, 1, 0, 0, 0, 23, 81, 12, 1),
      (52, 1, 1, 0, 0, 0, 20, 81, 12, 0),
      (2, 1, 1, 0, 0, 0, 25, 85, 14, 1),
      (24, 1, 1, 0, 1, 0, 19, 80, 9, 1),
      (12, 1, 1, 1, 1, 0, 21, 82, 10, 0),
      (8, 1, 2, 0, 0, 0, 16, 78, 11, 0),
      (4, 1, 1, 1, 0, 1, 24, 84, 12, 0),
      (4, 1, 1, 0, 0, 0, 19, 78, 12, 1),
      (4, 1, 1, 1, 0, 0, 16, 78, 9, 0),
      (8, 1, 1, 0, 0, 0, 20, 80, 12, 0),
      (48, 1, 2, 0, 0, 1, 24, 81, 14, 1),
      (24, 1, 1, 0, 0, 1, 27, 84, 18, 1),
      (3, 1, 1, 0, 1, 0, 26, 84, 16, 1),
      (20, 1, 1, 0, 1, 0, 25, 84, 15, 0),
      (52, 1, 1, 0, 1, 0, 25, 82, 16, 0),
      (60, 1, 1, 0, 1, 0, 24, 84, 14, 0),
      (2, 1, 1, 0, 0, 0, 21, 79, 13, 0),
      (2, 1, 3, 0, 0, 0, 22, 84, 14, 0),
      (5, 1, 3, 1, 0, 0, 20, 81, 12, 0),
      (12, 1, 3, 1, 0, 0, 17, 80, 8, 0),
      (24, 1, 3, 0, 0, 0, 27, 84, 10, 0),
      (12, 1, 3, 0, 0, 0, 19, 81, 12, 0),
      (4, 1, 3, 0, 0, 0, 23, 85, 13, 0),
      (2, 1, 3, 0, 0, 0, 16, 79, 10, 0),
      (6, 1, 3, 0, 0, 0, 24, 85, 13, 0),
      (1, 1, 1, 0, 0, 0, 22, 81, 15, 0),
      (4, 1, 3, 0, 0, 0, 17, 80, 10, 0),
      (2, 1, 1, 0, 1, 1, 19, 82, 8, 0),
      (48, 1, 2, 0, 0, 0, 21, 83, 12, 1),
      (8, 1, 2, 1, 0, 0, 20, 79, 9, 1),
      (24, 1, 1, 0, 0, 0, 20, 81, 12, 0),
      (12, 1, 2, 0, 0, 0, 26, 85, 14, 0),
      (2, 1, 1, 1, 1, 0, 22, 82, 12, 1),
      (3, 1, 1, 0, 1, 0, 21, 84, 9, 0),
      (96, 1, 1, 1, 0, 0, 19, 80, 8, 0),
      (3, 1, 1, 1, 0, 0, 19, 83, 10, 0),
      (16, 1, 2, 0, 1, 0, 23, 82, 16, 0),
      (6, 1, 1, 0, 1, 1, 21, 84, 12, 0),
      (4, 1, 1, 1, 0, 0, 19, 79, 10, 0),
      (56, 1, 2, 1, 0, 0, 17, 80, 11, 0),
      (4, 1, 2, 0, 0, 0, 20, 84, 12, 0),
      (6, 1, 1, 1, 0, 0, 19, 81, 10, 1),
      (2, 1, 2, 1, 0, 0, 21, 81, 14, 0),
      (8, 1, 1, 0, 0, 0, 21, 84, 14, 0),
      (14, 1, 2, 0, 0, 0, 22, 82, 13, 0),
      (8, 1, 3, 0, 0, 0, 19, 83, 10, 0),
      (1, 1, 3, 0, 0, 0, 24, 85, 9, 0),
      (2, 1, 3, 0, 0, 0, 19, 83, 11, 1),
      (16, 0, 1, 0, 0, 1, 27, 84, 16, 1),
      (8, 1, 1, 0, 0, 0, 26, 84, 16, 0),
      (48, 1, 1, 1, 1, 1, 18, 80, 8, 0),
      (52, 1, 1, 1, 1, 0, 17, 81, 7, 0),
      (25, 1, 1, 1, 1, 0, 21, 82, 11, 0),
      (20, 1, 1, 1, 1, 0, 22, 83, 12, 0),
      (12, 1, 1, 1, 1, 0, 19, 81, 11, 1),
      (8, 1, 3, 0, 0, 0, 23, 83, 14, 0),
      (5, 1, 3, 1, 1, 1, 20, 81, 10, 1),
      (4, 1, 1, 0, 1, 1, 25, 84, 16, 0),
      (16, 1, 1, 0, 0, 0, 25, 84, 16, 0),
      (1, 1, 1, 0, 0, 0, 22, 81, 15, 0),
      (5, 1, 1, 0, 1, 0, 26, 85, 16, 0),
      (3, 1, 1, 1, 1, 0, 19, 83, 11, 0),
      (46, 1, 1, 1, 1, 0, 20, 78, 12, 0),
      (8, 1, 3, 1, 0, 0, 18, 78, 12, 0),
      (40, 1, 1, 0, 0, 0, 18, 80, 10, 0),
      (1, 1, 3, 1, 1, 1, 22, 82, 12, 0),
      (4, 1, 2, 0, 0, 1, 24, 86, 13, 0),
      (3, 1, 1, 0, 1, 0, 22, 81, 12, 0),
      (2, 1, 3, 0, 0, 1, 25, 84, 12, 0),
      (2, 1, 1, 0, 0, 0, 27, 85, 15, 0),
      (3, 1, 1, 0, 0, 0, 22, 80, 16, 0),
      (46, 1, 1, 0, 0, 0, 25, 83, 14, 0),
      (2, 1, 3, 0, 0, 0, 19, 81, 12, 1),
      (36, 1, 1, 0, 0, 0, 21, 82, 12, 0),
      (6, 0, 3, 0, 0, 0, 22, 85, 12, 0),
      (8, 1, 1, 0, 0, 0, 18, 81, 11, 0),
      (16, 1, 1, 0, 0, 0, 19, 79, 12, 0),
      (16, 1, 1, 1, 1, 0, 19, 78, 9, 0),
      (12, 1, 3, 1, 0, 0, 23, 80, 9, 1),
      (6, 1, 2, 1, 0, 0, 20, 83, 13, 0),
      (5, 0, 3, 0, 0, 0, 21, 85, 14, 0),
      (16, 1, 3, 1, 1, 0, 19, 84, 11, 0),
      (12, 1, 3, 0, 0, 0, 19, 81, 12, 0),
      (1, 1, 3, 0, 0, 0, 26, 85, 11, 0),
      (4, 1, 1, 1, 1, 0, 21, 78, 12, 0),
      (24, 1, 1, 1, 0, 0, 19, 78, 11, 0),
      (1, 1, 1, 0, 0, 0, 22, 80, 12, 0),
      (10, 1, 3, 0, 1, 1, 22, 81, 13, 0),
      (10, 1, 1, 0, 0, 0, 25, 85, 13, 0),
      (2, 1, 3, 1, 0, 0, 20, 84, 12, 1),
      (2, 1, 3, 0, 1, 1, 24, 84, 12, 0),
      (64, 1, 3, 1, 0, 0, 21, 80, 11, 0),
      (8, 1, 2, 1, 0, 0, 21, 84, 12, 0),
      (48, 1, 2, 1, 1, 0, 21, 81, 12, 0),
      (28, 1, 3, 0, 0, 0, 21, 80, 11, 1),
      (24, 1, 3, 0, 0, 0, 18, 79, 10, 0),
      (18, 1, 2, 1, 0, 0, 23, 82, 11, 0),
      (6, 1, 3, 0, 0, 0, 21, 85, 12, 0),
      (3, 1, 2, 1, 1, 0, 19, 82, 11, 1),
      (56, 1, 3, 0, 0, 0, 26, 84, 15, 1),
      (18, 1, 1, 0, 0, 0, 24, 83, 13, 0),
      (2, 1, 3, 0, 0, 0, 21, 81, 9, 0),
      (6, 1, 3, 0, 0, 0, 20, 79, 6, 1),
      (12, 1, 3, 0, 0, 0, 24, 82, 14, 0),
      (32, 1, 1, 0, 1, 0, 19, 82, 9, 0),
      (3, 1, 3, 0, 0, 0, 21, 83, 12, 1),
      (72, 1, 1, 0, 0, 0, 19, 83, 11, 0),
      (5, 1, 1, 1, 1, 0, 19, 84, 7, 0),
      (12, 1, 2, 0, 0, 0, 20, 80, 13, 1),
      (8, 1, 3, 0, 0, 0, 23, 82, 12, 0),
      (8, 1, 1, 0, 1, 0, 23, 81, 13, 0),
      (16, 1, 1, 0, 1, 0, 21, 78, 14, 0),
      (2, 0, 1, 0, 0, 0, 26, 85, 13, 0),
      (3, 0, 1, 0, 0, 0, 27, 85, 16, 0),
      (12, 1, 2, 1, 0, 0, 17, 79, 10, 0),
      (40, 1, 2, 1, 0, 0, 18, 81, 12, 0),
      (96, 1, 1, 0, 0, 0, 25, 83, 14, 0),
      (4, 1, 1, 0, 1, 1, 22, 81, 12, 0),
      (3, 1, 1, 0, 1, 0, 20, 84, 12, 1),
      (12, 1, 1, 0, 0, 0, 25, 83, 16, 0),
      (28, 1, 1, 0, 1, 0, 25, 83, 16, 0),
      (7, 1, 1, 1, 1, 1, 22, 84, 11, 0),
      (1, 1, 2, 1, 0, 0, 22, 85, 15, 0),
      (1, 1, 1, 0, 1, 0, 23, 83, 14, 0),
      (4, 1, 3, 0, 0, 0, 26, 83, 9, 0),
      (3, 1, 3, 0, 0, 0, 25, 84, 14, 1),
      (12, 1, 3, 1, 0, 0, 24, 84, 12, 0),
      (1, 1, 2, 0, 0, 0, 19, 83, 12, 0),
      (14, 1, 1, 0, 0, 1, 26, 84, 15, 0),
      (12, 1, 1, 0, 0, 0, 20, 79, 12, 0),
      (8, 1, 2, 1, 0, 0, 19, 81, 12, 0),
      (12, 1, 3, 0, 0, 0, 25, 82, 12, 0),
      (1, 1, 3, 0, 0, 0, 22, 85, 11, 0),
      (8, 1, 1, 1, 0, 0, 17, 81, 10, 0),
      (8, 1, 1, 1, 1, 0, 24, 85, 9, 1),
      (8, 1, 1, 1, 1, 0, 15, 80, 9, 0),
      (7, 1, 3, 0, 1, 0, 23, 84, 13, 0),
      (12, 1, 3, 0, 0, 0, 21, 82, 12, 0),
      (6, 1, 3, 0, 0, 0, 24, 84, 12, 0),
      (2, 1, 2, 0, 0, 0, 23, 85, 14, 0),
      (16, 1, 3, 1, 0, 0, 20, 81, 11, 1),
      (24, 1, 1, 0, 0, 0, 18, 80, 9, 1),
      (24, 1, 3, 0, 0, 0, 20, 79, 10, 0),
      (12, 1, 3, 0, 1, 1, 24, 83, 9, 0),
      (72, 1, 1, 1, 0, 0, 16, 81, 9, 1),
      (6, 1, 1, 0, 1, 0, 23, 83, 12, 0),
      (1, 1, 2, 0, 0, 0, 25, 82, 13, 0),
      (48, 1, 1, 0, 0, 0, 20, 80, 12, 0),
      (3, 1, 1, 0, 1, 0, 22, 83, 12, 0),
      (24, 1, 1, 0, 0, 0, 23, 81, 12, 0),
      (12, 1, 1, 0, 0, 0, 23, 82, 12, 0),
      (26, 1, 1, 0, 0, 0, 22, 80, 12, 0),
      (3, 1, 1, 0, 1, 0, 23, 83, 12, 0),
      (24, 1, 1, 0, 0, 0, 20, 80, 12, 0),
      (1, 1, 1, 0, 0, 1, 20, 78, 12, 0),
      (5, 1, 1, 0, 1, 0, 24, 83, 12, 0),
      (2, 1, 1, 0, 1, 0, 21, 79, 12, 0),
      (12, 1, 1, 0, 0, 0, 19, 80, 12, 0),
      (48, 1, 1, 0, 0, 0, 23, 81, 12, 0),
      (3, 1, 2, 0, 1, 1, 23, 81, 13, 0),
      (4, 1, 1, 0, 1, 0, 22, 81, 12, 0),
      (6, 1, 1, 0, 1, 0, 22, 81, 12, 0),
      (4, 1, 1, 0, 1, 1, 24, 82, 13, 0),
      (52, 1, 1, 1, 0, 0, 22, 81, 12, 0),
      (8, 1, 2, 1, 0, 0, 23, 81, 12, 0),
      (20, 1, 1, 1, 0, 0, 21, 81, 12, 0),
      (20, 1, 1, 0, 0, 0, 23, 82, 12, 0),
      (28, 1, 1, 0, 0, 0, 22, 83, 12, 0),
      (4, 1, 1, 0, 0, 0, 24, 82, 12, 1),
      (16, 1, 1, 1, 0, 0, 19, 78, 12, 0),
      (8, 1, 2, 0, 0, 0, 19, 79, 12, 0),
      (5, 1, 1, 0, 0, 0, 21, 80, 12, 0),
      (11, 1, 1, 0, 1, 0, 24, 83, 12, 0),
      (4, 1, 2, 0, 0, 0, 24, 83, 12, 0),
      (3, 1, 1, 0, 0, 0, 22, 81, 12, 0),
      (2, 1, 1, 0, 0, 0, 23, 81, 12, 0),
      (2, 1, 1, 0, 0, 0, 21, 80, 12, 0),
      (6, 1, 1, 0, 0, 0, 21, 80, 13, 0),
      (8, 1, 1, 1, 1, 0, 21, 79, 12, 0),
      (1, 1, 1, 0, 1, 1, 18, 79, 12, 1),
      (48, 1, 1, 0, 1, 0, 19, 79, 12, 0),
      (32, 1, 1, 0, 0, 0, 20, 79, 13, 0),
      (32, 1, 1, 0, 0, 1, 20, 79, 12, 0),
      (6, 1, 1, 0, 1, 0, 22, 81, 12, 0),
      (6, 1, 1, 0, 0, 0, 25, 82, 12, 0),
      (24, 1, 1, 0, 0, 1, 20, 79, 12, 0),
      (4, 1, 3, 0, 0, 0, 20, 79, 14, 0),
      (16, 1, 1, 0, 0, 0, 22, 82, 12, 0),
      (12, 1, 1, 0, 0, 0, 21, 80, 12, 0),
      (2, 1, 1, 0, 1, 0, 24, 83, 12, 0),
      (1, 1, 1, 0, 0, 0, 21, 81, 12, 0),
      (3, 1, 1, 0, 1, 0, 22, 82, 12, 0),
      (7, 1, 1, 1, 1, 1, 25, 83, 12, 0),
      (56, 1, 1, 0, 0, 0, 24, 81, 12, 0),
      (1, 1, 1, 0, 0, 0, 22, 80, 12, 0),
      (24, 1, 1, 0, 0, 0, 21, 81, 12, 0),
      (16, 1, 1, 0, 1, 0, 19, 78, 12, 0),
      (20, 1, 1, 0, 1, 0, 22, 82, 12, 0),
      (1, 1, 1, 0, 0, 0, 22, 81, 13, 0),
      (120, 1, 3, 0, 0, 0, 22, 80, 12, 0),
      (44, 1, 1, 0, 0, 0, 22, 81, 14, 0),
      (3, 1, 1, 0, 0, 0, 25, 83, 12, 0),
      (32, 1, 1, 0, 0, 0, 20, 80, 12, 0),
      (6, 1, 1, 0, 0, 0, 22, 82, 12, 0),
      (52, 1, 1, 0, 0, 0, 22, 79, 12, 0),
      (24, 1, 2, 0, 0, 1, 23, 81, 12, 0),
      (72, 1, 1, 0, 0, 0, 21, 81, 12, 0),
      (24, 1, 2, 0, 0, 0, 21, 81, 12, 0),
      (3, 1, 1, 0, 1, 0, 22, 82, 10, 0),
      (6, 1, 1, 0, 1, 0, 21, 79, 12, 0),
      (24, 1, 1, 0, 1, 0, 24, 82, 12, 0),
      (16, 1, 2, 0, 0, 0, 23, 83, 12, 0),
      (5, 1, 1, 0, 1, 0, 25, 83, 12, 0),
      (48, 1, 1, 0, 0, 0, 20, 79, 12, 0),
      (10, 1, 1, 0, 1, 0, 23, 82, 12, 0),
      (48, 1, 1, 0, 0, 0, 23, 82, 13, 0),
      (2, 1, 1, 1, 1, 0, 24, 82, 12, 0),
      (6, 1, 1, 0, 0, 0, 24, 82, 14, 0),
      (36, 1, 2, 0, 0, 0, 22, 82, 14, 0),
      (12, 1, 1, 0, 0, 0, 22, 83, 12, 0),
      (2, 1, 1, 0, 1, 0, 21, 85, 12, 0),
      (4, 1, 1, 0, 1, 0, 18, 80, 12, 1),
      (24, 1, 1, 0, 0, 0, 23, 82, 13, 0),
      (1, 1, 1, 0, 0, 0, 23, 83, 11, 0),
      (20, 1, 1, 0, 0, 0, 21, 81, 13, 0),
      (76, 1, 1, 0, 0, 0, 21, 83, 14, 0),
      (8, 1, 1, 0, 0, 0, 20, 79, 12, 0),
      (4, 1, 3, 0, 0, 0, 24, 81, 11, 0),
      (36, 1, 1, 0, 1, 0, 20, 80, 12, 0),
      (6, 1, 1, 0, 0, 0, 21, 82, 12, 0),
      (32, 1, 1, 0, 0, 0, 19, 83, 14, 0),
      (4, 1, 1, 0, 0, 0, 20, 81, 12, 0),
      (4, 1, 1, 0, 1, 0, 21, 79, 12, 0),
      (40, 1, 1, 1, 1, 0, 22, 85, 12, 0),
      (3, 1, 3, 0, 0, 0, 20, 81, 9, 0),
      (8, 1, 1, 1, 0, 1, 23, 83, 10, 1),
      (32, 1, 1, 0, 0, 0, 18, 80, 11, 0),
      (10, 0, 1, 0, 0, 0, 28, 85, 15, 1),
      (1, 1, 1, 0, 0, 0, 20, 84, 12, 1),
      (1, 1, 1, 0, 1, 0, 20, 80, 12, 0),
      (5, 1, 1, 1, 1, 1, 21, 78, 15, 0),
      (24, 1, 1, 0, 1, 0, 18, 81, 10, 0),
      (48, 1, 1, 0, 0, 0, 23, 83, 12, 0),
      (12, 1, 1, 0, 1, 0, 24, 83, 12, 0),
      (20, 1, 1, 0, 0, 0, 27, 85, 17, 0),
      (4, 1, 1, 0, 1, 0, 21, 84, 12, 0),
      (16, 1, 1, 1, 1, 0, 21, 82, 12, 0),
      (32, 1, 3, 1, 0, 0, 18, 82, 10, 1),
      (24, 1, 1, 0, 0, 0, 26, 85, 14, 1),
      (13, 1, 1, 0, 0, 0, 21, 82, 12, 0),
      (1, 1, 1, 1, 0, 0, 16, 81, 9, 1),
      (16, 1, 1, 0, 1, 0, 20, 81, 12, 0),
      (44, 1, 1, 0, 0, 0, 21, 80, 12, 0),
      (32, 1, 1, 0, 1, 1, 22, 83, 12, 0),
      (1, 1, 1, 0, 1, 1, 20, 83, 12, 0),
      (8, 1, 1, 0, 1, 0, 22, 79, 12, 0),
      (6, 1, 1, 0, 0, 0, 22, 82, 13, 1),
      (6, 1, 1, 1, 1, 0, 21, 81, 12, 0),
      (32, 1, 1, 0, 0, 1, 25, 84, 18, 0),
      (28, 1, 1, 0, 1, 1, 19, 80, 12, 0),
      (7, 1, 1, 0, 0, 1, 24, 83, 14, 0),
      (12, 1, 1, 1, 1, 1, 20, 80, 10, 1),
      (4, 1, 1, 1, 0, 0, 18, 81, 11, 0),
      (32, 1, 1, 0, 0, 0, 23, 81, 16, 0),
      (48, 1, 1, 1, 0, 0, 20, 84, 11, 1),
      (32, 1, 1, 1, 0, 0, 17, 78, 12, 1),
      (3, 1, 2, 0, 1, 0, 19, 79, 11, 1),
      (4, 1, 2, 0, 0, 0, 21, 78, 12, 0),
      (4, 1, 1, 0, 1, 0, 23, 82, 12, 0),
      (2, 1, 1, 0, 0, 0, 24, 82, 13, 0),
      (3, 1, 1, 0, 0, 1, 21, 80, 12, 0),
      (1, 1, 1, 0, 1, 1, 20, 81, 12, 0),
      (32, 1, 1, 0, 1, 0, 24, 81, 12, 0),
      (24, 1, 1, 0, 0, 0, 20, 80, 12, 0),
      (4, 1, 1, 0, 0, 0, 20, 79, 12, 0),
      (5, 1, 1, 0, 0, 1, 22, 81, 12, 0),
      (24, 1, 2, 0, 0, 0, 21, 80, 12, 0),
      (6, 1, 1, 0, 1, 0, 20, 80, 12, 0))

    val data = dataList.toDF("label", "censor","race","poverty","smoke","alcohol","agemth","ybirth","yschool","pc3mth").orderBy("label")

 

建模並調優

val colArray = Array("race", "poverty", "smoke", "alcohol", "agemth", "ybirth", "yschool", "pc3mth")
 
val assembler = new VectorAssembler().setInputCols(colArray).setOutputCol("features")
 
val vecDF: DataFrame = assembler.transform(data)
 
val Array(trainingDF, testDF) = vecDF.randomSplit(Array(0.7, 0.3))
 
//###########################
// 建立生存迴歸模型
val AFT = new AFTSurvivalRegression().setFeaturesCol("features").setLabelCol("label").setCensorCol("censor").fit(trainingDF)
 
// 設定管道
val pipeline = new Pipeline().setStages(Array(AFT))
 
// 設定引數網格
val paramGrid = new ParamGridBuilder().addGrid(AFT.maxIter, Array(100, 500, 1000)).addGrid(AFT.tol, Array(1E-2, 1E-6)).build()
 
// 選擇(prediction, true label),計算測試誤差。
// 注意RegEvaluator.isLargerBetter,評估的度量值是大的好,還是小的好,系統會自動識別
val RegEvaluator = new RegressionEvaluator().setLabelCol(AFT.getLabelCol).setPredictionCol(AFT.getPredictionCol).setMetricName("rmse")
 
// 設定交叉驗證
val cv = new CrossValidator().setEstimator(pipeline).setEvaluator(RegEvaluator).setEstimatorParamMaps(paramGrid).setNumFolds(3)
 
// 執行交叉驗證,並選擇出最好的引數集
val cvModel = cv.fit(trainingDF)
 
// 檢視全部引數
cvModel.extractParamMap()
// cvModel.avgMetrics.length=cvModel.getEstimatorParamMaps.length
// cvModel.avgMetrics與cvModel.getEstimatorParamMaps中的元素一一對應
cvModel.avgMetrics.length
cvModel.avgMetrics // 引數對應的平均度量
 
cvModel.getEstimatorParamMaps.length
cvModel.getEstimatorParamMaps // 引數組合的集合
 
cvModel.getEvaluator.extractParamMap()  // 評估的引數
 
cvModel.getEvaluator.isLargerBetter // 評估的度量值是大的好,還是小的好
cvModel.getNumFolds // 交叉驗證的折數
 
//################################
// 測試模型
val predictDF: DataFrame = cvModel.transform(testDF).selectExpr(
  //"race","poverty","smoke","alcohol","agemth","ybirth","yschool","pc3mth", "features",
  "label", "censor",
  "round(prediction,2) as prediction").orderBy("label")
predictDF.show
 
spark.stop()

 

程式碼執行結果 

// 檢視全部引數
cvModel.extractParamMap()
res2: org.apache.spark.ml.param.ParamMap =
{
    cv_baf8c9af33b7-estimator: pipeline_20ba567066f7,
    cv_baf8c9af33b7-estimatorParamMaps: [Lorg.apache.spark.ml.param.ParamMap;@412a07c8,
    cv_baf8c9af33b7-evaluator: regEval_59075079f1c9,
    cv_baf8c9af33b7-numFolds: 3,
    cv_baf8c9af33b7-seed: -1191137437
}
 
// cvModel.avgMetrics.length=cvModel.getEstimatorParamMaps.length
// cvModel.avgMetrics與cvModel.getEstimatorParamMaps中的元素一一對應
cvModel.avgMetrics.length
res3: Int = 6
 
cvModel.avgMetrics // 引數對應的平均度量
res4: Array[Double] = Array(18.53, 17.53, 19.53, 17.63, 18.53, 18.93)
 
cvModel.getEstimatorParamMaps.length
res5: Int = 6
 
cvModel.getEstimatorParamMaps // 引數組合的集合
res6: Array[org.apache.spark.ml.param.ParamMap] =
Array({
    aftSurvReg_a7e5bc450599-maxIter: 100,
    aftSurvReg_a7e5bc450599-tol: 0.01
}, {
    aftSurvReg_a7e5bc450599-maxIter: 100,
    aftSurvReg_a7e5bc450599-tol: 1.0E-6
}, {
    aftSurvReg_a7e5bc450599-maxIter: 500,
    aftSurvReg_a7e5bc450599-tol: 0.01
}, {
    aftSurvReg_a7e5bc450599-maxIter: 500,
    aftSurvReg_a7e5bc450599-tol: 1.0E-6
}, {
    aftSurvReg_a7e5bc450599-maxIter: 1000,
    aftSurvReg_a7e5bc450599-tol: 0.01
}, {
    aftSurvReg_a7e5bc450599-maxIter: 1000,
    aftSurvReg_a7e5bc450599-tol: 1.0E-6
})
 
cvModel.getEvaluator.extractParamMap()  // 評估的引數
res7: org.apache.spark.ml.param.ParamMap =
{
    regEval_59075079f1c9-labelCol: label,
    regEval_59075079f1c9-metricName: rmse,
    regEval_59075079f1c9-predictionCol: prediction
}
 
cvModel.getEvaluator.isLargerBetter // 評估的度量值是大的好,還是小的好
res8: Boolean = false   // 這裡顯示“評估的度量值”是小的好
 
cvModel.getNumFolds // 交叉驗證的折數
res9: Int = 3
 
//################################
// 測試模型
val predictDF: DataFrame = cvModel.transform(testDF).selectExpr(
     |   //"race","poverty","smoke","alcohol","agemth","ybirth","yschool","pc3mth", "features",
     |   "label", "censor",
     |   "round(prediction,2) as prediction").orderBy("label")
predictDF: org.apache.spark.sql.DataFrame = [label: double, censor: double ... 1 more field]
 
predictDF.show
+-----+------+----------+                                                      
|label|censor|prediction|
+-----+------+----------+
|  1.0|   1.0|      15.4|
|  1.0|   1.0|     20.02|
|  1.0|   1.0|     18.73|
|  1.0|   1.0|     21.58|
|  1.0|   1.0|      21.8|
|  1.0|   1.0|      21.8|
|  1.0|   1.0|     14.37|
|  1.0|   1.0|      13.5|
|  1.0|   1.0|     15.82|
|  1.0|   1.0|     19.51|
|  1.0|   1.0|     13.17|
|  1.0|   1.0|      11.9|
|  1.0|   1.0|     17.26|
|  1.0|   1.0|     13.57|
|  1.0|   1.0|     11.57|
|  1.0|   1.0|     13.55|
|  1.0|   1.0|     10.95|
|  1.0|   1.0|     14.92|
|  1.0|   1.0|     12.25|
|  1.0|   1.0|     19.62|
+-----+------+----------+
only showing top 20 rows

  

 

相關文章