diff options
Diffstat (limited to 'examples/src/main/python/ml/aft_survival_regression.py')
-rw-r--r-- | examples/src/main/python/ml/aft_survival_regression.py | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/examples/src/main/python/ml/aft_survival_regression.py b/examples/src/main/python/ml/aft_survival_regression.py index 0ee01fd825..9879679829 100644 --- a/examples/src/main/python/ml/aft_survival_regression.py +++ b/examples/src/main/python/ml/aft_survival_regression.py @@ -17,19 +17,26 @@ from __future__ import print_function -from pyspark import SparkContext -from pyspark.sql import SQLContext # $example on$ from pyspark.ml.regression import AFTSurvivalRegression from pyspark.mllib.linalg import Vectors # $example off$ +from pyspark.sql import SparkSession + +""" +An example demonstrating aft survival regression. +Run with: + bin/spark-submit examples/src/main/python/ml/aft_survival_regression.py +""" if __name__ == "__main__": - sc = SparkContext(appName="AFTSurvivalRegressionExample") - sqlContext = SQLContext(sc) + spark = SparkSession \ + .builder \ + .appName("PythonAFTSurvivalRegressionExample") \ + .getOrCreate() # $example on$ - training = sqlContext.createDataFrame([ + training = spark.createDataFrame([ (1.218, 1.0, Vectors.dense(1.560, -0.605)), (2.949, 0.0, Vectors.dense(0.346, 2.158)), (3.627, 0.0, Vectors.dense(1.380, 0.231)), @@ -48,4 +55,4 @@ if __name__ == "__main__": model.transform(training).show(truncate=False) # $example off$ - sc.stop() + spark.stop() |