diff options
author | wm624@hotmail.com <wm624@hotmail.com> | 2017-02-17 21:21:10 -0800 |
---|---|---|
committer | Felix Cheung <felixcheung@apache.org> | 2017-02-17 21:21:10 -0800 |
commit | 8b57ea4a1e582d24baf37df3eb148804d83cf767 (patch) | |
tree | 303be3de6d56f0370034d27e00dabb97ada61785 /R/pkg/vignettes/sparkr-vignettes.Rmd | |
parent | 15b144d2bf4555981a51276277c08a9c11a402f6 (diff) | |
download | spark-8b57ea4a1e582d24baf37df3eb148804d83cf767.tar.gz spark-8b57ea4a1e582d24baf37df3eb148804d83cf767.tar.bz2 spark-8b57ea4a1e582d24baf37df3eb148804d83cf767.zip |
[SPARK-19639][SPARKR][EXAMPLE] Add spark.svmLinear example and update vignettes
## What changes were proposed in this pull request?
We recently add the spark.svmLinear API for SparkR. We need to add an example and update the vignettes.
## How was this patch tested?
Manually run example.
Author: wm624@hotmail.com <wm624@hotmail.com>
Closes #16969 from wangmiao1981/example.
Diffstat (limited to 'R/pkg/vignettes/sparkr-vignettes.Rmd')
-rw-r--r-- | R/pkg/vignettes/sparkr-vignettes.Rmd | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/R/pkg/vignettes/sparkr-vignettes.Rmd b/R/pkg/vignettes/sparkr-vignettes.Rmd index a742484c4c..bc8bc3c26c 100644 --- a/R/pkg/vignettes/sparkr-vignettes.Rmd +++ b/R/pkg/vignettes/sparkr-vignettes.Rmd @@ -469,6 +469,8 @@ SparkR supports the following machine learning models and algorithms. #### Classification +* Linear Support Vector Machine (SVM) Classifier + * Logistic Regression * Multilayer Perceptron (MLP) @@ -532,6 +534,26 @@ head(carsDF_test) ### Models and Algorithms +#### Linear Support Vector Machine (SVM) Classifier + +[Linear Support Vector Machine (SVM)](https://en.wikipedia.org/wiki/Support_vector_machine#Linear_SVM) classifier is an SVM classifier with linear kernels. +This is a binary classifier. We use a simple example to show how to use `spark.svmLinear` +for binary classification. + +```{r} +# load training data and create a DataFrame +t <- as.data.frame(Titanic) +training <- createDataFrame(t) +# fit a Linear SVM classifier model +model <- spark.svmLinear(training, Survived ~ ., regParam = 0.01, maxIter = 10) +summary(model) +``` + +Predict values on training data +```{r} +prediction <- predict(model, training) +``` + #### Logistic Regression [Logistic regression](https://en.wikipedia.org/wiki/Logistic_regression) is a widely-used model when the response is categorical. It can be seen as a special case of the [Generalized Linear Predictive Model](https://en.wikipedia.org/wiki/Generalized_linear_model). |