Skip to content

Commit 539dfa2

Browse files
zhengruifengmengxr
authored andcommitted
[SPARK-15398][ML] Update the warning message to recommend ML usage
## What changes were proposed in this pull request? MLlib are not recommended to use, and some methods are even deprecated. Update the warning message to recommend ML usage. ``` def showWarning() { System.err.println( """WARN: This is a naive implementation of Logistic Regression and is given as an example! |Please use either org.apache.spark.mllib.classification.LogisticRegressionWithSGD or |org.apache.spark.mllib.classification.LogisticRegressionWithLBFGS |for more conventional use. """.stripMargin) } ``` To ``` def showWarning() { System.err.println( """WARN: This is a naive implementation of Logistic Regression and is given as an example! |Please use org.apache.spark.ml.classification.LogisticRegression |for more conventional use. """.stripMargin) } ``` ## How was this patch tested? local build Author: Zheng RuiFeng <[email protected]> Closes #13190 from zhengruifeng/update_recd. (cherry picked from commit 47a2940) Signed-off-by: Xiangrui Meng <[email protected]>
1 parent e4e3e98 commit 539dfa2

File tree

12 files changed

+28
-37
lines changed

12 files changed

+28
-37
lines changed

examples/src/main/java/org/apache/spark/examples/JavaHdfsLR.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@
3232
* Logistic regression based classification.
3333
*
3434
* This is an example implementation for learning how to use Spark. For more conventional use,
35-
* please refer to either org.apache.spark.mllib.classification.LogisticRegressionWithSGD or
36-
* org.apache.spark.mllib.classification.LogisticRegressionWithLBFGS based on your needs.
35+
* please refer to org.apache.spark.ml.classification.LogisticRegression.
3736
*/
3837
public final class JavaHdfsLR {
3938

@@ -43,8 +42,7 @@ public final class JavaHdfsLR {
4342
static void showWarning() {
4443
String warning = "WARN: This is a naive implementation of Logistic Regression " +
4544
"and is given as an example!\n" +
46-
"Please use either org.apache.spark.mllib.classification.LogisticRegressionWithSGD " +
47-
"or org.apache.spark.mllib.classification.LogisticRegressionWithLBFGS " +
45+
"Please use org.apache.spark.ml.classification.LogisticRegression " +
4846
"for more conventional use.";
4947
System.err.println(warning);
5048
}

examples/src/main/python/als.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
"""
1919
This is an example implementation of ALS for learning how to use Spark. Please refer to
20-
ALS in pyspark.mllib.recommendation for more conventional use.
20+
pyspark.ml.recommendation.ALS for more conventional use.
2121
2222
This example requires numpy (http://www.numpy.org/)
2323
"""
@@ -59,7 +59,7 @@ def update(i, vec, mat, ratings):
5959
"""
6060

6161
print("""WARN: This is a naive implementation of ALS and is given as an
62-
example. Please use the ALS method found in pyspark.mllib.recommendation for more
62+
example. Please use pyspark.ml.recommendation.ALS for more
6363
conventional use.""", file=sys.stderr)
6464

6565
sc = SparkContext(appName="PythonALS")

examples/src/main/python/kmeans.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717

1818
"""
1919
The K-means algorithm written from scratch against PySpark. In practice,
20-
one may prefer to use the KMeans algorithm in MLlib, as shown in
21-
examples/src/main/python/mllib/kmeans.py.
20+
one may prefer to use the KMeans algorithm in ML, as shown in
21+
examples/src/main/python/ml/kmeans_example.py.
2222
2323
This example requires NumPy (http://www.numpy.org/).
2424
"""
@@ -52,8 +52,8 @@ def closestPoint(p, centers):
5252
exit(-1)
5353

5454
print("""WARN: This is a naive implementation of KMeans Clustering and is given
55-
as an example! Please refer to examples/src/main/python/mllib/kmeans.py for an example on
56-
how to use MLlib's KMeans implementation.""", file=sys.stderr)
55+
as an example! Please refer to examples/src/main/python/ml/kmeans_example.py for an
56+
example on how to use ML's KMeans implementation.""", file=sys.stderr)
5757

5858
sc = SparkContext(appName="PythonKMeans")
5959
lines = sc.textFile(sys.argv[1])

examples/src/main/python/logistic_regression.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
to act on batches of input data using efficient matrix operations.
2121
2222
In practice, one may prefer to use the LogisticRegression algorithm in
23-
MLlib, as shown in examples/src/main/python/mllib/logistic_regression.py.
23+
ML, as shown in examples/src/main/python/ml/logistic_regression_with_elastic_net.py.
2424
"""
2525
from __future__ import print_function
2626

@@ -51,8 +51,9 @@ def readPointBatch(iterator):
5151
exit(-1)
5252

5353
print("""WARN: This is a naive implementation of Logistic Regression and is
54-
given as an example! Please refer to examples/src/main/python/mllib/logistic_regression.py
55-
to see how MLlib's implementation is used.""", file=sys.stderr)
54+
given as an example!
55+
Please refer to examples/src/main/python/ml/logistic_regression_with_elastic_net.py
56+
to see how ML's implementation is used.""", file=sys.stderr)
5657

5758
sc = SparkContext(appName="PythonLR")
5859
points = sc.textFile(sys.argv[1]).mapPartitions(readPointBatch).cache()

examples/src/main/scala/org/apache/spark/examples/LocalALS.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import org.apache.commons.math3.linear._
2424
* Alternating least squares matrix factorization.
2525
*
2626
* This is an example implementation for learning how to use Spark. For more conventional use,
27-
* please refer to org.apache.spark.mllib.recommendation.ALS
27+
* please refer to org.apache.spark.ml.recommendation.ALS.
2828
*/
2929
object LocalALS {
3030

@@ -96,7 +96,7 @@ object LocalALS {
9696
def showWarning() {
9797
System.err.println(
9898
"""WARN: This is a naive implementation of ALS and is given as an example!
99-
|Please use the ALS method found in org.apache.spark.mllib.recommendation
99+
|Please use org.apache.spark.ml.recommendation.ALS
100100
|for more conventional use.
101101
""".stripMargin)
102102
}

examples/src/main/scala/org/apache/spark/examples/LocalFileLR.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ import breeze.linalg.{DenseVector, Vector}
2626
* Logistic regression based classification.
2727
*
2828
* This is an example implementation for learning how to use Spark. For more conventional use,
29-
* please refer to either org.apache.spark.mllib.classification.LogisticRegressionWithSGD or
30-
* org.apache.spark.mllib.classification.LogisticRegressionWithLBFGS based on your needs.
29+
* please refer to org.apache.spark.ml.classification.LogisticRegression.
3130
*/
3231
object LocalFileLR {
3332
val D = 10 // Number of dimensions
@@ -43,8 +42,7 @@ object LocalFileLR {
4342
def showWarning() {
4443
System.err.println(
4544
"""WARN: This is a naive implementation of Logistic Regression and is given as an example!
46-
|Please use either org.apache.spark.mllib.classification.LogisticRegressionWithSGD or
47-
|org.apache.spark.mllib.classification.LogisticRegressionWithLBFGS
45+
|Please use org.apache.spark.ml.classification.LogisticRegression
4846
|for more conventional use.
4947
""".stripMargin)
5048
}

examples/src/main/scala/org/apache/spark/examples/LocalKMeans.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ import breeze.linalg.{squaredDistance, DenseVector, Vector}
2929
* K-means clustering.
3030
*
3131
* This is an example implementation for learning how to use Spark. For more conventional use,
32-
* please refer to org.apache.spark.mllib.clustering.KMeans
32+
* please refer to org.apache.spark.ml.clustering.KMeans.
3333
*/
3434
object LocalKMeans {
3535
val N = 1000
@@ -66,7 +66,7 @@ object LocalKMeans {
6666
def showWarning() {
6767
System.err.println(
6868
"""WARN: This is a naive implementation of KMeans Clustering and is given as an example!
69-
|Please use the KMeans method found in org.apache.spark.mllib.clustering
69+
|Please use org.apache.spark.ml.clustering.KMeans
7070
|for more conventional use.
7171
""".stripMargin)
7272
}

examples/src/main/scala/org/apache/spark/examples/LocalLR.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ import breeze.linalg.{DenseVector, Vector}
2626
* Logistic regression based classification.
2727
*
2828
* This is an example implementation for learning how to use Spark. For more conventional use,
29-
* please refer to either org.apache.spark.mllib.classification.LogisticRegressionWithSGD or
30-
* org.apache.spark.mllib.classification.LogisticRegressionWithLBFGS based on your needs.
29+
* please refer to org.apache.spark.ml.classification.LogisticRegression.
3130
*/
3231
object LocalLR {
3332
val N = 10000 // Number of data points
@@ -50,8 +49,7 @@ object LocalLR {
5049
def showWarning() {
5150
System.err.println(
5251
"""WARN: This is a naive implementation of Logistic Regression and is given as an example!
53-
|Please use either org.apache.spark.mllib.classification.LogisticRegressionWithSGD or
54-
|org.apache.spark.mllib.classification.LogisticRegressionWithLBFGS
52+
|Please use org.apache.spark.ml.classification.LogisticRegression
5553
|for more conventional use.
5654
""".stripMargin)
5755
}

examples/src/main/scala/org/apache/spark/examples/SparkALS.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import org.apache.spark._
2626
* Alternating least squares matrix factorization.
2727
*
2828
* This is an example implementation for learning how to use Spark. For more conventional use,
29-
* please refer to org.apache.spark.mllib.recommendation.ALS
29+
* please refer to org.apache.spark.ml.recommendation.ALS.
3030
*/
3131
object SparkALS {
3232

@@ -81,7 +81,7 @@ object SparkALS {
8181
def showWarning() {
8282
System.err.println(
8383
"""WARN: This is a naive implementation of ALS and is given as an example!
84-
|Please use the ALS method found in org.apache.spark.mllib.recommendation
84+
|Please use org.apache.spark.ml.recommendation.ALS
8585
|for more conventional use.
8686
""".stripMargin)
8787
}

examples/src/main/scala/org/apache/spark/examples/SparkHdfsLR.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ import org.apache.spark._
3131
* Logistic regression based classification.
3232
*
3333
* This is an example implementation for learning how to use Spark. For more conventional use,
34-
* please refer to either org.apache.spark.mllib.classification.LogisticRegressionWithSGD or
35-
* org.apache.spark.mllib.classification.LogisticRegressionWithLBFGS based on your needs.
34+
* please refer to org.apache.spark.ml.classification.LogisticRegression.
3635
*/
3736
object SparkHdfsLR {
3837
val D = 10 // Number of dimensions
@@ -54,8 +53,7 @@ object SparkHdfsLR {
5453
def showWarning() {
5554
System.err.println(
5655
"""WARN: This is a naive implementation of Logistic Regression and is given as an example!
57-
|Please use either org.apache.spark.mllib.classification.LogisticRegressionWithSGD or
58-
|org.apache.spark.mllib.classification.LogisticRegressionWithLBFGS
56+
|Please use org.apache.spark.ml.classification.LogisticRegression
5957
|for more conventional use.
6058
""".stripMargin)
6159
}

0 commit comments

Comments
 (0)