aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authoractuaryzhang <actuaryzhang10@gmail.com>2017-04-07 10:57:12 -0700
committerFelix Cheung <felixcheung@apache.org>2017-04-07 10:57:12 -0700
commit870b9d9aa00c260b532c78088e4a0384f7f1fa8a (patch)
treed54b04259989b1cf15e3cc1b3e0874943fafb81a /examples
parent9e0893b53d68f777c1f3fb0a67820424a9c253ab (diff)
downloadspark-870b9d9aa00c260b532c78088e4a0384f7f1fa8a.tar.gz
spark-870b9d9aa00c260b532c78088e4a0384f7f1fa8a.tar.bz2
spark-870b9d9aa00c260b532c78088e4a0384f7f1fa8a.zip
[SPARK-20026][DOC][SPARKR] Add Tweedie example for SparkR in programming guide
## What changes were proposed in this pull request? Add Tweedie example for SparkR in programming guide. The doc was already updated in #17103. Author: actuaryzhang <actuaryzhang10@gmail.com> Closes #17553 from actuaryzhang/programGuide.
Diffstat (limited to 'examples')
-rw-r--r--examples/src/main/r/ml/glm.R9
1 files changed, 9 insertions, 0 deletions
diff --git a/examples/src/main/r/ml/glm.R b/examples/src/main/r/ml/glm.R
index ee13910382..23141b57df 100644
--- a/examples/src/main/r/ml/glm.R
+++ b/examples/src/main/r/ml/glm.R
@@ -56,6 +56,15 @@ summary(binomialGLM)
# Prediction
binomialPredictions <- predict(binomialGLM, binomialTestDF)
head(binomialPredictions)
+
+# Fit a generalized linear model of family "tweedie" with spark.glm
+training3 <- read.df("data/mllib/sample_multiclass_classification_data.txt", source = "libsvm")
+tweedieDF <- transform(training3, label = training3$label * exp(randn(10)))
+tweedieGLM <- spark.glm(tweedieDF, label ~ features, family = "tweedie",
+ var.power = 1.2, link.power = 0)
+
+# Model summary
+summary(tweedieGLM)
# $example off$
sparkR.session.stop()