-
See Also
- Classify
- Predict
- NetTrain
- ClassifierFunction
- PredictorFunction
- ClassifierMeasurements
- PredictorMeasurements
- SequencePredict
- ClusterClassify
-
- Methods
- DecisionTree
- LinearRegression
- LogisticRegression
- GaussianProcess
- GradientBoostedTrees
- Markov
- NaiveBayes
- NearestNeighbors
- RandomForest
- SupportVectorMachine
-
-
See Also
- Classify
- Predict
- NetTrain
- ClassifierFunction
- PredictorFunction
- ClassifierMeasurements
- PredictorMeasurements
- SequencePredict
- ClusterClassify
-
- Methods
- DecisionTree
- LinearRegression
- LogisticRegression
- GaussianProcess
- GradientBoostedTrees
- Markov
- NaiveBayes
- NearestNeighbors
- RandomForest
- SupportVectorMachine
-
See Also
"NeuralNetwork" (Machine Learning Method)
Details & Suboptions
- A neural network consists of stacked layers, each performing a simple computation. Information is processed layer by layer from the input layer to the output layer. The neural network is trained to minimize a loss function on the training set using gradient descent.
- The following options can be given:
-
MaxTrainingRounds Automatic maximum number of iterations over the dataset "NetworkDepth" Automatic the depth of the network - The option "NetworkDepth" controls the capacity of the network. A deeper network will be able to fit more complex patterns but will be more prone to overfitting.
- The option MaxTrainingRounds can be used to speed up the training but also as a regularization parameter: setting a lower value can prevent overfitting.
Examples
open all close allBasic Examples (2)
Train a classifier function on labeled examples:
c = Classify[{1, 2, 3, 4} -> {"A", "A", "B", "B"}, Method -> "NeuralNetwork"]Obtain information about the classifier:
Information[c]c[1.3]Generate some data and visualize it:
data = Table[x -> x + RandomVariate[NormalDistribution[0, 2]], {x, RandomReal[{-5, 5}, 100]}];
ListPlot[List@@@data]Train a predictor function on it:
p = Predict[data, Method -> "NeuralNetwork"]Compare the data with the predicted values and look at the standard deviation:
Show[Plot[{p[x],
p[x] + StandardDeviation[p[x, "Distribution"]], p[x] - StandardDeviation[p[x, "Distribution"]]},
{x, -5, 5},
PlotStyle -> {Blue, Gray, Gray},
Filling -> {2 -> {3}},
Exclusions -> False,
PerformanceGoal -> "Speed", PlotLegends -> {"Prediction", "Confidence Interval"}], ListPlot[List@@@data, PlotStyle -> Red, PlotLegends -> {"Data"}]]Options (2)
MaxTrainingRounds (1)
Generate a training set and visualize it:
trainingdata = Table[x -> Sin[x] + RandomVariate[NormalDistribution[0, .3]], {x, RandomReal[{-5, 5}, 50] }];
ListPlot[List@@@trainingdata]Train two predictors using different MaxTrainingRounds and compare their performances on the training set:
{p1, p2, p3} = Predict[trainingdata, Method -> {"NeuralNetwork", MaxTrainingRounds -> #}]& /@ {20, 100, 500};Show[ListPlot[List@@@trainingdata], Plot[{p1[x], p2[x], p3[x]}, {x, -10, 10}, PlotLegends -> {20, 100, 500}]]"NetworkDepth" (1)
Use the "NetworkDepth" suboption to specify the number of units in the neural network:
pr1 = Predict[{1, 2, 3, 4, 5} -> {1, 2, 3, 4, 5}, Method -> {"NeuralNetwork", "NetworkDepth" -> 1}]Train a second PredictorFunction by changing the "NetworkDepth":
pr4 = Predict[{1, 2, 3, 4, 5} -> {1, 2, 3, 4, 5}, Method -> {"NeuralNetwork", "NetworkDepth" -> 4}]Show[Plot[{pr1[x], pr4[x]}, {x, 0, 6}], ListPlot[Transpose[{{1, 2, 3, 4, 5}, {1, 2, 3, 4, 5}}]]]See Also
Classify Predict NetTrain ClassifierFunction PredictorFunction ClassifierMeasurements PredictorMeasurements SequencePredict ClusterClassify
Methods: DecisionTree LinearRegression LogisticRegression GaussianProcess GradientBoostedTrees Markov NaiveBayes NearestNeighbors RandomForest SupportVectorMachine