We’ll predict the class of flowers based on the petal length and petal width using R.
Install the necessary packages:
Load the dataset and display the structure of the dataset:
Use set.seed() to determine the starting point used in the generation of a sequence of random numbers:
Build your model using ‘rpart‘ function:
Let’s validate the data using the remaining 50 rows we kept as testing data:
Install the packages required to use “ConfusionMatrix” to evaluate the model:
We have an accuracy of 92 percent.