Skip to content
Snippets Groups Projects
Commit 988f6d7e authored by Felix Cheung's avatar Felix Cheung Committed by Felix Cheung
Browse files

[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.
parent b4065983
No related branches found
No related tags found
No related merge requests found
Showing with 46 additions and 18 deletions
......@@ -41,5 +41,7 @@ summary(model)
# Prediction
predictions <- predict(model, test)
showDF(predictions)
head(predictions)
# $example off$
sparkR.session.stop()
......@@ -40,3 +40,5 @@ summary(fitted.model)
fitted <- predict(model, df)
head(select(fitted, "Sepal_Length", "prediction"))
# $example off$
sparkR.session.stop()
......@@ -38,5 +38,7 @@ summary(model)
# Prediction
predictions <- predict(model, test)
showDF(predictions)
head(predictions)
# $example off$
sparkR.session.stop()
......@@ -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()
......@@ -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()
......@@ -38,5 +38,7 @@ summary(model)
# Prediction
predictions <- predict(model, test)
showDF(predictions)
head(predictions)
# $example off$
sparkR.session.stop()
......@@ -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()
......@@ -37,3 +37,5 @@ model <- spark.kstest(df, "test", "norm")
# Model summary
summary(model)
# $example off$
sparkR.session.stop()
......@@ -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()
......@@ -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()
......@@ -42,7 +42,7 @@ summary(gaussianGLM2)
# Check model prediction
gaussianPredictions <- predict(gaussianGLM2, gaussianTestDF)
showDF(gaussianPredictions)
head(gaussianPredictions)
unlink(modelPath)
# $example off:read_write$
......
......@@ -44,5 +44,7 @@ summary(model)
# Prediction
predictions <- predict(model, test)
showDF(predictions)
head(predictions)
# $example off$
sparkR.session.stop()
......@@ -37,5 +37,7 @@ summary(nbModel)
# Prediction
nbPredictions <- predict(nbModel, nbTestDF)
showDF(nbPredictions)
head(nbPredictions)
# $example off$
sparkR.session.stop()
......@@ -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()
......@@ -39,5 +39,7 @@ summary(aftModel)
# Prediction
aftPredictions <- predict(aftModel, aftTestDF)
showDF(aftPredictions)
head(aftPredictions)
# $example off$
sparkR.session.stop()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment