Github user mengxr commented on a diff in the pull request:
https://github.com/apache/spark/pull/13000#discussion_r63997601
--- Diff: examples/src/main/r/ml.R ---
@@ -25,30 +25,102 @@ library(SparkR)
sc <- sparkR.init(appName="SparkR-ML-example")
sqlContext <- sparkRSQL.init(sc)
-# Train GLM of family 'gaussian'
+############################ spark.glm and glm
##############################################
+
+# Fit a generalized linear model with spark.glm
training1 <- suppressWarnings(createDataFrame(sqlContext, iris))
test1 <- training1
-model1 <- glm(Sepal_Length ~ Sepal_Width + Species, training1, family =
"gaussian")
+model1 <- spark.glm(training1, Sepal_Length ~ Sepal_Width + Species,
family = "gaussian")
# Model summary
summary(model1)
# Prediction
predictions1 <- predict(model1, test1)
-head(select(predictions1, "Sepal_Length", "prediction"))
+showDF(predictions1)
+
+# Fit a generalized linear model with glm (R-compliant)
+sameModel <- glm(Sepal_Length ~ Sepal_Width + Species, training1, family =
"gaussian")
+summary(sameModel)
+
+############################ spark.survreg
##############################################
+
+# Use the ovarian dataset available in R survival package
+library(survival)
-# Train GLM of family 'binomial'
-training2 <- filter(training1, training1$Species != "setosa")
+# Fit an accelerated failure time (AFT) survival regression model with
spark.survreg
+training2 <- suppressWarnings(createDataFrame(sqlContext, ovarian))
test2 <- training2
-model2 <- glm(Species ~ Sepal_Length + Sepal_Width, data = training2,
family = "binomial")
--- End diff --
+1
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]