Description Usage Arguments Details Value Author(s) See Also Examples

View source: R/assess.glmnet.R

Given a test set, produce summary performance measures for the glmnet model(s)

1 2 3 4 5 6 7 8 | ```
assess.glmnet(object, newx = NULL, newy, weights = NULL,
family = c("gaussian", "binomial", "poisson", "multinomial", "cox",
"mgaussian"), ...)
confusion.glmnet(object, newx = NULL, newy, family = c("binomial",
"multinomial"), ...)
roc.glmnet(object, newx = NULL, newy, ...)
``` |

`object` |
Fitted |

`newx` |
If predictions are to made, these are the 'x' values. Required
for |

`newy` |
required argument for all functions; the new response values |

`weights` |
For observation weights for the test observations |

`family` |
The family of the model, in case predictions are passed in as 'object' |

`...` |
additional arguments to |

`assess.glmnet`

produces all the different performance measures
provided by `cv.glmnet`

for each of the families. A single vector, or a
matrix of predictions can be provided, or fitted model objects or CV
objects. In the case when the predictions are still to be made, the
`...`

arguments allow, for example, 'offsets' and other prediction
parameters such as values for 'gamma' for 'relaxed' fits. `roc.glmnet`

produces for a single vector a two column matrix with columns TPR and FPR
(true positive rate and false positive rate). This object can be plotted to
produce an ROC curve. If more than one predictions are called for, then a
list of such matrices is produced. `confusion.glmnet`

produces a
confusion matrix tabulating the classification results. Again, a single
table or a list, with a print method.

`assess.glmnet`

produces a list of vectors of measures.
`roc.glmnet`

a list of 'roc' two-column matrices, and
`confusion.glmnet`

a list of tables. If a single prediction is
provided, or predictions are made from a CV object, the latter two drop the
list status and produce a single matrix or table.

Trevor Hastie and Rob Tibshirani

Maintainer: Trevor Hastie
[email protected]

1 2 3 4 5 6 7 8 9 10 11 12 13 14 | ```
x = matrix(rnorm(100 * 20), 100, 20)
y = rnorm(100)
g2 = sample(1:2, 100, replace = TRUE)
g4 = sample(1:4, 100, replace = TRUE)
fit1 = glmnet(x, y)
assess.glmnet(fit1, newx = x, newy = y)
preds = predict(fit1, newx = x[1:20, ], s = c(0.01, 0.005))
assess.glmnet(preds, newy = y[1:20], family = "gaussian")
fit2 = glmnet(x, g2, family = "binomial")
plot(roc.glmnet(fit2, newx = x, newy = g2)[[20]])
fit2c = cv.glmnet(x, g2, family = "binomial")
plot(roc.glmnet(fit2c, newx = x, newy = g2, s = "lambda.min"))
fit3 = glmnet(x, g4, family = "multinomial")
confusion.glmnet(fit3, newx = x[1:50, ], newy = g4[1:50], s = 0.01)
``` |

Embedding an R snippet on your website

Add the following code to your website.

For more information on customizing the embed code, read Embedding Snippets.