From 2ad031be67c7a0f0c4895c084c891330a9ec935e Mon Sep 17 00:00:00 2001 From: Yanbo Liang Date: Mon, 11 Jul 2016 14:31:11 -0700 Subject: [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 Closes #14011 from yanboliang/r-user-guide-update. --- examples/src/main/r/ml.R | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'examples') 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 -- cgit v1.2.3