score: Score the Performance of a Model fit with 'sgdnet()'

Description Usage Arguments Value See Also Examples

Description

The main purpose of this function is internal use within cv_sgdnet(), where it is used to score the performance over folds in cross-validation. It can, however, be used on its own to measure performance against a validation set, for instance by training the model via cv_sgdnet() and holding out a validation set for use with this function.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
score(fit, ...)

## S3 method for class 'sgdnet_gaussian'
score(fit, x, y, type.measure = c("deviance",
  "mse", "mae"), s = fit$lambda, ...)

## S3 method for class 'sgdnet_binomial'
score(fit, x, y, type.measure = c("deviance",
  "mse", "mae", "class", "auc"), s = fit$lambda, ...)

## S3 method for class 'sgdnet_multinomial'
score(fit, x, y,
  type.measure = c("deviance", "mse", "mae", "class"), s = fit$lambda,
  ...)

## S3 method for class 'sgdnet_mgaussian'
score(fit, x, y, type.measure = c("deviance",
  "mse", "mae"), s = fit$lambda, ...)

## S3 method for class 'cv_sgdnet'
score(fit, x, y, type.measure, s = c("lambda_1se",
  "lambda_min"), ...)

Arguments

fit

the model fit

...

arguments passed on to predict.sgdnet()

x

a feature matrix of new data

y

response(s) for new data

type.measure

the type of measure

s

lambda

Value

Returns the prediction error along the lambda path.

See Also

predict.sgdnet(), cv_sgdnet()

Examples

1
2
3
4
5
6
7
8
9
set.seed(1)
n <- nrow(wine$x)
train_ind <- sample(n, floor(0.8*n))
cv_fit <- cv_sgdnet(wine$x[train_ind, ],
                    wine$y[train_ind],
                    family = "multinomial",
                    nfolds = 5,
                    alpha = c(0.5, 1))
score(cv_fit, wine$x[-train_ind, ], wine$y[-train_ind], "deviance")

jolars/sgdnet documentation built on May 22, 2019, 11:52 p.m.