aboutsummaryrefslogtreecommitdiff
path: root/examples/src/main
diff options
context:
space:
mode:
authorYanbo Liang <ybliang8@gmail.com>2016-07-11 14:31:11 -0700
committerShivaram Venkataraman <shivaram@cs.berkeley.edu>2016-07-11 14:31:11 -0700
commit2ad031be67c7a0f0c4895c084c891330a9ec935e (patch)
tree1972b9f3226ca0026db712b6c32faba47f23b2e1 /examples/src/main
parent840853ed06d63694bf98b21a889a960aac6ac0ac (diff)
downloadspark-2ad031be67c7a0f0c4895c084c891330a9ec935e.tar.gz
spark-2ad031be67c7a0f0c4895c084c891330a9ec935e.tar.bz2
spark-2ad031be67c7a0f0c4895c084c891330a9ec935e.zip
[SPARKR][DOC] SparkR ML user guides update for 2.0
## What changes were proposed in this pull request? * Update SparkR ML section to make them consistent with SparkR API docs. * Since #13972 adds labelling support for the ```include_example``` Jekyll plugin, so that we can split the single ```ml.R``` example file into multiple line blocks with different labels, and include them in different algorithms/models in the generated HTML page. ## How was this patch tested? Only docs update, manually check the generated docs. Author: Yanbo Liang <ybliang8@gmail.com> Closes #14011 from yanboliang/r-user-guide-update.
Diffstat (limited to 'examples/src/main')
-rw-r--r--examples/src/main/r/ml.R22
1 files changed, 11 insertions, 11 deletions
diff --git a/examples/src/main/r/ml.R b/examples/src/main/r/ml.R
index 65242e68b3..a8a1274ac9 100644
--- a/examples/src/main/r/ml.R
+++ b/examples/src/main/r/ml.R
@@ -24,9 +24,8 @@ library(SparkR)
# Initialize SparkSession
sparkR.session(appName = "SparkR-ML-example")
-# $example on$
############################ spark.glm and glm ##############################################
-
+# $example on:glm$
irisDF <- suppressWarnings(createDataFrame(iris))
# Fit a generalized linear model of family "gaussian" with spark.glm
gaussianDF <- irisDF
@@ -55,8 +54,9 @@ summary(binomialGLM)
# Prediction
binomialPredictions <- predict(binomialGLM, binomialTestDF)
showDF(binomialPredictions)
-
+# $example off:glm$
############################ spark.survreg ##############################################
+# $example on:survreg$
# Use the ovarian dataset available in R survival package
library(survival)
@@ -72,9 +72,9 @@ summary(aftModel)
# Prediction
aftPredictions <- predict(aftModel, aftTestDF)
showDF(aftPredictions)
-
+# $example off:survreg$
############################ spark.naiveBayes ##############################################
-
+# $example on:naiveBayes$
# Fit a Bernoulli naive Bayes model with spark.naiveBayes
titanic <- as.data.frame(Titanic)
titanicDF <- createDataFrame(titanic[titanic$Freq > 0, -5])
@@ -88,9 +88,9 @@ summary(nbModel)
# Prediction
nbPredictions <- predict(nbModel, nbTestDF)
showDF(nbPredictions)
-
+# $example off:naiveBayes$
############################ spark.kmeans ##############################################
-
+# $example on:kmeans$
# Fit a k-means model with spark.kmeans
irisDF <- suppressWarnings(createDataFrame(iris))
kmeansDF <- irisDF
@@ -107,9 +107,9 @@ showDF(fitted(kmeansModel))
# Prediction
kmeansPredictions <- predict(kmeansModel, kmeansTestDF)
showDF(kmeansPredictions)
-
+# $example off:kmeans$
############################ model read/write ##############################################
-
+# $example on:read_write$
irisDF <- suppressWarnings(createDataFrame(iris))
# Fit a generalized linear model of family "gaussian" with spark.glm
gaussianDF <- irisDF
@@ -120,7 +120,7 @@ gaussianGLM <- spark.glm(gaussianDF, Sepal_Length ~ Sepal_Width + Species, famil
modelPath <- tempfile(pattern = "ml", fileext = ".tmp")
write.ml(gaussianGLM, modelPath)
gaussianGLM2 <- read.ml(modelPath)
-# $example off$
+
# Check model summary
summary(gaussianGLM2)
@@ -129,7 +129,7 @@ gaussianPredictions <- predict(gaussianGLM2, gaussianTestDF)
showDF(gaussianPredictions)
unlink(modelPath)
-
+# $example off:read_write$
############################ fit models with spark.lapply #####################################
# Perform distributed training of multiple models with spark.lapply