@@ -44,7 +44,7 @@ class BinaryClassificationMetrics(JavaModelWrapper):
4444
4545 def __init__ (self , scoreAndLabels ):
4646 sc = scoreAndLabels .ctx
47- sql_ctx = SQLContext (sc )
47+ sql_ctx = SQLContext . getOrCreate (sc )
4848 df = sql_ctx .createDataFrame (scoreAndLabels , schema = StructType ([
4949 StructField ("score" , DoubleType (), nullable = False ),
5050 StructField ("label" , DoubleType (), nullable = False )]))
@@ -103,7 +103,7 @@ class RegressionMetrics(JavaModelWrapper):
103103
104104 def __init__ (self , predictionAndObservations ):
105105 sc = predictionAndObservations .ctx
106- sql_ctx = SQLContext (sc )
106+ sql_ctx = SQLContext . getOrCreate (sc )
107107 df = sql_ctx .createDataFrame (predictionAndObservations , schema = StructType ([
108108 StructField ("prediction" , DoubleType (), nullable = False ),
109109 StructField ("observation" , DoubleType (), nullable = False )]))
@@ -197,7 +197,7 @@ class MulticlassMetrics(JavaModelWrapper):
197197
198198 def __init__ (self , predictionAndLabels ):
199199 sc = predictionAndLabels .ctx
200- sql_ctx = SQLContext (sc )
200+ sql_ctx = SQLContext . getOrCreate (sc )
201201 df = sql_ctx .createDataFrame (predictionAndLabels , schema = StructType ([
202202 StructField ("prediction" , DoubleType (), nullable = False ),
203203 StructField ("label" , DoubleType (), nullable = False )]))
@@ -338,7 +338,7 @@ class RankingMetrics(JavaModelWrapper):
338338
339339 def __init__ (self , predictionAndLabels ):
340340 sc = predictionAndLabels .ctx
341- sql_ctx = SQLContext (sc )
341+ sql_ctx = SQLContext . getOrCreate (sc )
342342 df = sql_ctx .createDataFrame (predictionAndLabels ,
343343 schema = sql_ctx ._inferSchema (predictionAndLabels ))
344344 java_model = callMLlibFunc ("newRankingMetrics" , df ._jdf )
@@ -424,7 +424,7 @@ class MultilabelMetrics(JavaModelWrapper):
424424
425425 def __init__ (self , predictionAndLabels ):
426426 sc = predictionAndLabels .ctx
427- sql_ctx = SQLContext (sc )
427+ sql_ctx = SQLContext . getOrCreate (sc )
428428 df = sql_ctx .createDataFrame (predictionAndLabels ,
429429 schema = sql_ctx ._inferSchema (predictionAndLabels ))
430430 java_class = sc ._jvm .org .apache .spark .mllib .evaluation .MultilabelMetrics
0 commit comments