Icon

Iris_​Classification_​with_​ANN

Classifying the iris dataset with ANN 4-3-1

Exercise of the L4-DL Introduction to Deep Learning Course.

The goal is to train a multilayer Perceptron with 4-8-3 layers, using BackPropagation, to classify the Iris dataset.




Use Case DescriptionThe iris dataset contains 4 numerical features (sepal length, sepal width, petal length, & petal width). Our goal is to use these features to classify irises into 3 categories (setosa, versicolor, &virginica). We do so by creating a Keras network model with 3 layers, with 4-8-3 units. Iris classification with ANNThe Data Preparation & Partition metanode preprocesses and partitions data (75% training, 25% testing). The target is coded numericallyas 1, 2, and 3, corresponding to setosa, virginica and versicolor, respectively.1). Build a network with 4-8-3 units.-The first (input) layer with a Keras Input Layer node with 4 units (Shape), corresponding to the input features.-The second (hidden) layer with a Keras Dense Layer node, with 8 units and the ReLU activation function (Activation function).-The last (output) layer with a Keras Dense Layer node, with 3 units and the Softmax activation function2). Train the Keras network with a Keras Network Learner node. -Connect the network output port (red square) of the output node of your network to the network input node (red square) of the KerasNetwork Learner node. Connect the training set to the input port (black triangle)-Under the Input Data tab, the Conversion is From Number (double). The four numerical features should be used as the input. -Under the Target Data tab, the Conversion is From Collection of Number (integer) to One-Hot Tensor, with class_collection as the Targetcolumn. From the Standard loss function, select Categorical cross entropy from the pull-down menu.-Under Options tab, set Epochs to 100, and Training batch size to 5. Select Adam from Optimizer pull-down menu.-While the network trains, right click the node and open the Learning Monitor. Observe how the accuracy and loss change as the networkis being trained. 3). Apply the trained network model to the testing data with a Keras NetworkExecutor node. -Connect the network output from the Learner node to the Executor node, as well as the trainingset from the metanode.-Check Keep input columns in output table.-As for the Inputs, the Conversion is From Number (double), with the 4 numeric input features.-For the Outputs, click on the add output button. The network output layer is selected by default.The Conversion is To Number (double). The Output column prefix are appended to the outputcolumn names.4). Convert the network output to a categorical variable.-The three output columns generated by the network model represent the class probabilities forthree categories. The columns are in the order of 0: setosa, 1: virginica, and 2: versicolor. Thepredicted class is the one with the highest probability among the three. Use a Rule Engine node tocreate an integer column with the predicted class.5). Assess the prediction accuracy using a Scorer node. -Compare the target column vs. the prediction from the network Training thenetwork100 epochsBatch size 5Adam optimizerApply trained networkHidden layer8 unitsReLUOutput layer 3 unitSoftmaxInput layer 4 unitsExtract predictionTransform classto integerPartition 75% - 25%NormalizationReading the iris datasetExamining theaccuracyKeras NetworkLearner Keras NetworkExecutor Keras Dense Layer Keras Dense Layer Keras Input Layer Rule Engine Data Preparation& Partition Table Reader Scorer Use Case DescriptionThe iris dataset contains 4 numerical features (sepal length, sepal width, petal length, & petal width). Our goal is to use these features to classify irises into 3 categories (setosa, versicolor, &virginica). We do so by creating a Keras network model with 3 layers, with 4-8-3 units. Iris classification with ANNThe Data Preparation & Partition metanode preprocesses and partitions data (75% training, 25% testing). The target is coded numericallyas 1, 2, and 3, corresponding to setosa, virginica and versicolor, respectively.1). Build a network with 4-8-3 units.-The first (input) layer with a Keras Input Layer node with 4 units (Shape), corresponding to the input features.-The second (hidden) layer with a Keras Dense Layer node, with 8 units and the ReLU activation function (Activation function).-The last (output) layer with a Keras Dense Layer node, with 3 units and the Softmax activation function2). Train the Keras network with a Keras Network Learner node. -Connect the network output port (red square) of the output node of your network to the network input node (red square) of the KerasNetwork Learner node. Connect the training set to the input port (black triangle)-Under the Input Data tab, the Conversion is From Number (double). The four numerical features should be used as the input. -Under the Target Data tab, the Conversion is From Collection of Number (integer) to One-Hot Tensor, with class_collection as the Targetcolumn. From the Standard loss function, select Categorical cross entropy from the pull-down menu.-Under Options tab, set Epochs to 100, and Training batch size to 5. Select Adam from Optimizer pull-down menu.-While the network trains, right click the node and open the Learning Monitor. Observe how the accuracy and loss change as the networkis being trained. 3). Apply the trained network model to the testing data with a Keras NetworkExecutor node. -Connect the network output from the Learner node to the Executor node, as well as the trainingset from the metanode.-Check Keep input columns in output table.-As for the Inputs, the Conversion is From Number (double), with the 4 numeric input features.-For the Outputs, click on the add output button. The network output layer is selected by default.The Conversion is To Number (double). The Output column prefix are appended to the outputcolumn names.4). Convert the network output to a categorical variable.-The three output columns generated by the network model represent the class probabilities forthree categories. The columns are in the order of 0: setosa, 1: virginica, and 2: versicolor. Thepredicted class is the one with the highest probability among the three. Use a Rule Engine node tocreate an integer column with the predicted class.5). Assess the prediction accuracy using a Scorer node. -Compare the target column vs. the prediction from the network Training thenetwork100 epochsBatch size 5Adam optimizerApply trained networkHidden layer8 unitsReLUOutput layer 3 unitSoftmaxInput layer 4 unitsExtract predictionTransform classto integerPartition 75% - 25%NormalizationReading the iris datasetExamining theaccuracyKeras NetworkLearner Keras NetworkExecutor Keras Dense Layer Keras Dense Layer Keras Input Layer Rule Engine Data Preparation& Partition Table Reader Scorer

Nodes

Extensions

Links