You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by yl...@apache.org on 2017/01/12 08:58:37 UTC

spark git commit: [SPARK-19158][SPARKR][EXAMPLES] Fix ml.R example fails due to lack of e1071 package.

Repository: spark
Updated Branches:
  refs/heads/master 24100f162 -> 2c586f506


[SPARK-19158][SPARKR][EXAMPLES] Fix ml.R example fails due to lack of e1071 package.

## What changes were proposed in this pull request?
```ml.R``` example depends on ```e1071``` package, if it's not available in users' environment, it will fail. I think the example should not depends on third-party packages, so I update it to remove the dependency.

## How was this patch tested?
Manual test.

Author: Yanbo Liang <yb...@gmail.com>

Closes #16548 from yanboliang/spark-19158.


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/2c586f50
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/2c586f50
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/2c586f50

Branch: refs/heads/master
Commit: 2c586f506de9e2ba592afae1f0c73b6ae631bb96
Parents: 24100f1
Author: Yanbo Liang <yb...@gmail.com>
Authored: Thu Jan 12 00:58:30 2017 -0800
Committer: Yanbo Liang <yb...@gmail.com>
Committed: Thu Jan 12 00:58:30 2017 -0800

----------------------------------------------------------------------
 examples/src/main/r/ml/ml.R | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/2c586f50/examples/src/main/r/ml/ml.R
----------------------------------------------------------------------
diff --git a/examples/src/main/r/ml/ml.R b/examples/src/main/r/ml/ml.R
index d601590..05f5199 100644
--- a/examples/src/main/r/ml/ml.R
+++ b/examples/src/main/r/ml/ml.R
@@ -49,17 +49,16 @@ unlink(modelPath)
 
 ############################ fit models with spark.lapply #####################################
 # Perform distributed training of multiple models with spark.lapply
-costs <- exp(seq(from = log(1), to = log(1000), length.out = 5))
-train <- function(cost) {
-  stopifnot(requireNamespace("e1071", quietly = TRUE))
-  model <- e1071::svm(Species ~ ., data = iris, cost = cost)
-  summary(model)
+algorithms <- c("Hartigan-Wong", "Lloyd", "MacQueen")
+train <- function(algorithm) {
+  model <- kmeans(x = iris[1:4], centers = 3, algorithm = algorithm)
+  model$withinss
 }
 
-model.summaries <- spark.lapply(costs, train)
+model.withinss <- spark.lapply(algorithms, train)
 
-# Print the summary of each model
-print(model.summaries)
+# Print the within-cluster sum of squares for each model
+print(model.withinss)
 
 # Stop the SparkSession now
 sparkR.session.stop()


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org