Learn R Programming

gencve (version 0.3)

rmix: Random Mixture Classification Example

Description

Generates a random mixture for binary class prediction with output variable green and red factors and with two inputs x1 and x2. Similar to the mixture dataset in ESL.

Usage

rmix(n = 100)

Arguments

n
Sample size, should be even number, n/2 green and n/2 red.

Value

dataframe with columns x1, x2, y

Details

The optimal Bayes error rate is 20.76

References

ESL. Hastie, Tibshirani and Friedman (2009). The Elements of Statistical Learning. 2nd Ed. Springer.

See Also

rxor, rdigitsBFOS, ShaoReg

Examples

Run this code
mdf <- rmix(200)
gr <- mdf[mdf$y=="green",]
rd <- mdf[mdf$y=="red",]
with(mdf, {plot(x1, x2, type="n")
  points(gr, col="green")
  points(rd, col="red")
  })

Run the code above in your browser using DataLab