Skip to content
Snippets Groups Projects
Commit c74fd1e5 authored by wm624@hotmail.com's avatar wm624@hotmail.com Committed by Joseph K. Bradley
Browse files

[SPARK-14937][ML][DOCUMENT] spark.ml LogisticRegression sqlCtx in scala is...

[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: wm624@hotmail.com <wm624@hotmail.com>

Closes #12717 from wangmiao1981/doc.
parent 450136ec
No related branches found
No related tags found
No related merge requests found
...@@ -29,11 +29,11 @@ object LinearRegressionWithElasticNetExample { ...@@ -29,11 +29,11 @@ object LinearRegressionWithElasticNetExample {
def main(args: Array[String]): Unit = { def main(args: Array[String]): Unit = {
val conf = new SparkConf().setAppName("LinearRegressionWithElasticNetExample") val conf = new SparkConf().setAppName("LinearRegressionWithElasticNetExample")
val sc = new SparkContext(conf) val sc = new SparkContext(conf)
val sqlCtx = new SQLContext(sc) val sqlContext = new SQLContext(sc)
// $example on$ // $example on$
// Load training data // Load training data
val training = sqlCtx.read.format("libsvm") val training = sqlContext.read.format("libsvm")
.load("data/mllib/sample_linear_regression_data.txt") .load("data/mllib/sample_linear_regression_data.txt")
val lr = new LinearRegression() val lr = new LinearRegression()
......
...@@ -30,11 +30,11 @@ object LogisticRegressionSummaryExample { ...@@ -30,11 +30,11 @@ object LogisticRegressionSummaryExample {
def main(args: Array[String]): Unit = { def main(args: Array[String]): Unit = {
val conf = new SparkConf().setAppName("LogisticRegressionSummaryExample") val conf = new SparkConf().setAppName("LogisticRegressionSummaryExample")
val sc = new SparkContext(conf) val sc = new SparkContext(conf)
val sqlCtx = new SQLContext(sc) val sqlContext = new SQLContext(sc)
import sqlCtx.implicits._ import sqlContext.implicits._
// Load training data // Load training data
val training = sqlCtx.read.format("libsvm").load("data/mllib/sample_libsvm_data.txt") val training = sqlContext.read.format("libsvm").load("data/mllib/sample_libsvm_data.txt")
val lr = new LogisticRegression() val lr = new LogisticRegression()
.setMaxIter(10) .setMaxIter(10)
......
...@@ -29,11 +29,11 @@ object LogisticRegressionWithElasticNetExample { ...@@ -29,11 +29,11 @@ object LogisticRegressionWithElasticNetExample {
def main(args: Array[String]): Unit = { def main(args: Array[String]): Unit = {
val conf = new SparkConf().setAppName("LogisticRegressionWithElasticNetExample") val conf = new SparkConf().setAppName("LogisticRegressionWithElasticNetExample")
val sc = new SparkContext(conf) val sc = new SparkContext(conf)
val sqlCtx = new SQLContext(sc) val sqlContext = new SQLContext(sc)
// $example on$ // $example on$
// Load training data // Load training data
val training = sqlCtx.read.format("libsvm").load("data/mllib/sample_libsvm_data.txt") val training = sqlContext.read.format("libsvm").load("data/mllib/sample_libsvm_data.txt")
val lr = new LogisticRegression() val lr = new LogisticRegression()
.setMaxIter(10) .setMaxIter(10)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment