Skip to content

Commit c74fd1e

Browse files
wangmiao1981jkbradley
authored andcommitted
[SPARK-14937][ML][DOCUMENT] spark.ml LogisticRegression sqlCtx in scala is inconsistent with java and python
## What changes were proposed in this pull request? In spark.ml document, the LogisticRegression scala example uses sqlCtx. It is inconsistent with java and python examples which use sqlContext. In addition, a user can't copy & paste to run the example in spark-shell as sqlCtx doesn't exist in spark-shell while sqlContext exists. Change the scala example referred by the spark.ml example. ## How was this patch tested? Compile the example scala file and it passes compilation. Author: [email protected] <[email protected]> Closes #12717 from wangmiao1981/doc.
1 parent 450136e commit c74fd1e

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

examples/src/main/scala/org/apache/spark/examples/ml/LinearRegressionWithElasticNetExample.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ object LinearRegressionWithElasticNetExample {
2929
def main(args: Array[String]): Unit = {
3030
val conf = new SparkConf().setAppName("LinearRegressionWithElasticNetExample")
3131
val sc = new SparkContext(conf)
32-
val sqlCtx = new SQLContext(sc)
32+
val sqlContext = new SQLContext(sc)
3333

3434
// $example on$
3535
// Load training data
36-
val training = sqlCtx.read.format("libsvm")
36+
val training = sqlContext.read.format("libsvm")
3737
.load("data/mllib/sample_linear_regression_data.txt")
3838

3939
val lr = new LinearRegression()

examples/src/main/scala/org/apache/spark/examples/ml/LogisticRegressionSummaryExample.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ object LogisticRegressionSummaryExample {
3030
def main(args: Array[String]): Unit = {
3131
val conf = new SparkConf().setAppName("LogisticRegressionSummaryExample")
3232
val sc = new SparkContext(conf)
33-
val sqlCtx = new SQLContext(sc)
34-
import sqlCtx.implicits._
33+
val sqlContext = new SQLContext(sc)
34+
import sqlContext.implicits._
3535

3636
// Load training data
37-
val training = sqlCtx.read.format("libsvm").load("data/mllib/sample_libsvm_data.txt")
37+
val training = sqlContext.read.format("libsvm").load("data/mllib/sample_libsvm_data.txt")
3838

3939
val lr = new LogisticRegression()
4040
.setMaxIter(10)

examples/src/main/scala/org/apache/spark/examples/ml/LogisticRegressionWithElasticNetExample.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ object LogisticRegressionWithElasticNetExample {
2929
def main(args: Array[String]): Unit = {
3030
val conf = new SparkConf().setAppName("LogisticRegressionWithElasticNetExample")
3131
val sc = new SparkContext(conf)
32-
val sqlCtx = new SQLContext(sc)
32+
val sqlContext = new SQLContext(sc)
3333

3434
// $example on$
3535
// Load training data
36-
val training = sqlCtx.read.format("libsvm").load("data/mllib/sample_libsvm_data.txt")
36+
val training = sqlContext.read.format("libsvm").load("data/mllib/sample_libsvm_data.txt")
3737

3838
val lr = new LogisticRegression()
3939
.setMaxIter(10)

0 commit comments

Comments
 (0)