aboutsummaryrefslogtreecommitdiff
path: root/examples/src
diff options
context:
space:
mode:
authorFelix Cheung <felixcheung_m@hotmail.com>2017-02-17 13:30:55 -0800
committerFelix Cheung <felixcheung@apache.org>2017-02-17 13:30:55 -0800
commit988f6d7ee8017756645f2af9993ee020332442cb (patch)
tree9ad0622c7eb7d9fc0e32ee32eb1682fb95966986 /examples/src
parentb40659838245ecaefb4e83d2ec6155f3f23a6675 (diff)
downloadspark-988f6d7ee8017756645f2af9993ee020332442cb.tar.gz
spark-988f6d7ee8017756645f2af9993ee020332442cb.tar.bz2
spark-988f6d7ee8017756645f2af9993ee020332442cb.zip
[SPARKR][EXAMPLES] update examples to stop spark session
## What changes were proposed in this pull request? stop session at end of example ## How was this patch tested? manual Author: Felix Cheung <felixcheung_m@hotmail.com> Closes #16973 from felixcheung/rexamples.
Diffstat (limited to 'examples/src')
-rw-r--r--examples/src/main/r/ml/als.R4
-rw-r--r--examples/src/main/r/ml/bisectingKmeans.R2
-rw-r--r--examples/src/main/r/ml/gaussianMixture.R4
-rw-r--r--examples/src/main/r/ml/gbt.R6
-rw-r--r--examples/src/main/r/ml/glm.R6
-rw-r--r--examples/src/main/r/ml/isoreg.R4
-rw-r--r--examples/src/main/r/ml/kmeans.R6
-rw-r--r--examples/src/main/r/ml/kstest.R2
-rw-r--r--examples/src/main/r/ml/lda.R4
-rw-r--r--examples/src/main/r/ml/logit.R6
-rw-r--r--examples/src/main/r/ml/ml.R2
-rw-r--r--examples/src/main/r/ml/mlp.R4
-rw-r--r--examples/src/main/r/ml/naiveBayes.R4
-rw-r--r--examples/src/main/r/ml/randomForest.R6
-rw-r--r--examples/src/main/r/ml/survreg.R4
15 files changed, 46 insertions, 18 deletions
diff --git a/examples/src/main/r/ml/als.R b/examples/src/main/r/ml/als.R
index 383bbba190..4d1c91add5 100644
--- a/examples/src/main/r/ml/als.R
+++ b/examples/src/main/r/ml/als.R
@@ -41,5 +41,7 @@ summary(model)
# Prediction
predictions <- predict(model, test)
-showDF(predictions)
+head(predictions)
# $example off$
+
+sparkR.session.stop()
diff --git a/examples/src/main/r/ml/bisectingKmeans.R b/examples/src/main/r/ml/bisectingKmeans.R
index 37aeb74fc7..5fb5bfb0fa 100644
--- a/examples/src/main/r/ml/bisectingKmeans.R
+++ b/examples/src/main/r/ml/bisectingKmeans.R
@@ -40,3 +40,5 @@ summary(fitted.model)
fitted <- predict(model, df)
head(select(fitted, "Sepal_Length", "prediction"))
# $example off$
+
+sparkR.session.stop()
diff --git a/examples/src/main/r/ml/gaussianMixture.R b/examples/src/main/r/ml/gaussianMixture.R
index 54b69acc83..558e44cc11 100644
--- a/examples/src/main/r/ml/gaussianMixture.R
+++ b/examples/src/main/r/ml/gaussianMixture.R
@@ -38,5 +38,7 @@ summary(model)
# Prediction
predictions <- predict(model, test)
-showDF(predictions)
+head(predictions)
# $example off$
+
+sparkR.session.stop()
diff --git a/examples/src/main/r/ml/gbt.R b/examples/src/main/r/ml/gbt.R
index be16c2aa66..bc654f1df7 100644
--- a/examples/src/main/r/ml/gbt.R
+++ b/examples/src/main/r/ml/gbt.R
@@ -40,7 +40,7 @@ summary(model)
# Prediction
predictions <- predict(model, test)
-showDF(predictions)
+head(predictions)
# $example off:classification$
# GBT regression model
@@ -59,5 +59,7 @@ summary(model)
# Prediction
predictions <- predict(model, test)
-showDF(predictions)
+head(predictions)
# $example off:regression$
+
+sparkR.session.stop()
diff --git a/examples/src/main/r/ml/glm.R b/examples/src/main/r/ml/glm.R
index 599071790a..e41af97751 100644
--- a/examples/src/main/r/ml/glm.R
+++ b/examples/src/main/r/ml/glm.R
@@ -36,7 +36,7 @@ summary(gaussianGLM)
# Prediction
gaussianPredictions <- predict(gaussianGLM, gaussianTestDF)
-showDF(gaussianPredictions)
+head(gaussianPredictions)
# Fit a generalized linear model with glm (R-compliant)
gaussianGLM2 <- glm(Sepal_Length ~ Sepal_Width + Species, gaussianDF, family = "gaussian")
@@ -53,5 +53,7 @@ summary(binomialGLM)
# Prediction
binomialPredictions <- predict(binomialGLM, binomialTestDF)
-showDF(binomialPredictions)
+head(binomialPredictions)
# $example off$
+
+sparkR.session.stop()
diff --git a/examples/src/main/r/ml/isoreg.R b/examples/src/main/r/ml/isoreg.R
index 75dce97ed9..a53c83eac4 100644
--- a/examples/src/main/r/ml/isoreg.R
+++ b/examples/src/main/r/ml/isoreg.R
@@ -38,5 +38,7 @@ summary(model)
# Prediction
predictions <- predict(model, test)
-showDF(predictions)
+head(predictions)
# $example off$
+
+sparkR.session.stop()
diff --git a/examples/src/main/r/ml/kmeans.R b/examples/src/main/r/ml/kmeans.R
index 043b21b038..288e2f9724 100644
--- a/examples/src/main/r/ml/kmeans.R
+++ b/examples/src/main/r/ml/kmeans.R
@@ -36,9 +36,11 @@ kmeansModel <- spark.kmeans(kmeansDF, ~ Sepal_Length + Sepal_Width + Petal_Lengt
summary(kmeansModel)
# Get fitted result from the k-means model
-showDF(fitted(kmeansModel))
+head(fitted(kmeansModel))
# Prediction
kmeansPredictions <- predict(kmeansModel, kmeansTestDF)
-showDF(kmeansPredictions)
+head(kmeansPredictions)
# $example off$
+
+sparkR.session.stop()
diff --git a/examples/src/main/r/ml/kstest.R b/examples/src/main/r/ml/kstest.R
index 12625f7d3e..e2b07702b6 100644
--- a/examples/src/main/r/ml/kstest.R
+++ b/examples/src/main/r/ml/kstest.R
@@ -37,3 +37,5 @@ model <- spark.kstest(df, "test", "norm")
# Model summary
summary(model)
# $example off$
+
+sparkR.session.stop()
diff --git a/examples/src/main/r/ml/lda.R b/examples/src/main/r/ml/lda.R
index 7b187d155a..769be0a78d 100644
--- a/examples/src/main/r/ml/lda.R
+++ b/examples/src/main/r/ml/lda.R
@@ -38,9 +38,11 @@ summary(model)
# Posterior probabilities
posterior <- spark.posterior(model, test)
-showDF(posterior)
+head(posterior)
# The log perplexity of the LDA model
logPerplexity <- spark.perplexity(model, test)
print(paste0("The upper bound bound on perplexity: ", logPerplexity))
# $example off$
+
+sparkR.session.stop()
diff --git a/examples/src/main/r/ml/logit.R b/examples/src/main/r/ml/logit.R
index a2ac882ed0..4c8fd428d3 100644
--- a/examples/src/main/r/ml/logit.R
+++ b/examples/src/main/r/ml/logit.R
@@ -40,7 +40,7 @@ summary(model)
# Prediction
predictions <- predict(model, test)
-showDF(predictions)
+head(predictions)
# $example off:binomial$
# Multinomial logistic regression
@@ -59,5 +59,7 @@ summary(model)
# Prediction
predictions <- predict(model, test)
-showDF(predictions)
+head(predictions)
# $example off:multinomial$
+
+sparkR.session.stop()
diff --git a/examples/src/main/r/ml/ml.R b/examples/src/main/r/ml/ml.R
index 05f5199aeb..b96819418b 100644
--- a/examples/src/main/r/ml/ml.R
+++ b/examples/src/main/r/ml/ml.R
@@ -42,7 +42,7 @@ summary(gaussianGLM2)
# Check model prediction
gaussianPredictions <- predict(gaussianGLM2, gaussianTestDF)
-showDF(gaussianPredictions)
+head(gaussianPredictions)
unlink(modelPath)
# $example off:read_write$
diff --git a/examples/src/main/r/ml/mlp.R b/examples/src/main/r/ml/mlp.R
index d28fc069bd..b69ac845f2 100644
--- a/examples/src/main/r/ml/mlp.R
+++ b/examples/src/main/r/ml/mlp.R
@@ -44,5 +44,7 @@ summary(model)
# Prediction
predictions <- predict(model, test)
-showDF(predictions)
+head(predictions)
# $example off$
+
+sparkR.session.stop()
diff --git a/examples/src/main/r/ml/naiveBayes.R b/examples/src/main/r/ml/naiveBayes.R
index 9c416599b4..da69e93ef2 100644
--- a/examples/src/main/r/ml/naiveBayes.R
+++ b/examples/src/main/r/ml/naiveBayes.R
@@ -37,5 +37,7 @@ summary(nbModel)
# Prediction
nbPredictions <- predict(nbModel, nbTestDF)
-showDF(nbPredictions)
+head(nbPredictions)
# $example off$
+
+sparkR.session.stop()
diff --git a/examples/src/main/r/ml/randomForest.R b/examples/src/main/r/ml/randomForest.R
index d1b96b62a0..5d99502cd9 100644
--- a/examples/src/main/r/ml/randomForest.R
+++ b/examples/src/main/r/ml/randomForest.R
@@ -40,7 +40,7 @@ summary(model)
# Prediction
predictions <- predict(model, test)
-showDF(predictions)
+head(predictions)
# $example off:classification$
# Random forest regression model
@@ -59,5 +59,7 @@ summary(model)
# Prediction
predictions <- predict(model, test)
-showDF(predictions)
+head(predictions)
# $example off:regression$
+
+sparkR.session.stop()
diff --git a/examples/src/main/r/ml/survreg.R b/examples/src/main/r/ml/survreg.R
index f728b8b5d8..bf6c0a1619 100644
--- a/examples/src/main/r/ml/survreg.R
+++ b/examples/src/main/r/ml/survreg.R
@@ -39,5 +39,7 @@ summary(aftModel)
# Prediction
aftPredictions <- predict(aftModel, aftTestDF)
-showDF(aftPredictions)
+head(aftPredictions)
# $example off$
+
+sparkR.session.stop()