 Estimator - Maple Help

DeepLearning

 Estimator
 estimator object Description

 • An Estimator is an object which encapsulates a high-level interface which encapsulates tasks for training, evaluation, and prediction with machine learning models. Generating Estimators

 • To construct an Estimator object encapsulating a certain classification or regression task, see the DeepLearning Overview section on Estimators. Operations with Estimators

 • The following functions can be performed with an Estimator. Examples

Train a deep neural network classifier to recognize whether a point is within a circle centered at the origin with radius 1. We begin by generating some input data to train the model.

 > $N≔1000:$
 > $X≔\mathrm{Statistics}:-\mathrm{RandomVariable}\left('\mathrm{Uniform}\left(-1.,1.\right)'\right):$
 > $\mathrm{training_data}≔\mathrm{DataFrame}\left(\mathrm{Statistics}:-\mathrm{Sample}\left(X,\left[N,2\right]\right),\mathrm{columns}=\left["x","y"\right]\right):$
 > $\mathrm{class}≔\mathrm{DataSeries}\left(⟨\mathrm{seq}\left(\mathrm{if}\left({\mathrm{training_data}\left["x"\right]\left[i\right]}^{2}+{\mathrm{training_data}\left["y"\right]\left[i\right]}^{2}<1,1,0\right),i=1..N\right)⟩\right):$

We can now define an Estimator, in this case a DNNClassifier, to process the input.

 > $\mathrm{with}\left(\mathrm{DeepLearning}\right):$
 > $\mathrm{fc}≔\left[\mathrm{seq}\left(\mathrm{NumericColumn}\left(u,\mathrm{shape}=\left[1\right]\right),u\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{in}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\left["x","y"\right]\right)\right]$
 ${\mathrm{fc}}{≔}\left[\left[\begin{array}{c}{\mathrm{Feature Column}}\\ {\mathrm{NumericColumn\left(key=\text{'}x\text{'}, shape=\left(1,\right), default_value=None, dtype=tf.float32, normalizer_fn=None\right)}}\end{array}\right]{,}\left[\begin{array}{c}{\mathrm{Feature Column}}\\ {\mathrm{NumericColumn\left(key=\text{'}y\text{'}, shape=\left(1,\right), default_value=None, dtype=tf.float32, normalizer_fn=None\right)}}\end{array}\right]\right]$ (1)
 > $\mathrm{classifier}≔\mathrm{DNNClassifier}\left(\mathrm{fc},\mathrm{hidden_units}=\left[10,20,10\right],\mathrm{num_classes}=2\right)$
 ${\mathrm{classifier}}{≔}\left[\begin{array}{c}{\mathrm{DeepLearning Estimator}}\\ {\mathrm{}}\end{array}\right]$ (2)
 > $\mathrm{classifier}:-\mathrm{Train}\left(\mathrm{training_data},\mathrm{class},\mathrm{steps}=2000,\mathrm{num_epochs}=\mathrm{none},\mathrm{shuffle}=\mathrm{true}\right)$
 $\left[\begin{array}{c}{\mathrm{DeepLearning Tensor}}\\ {\mathrm{Name: none}}\\ {\mathrm{Shape: undefined}}\\ {\mathrm{Data Type: undefined}}\end{array}\right]$ (3)

With our classifier thus trained, we can make predictions about additional points.

 > $\mathrm{test_data}≔\mathrm{DataFrame}\left(\mathrm{Statistics}:-\mathrm{Sample}\left(X,\left[5,2\right]\right),\mathrm{columns}=\left["x","y"\right]\right):$
 > $\mathrm{result}≔\mathrm{classifier}:-\mathrm{Predict}\left(\mathrm{test_data},\mathrm{num_epochs}=1,\mathrm{shuffle}=\mathrm{false}\right):$ Compatibility

 • The DeepLearning[Estimator] command was introduced in Maple 2018.