How to do it...

Perform the following steps to generate two different classification examples with different costs:

  1. Subset the iris dataset with columns named as Sepal.Length, Sepal.Width, Species, with species in setosa and virginica:
        > iris.subset = subset(iris, select=c("Sepal.Length",         "Sepal.Width", "Species"), Species %in% c("setosa","virginica"))
  1. Then, you can generate a scatter plot with Sepal.Length as the x-axis and the Sepal.Width as the y-axis:
        > plot(x=iris.subset$Sepal.Length,y=iris.subset$Sepal.Width,        col=iris.subset$Species, pch=19)
Scatter plot of Sepal.Length and Sepal.Width with subset of iris dataset
  1. Next, you can ...

Get Machine Learning with R Cookbook - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.