spark.mlp {SparkR} | R Documentation |

`spark.mlp`

fits a multi-layer perceptron neural network model against a SparkDataFrame.
Users can call `summary`

to print a summary of the fitted model, `predict`

to make
predictions on new data, and `write.ml`

/`read.ml`

to save/load fitted models.
Only categorical data is supported.
For more details, see
Multilayer Perceptron

spark.mlp(data, formula, ...) ## S4 method for signature 'SparkDataFrame,formula' spark.mlp(data, formula, layers, blockSize = 128, solver = "l-bfgs", maxIter = 100, tol = 1e-06, stepSize = 0.03, seed = NULL, initialWeights = NULL) ## S4 method for signature 'MultilayerPerceptronClassificationModel' predict(object, newData) ## S4 method for signature 'MultilayerPerceptronClassificationModel' summary(object) ## S4 method for signature 'MultilayerPerceptronClassificationModel,character' write.ml(object, path, overwrite = FALSE)

`data` |
a |

`formula` |
a symbolic description of the model to be fitted. Currently only a few formula operators are supported, including '~', '.', ':', '+', and '-'. |

`...` |
additional arguments passed to the method. |

`layers` |
integer vector containing the number of nodes for each layer. |

`blockSize` |
blockSize parameter. |

`solver` |
solver parameter, supported options: "gd" (minibatch gradient descent) or "l-bfgs". |

`maxIter` |
maximum iteration number. |

`tol` |
convergence tolerance of iterations. |

`stepSize` |
stepSize parameter. |

`seed` |
seed parameter for weights initialization. |

`initialWeights` |
initialWeights parameter for weights initialization, it should be a numeric vector. |

`object` |
a Multilayer Perceptron Classification Model fitted by |

`newData` |
a SparkDataFrame for testing. |

`path` |
the directory where the model is saved. |

`overwrite` |
overwrites or not if the output path already exists. Default is FALSE which means throw exception if the output path exists. |

`spark.mlp`

returns a fitted Multilayer Perceptron Classification Model.

`predict`

returns a SparkDataFrame containing predicted labeled in a column named
"prediction".

`summary`

returns summary information of the fitted model, which is a list.
The list includes `numOfInputs`

(number of inputs), `numOfOutputs`

(number of outputs), `layers`

(array of layer sizes including input
and output layers), and `weights`

(the weights of layers).
For `weights`

, it is a numeric vector with length equal to the expected
given the architecture (i.e., for 8-10-2 network, 112 connection weights).

spark.mlp since 2.1.0

predict(MultilayerPerceptronClassificationModel) since 2.1.0

summary(MultilayerPerceptronClassificationModel) since 2.1.0

write.ml(MultilayerPerceptronClassificationModel, character) since 2.1.0

```
## Not run:
##D df <- read.df("data/mllib/sample_multiclass_classification_data.txt", source = "libsvm")
##D
##D # fit a Multilayer Perceptron Classification Model
##D model <- spark.mlp(df, label ~ features, blockSize = 128, layers = c(4, 3), solver = "l-bfgs",
##D maxIter = 100, tol = 0.5, stepSize = 1, seed = 1,
##D initialWeights = c(0, 0, 0, 0, 0, 5, 5, 5, 5, 5, 9, 9, 9, 9, 9))
##D
##D # get the summary of the model
##D summary(model)
##D
##D # make predictions
##D predictions <- predict(model, df)
##D
##D # save and load the model
##D path <- "path/to/model"
##D write.ml(model, path)
##D savedModel <- read.ml(path)
##D summary(savedModel)
## End(Not run)
```

[Package *SparkR* version 2.1.2 Index]