/
print.sgdnet.R
45 lines (44 loc) · 1.7 KB
/
print.sgdnet.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# sgdnet: Penalized Generalized Linear Models with Stochastic Gradient Descent
# Copyright (C) 2018 Johan Larsson
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#' Print a Path Summary for a Fit from sgdnet
#'
#' @param x an object of class `'sgdnet'`, typically the result of
#' calling [sgdnet()]
#' @param ... other arguments passed to [print()]
#'
#' @return Prints (and return invisibly) a table of the regularization path from
#' the fit with the following columns:
#' \tabular{ll}{
#' `Df` \tab pseudo-degrees of freedom, namely the number of non-zero
#' coefficients \cr
#' `%Dev` \tab the percentage of deviance explained \cr
#' `Lambda` \tab the \eqn{\lambda}{lambda} value (regularization strength) of
#' the fit
#' }
#' @export
#' @seealso [sgdnet()], [print.sgdnet()]
#'
#' @examples
#' fit <- sgdnet(with(mtcars, cbind(drat, hp)), mtcars$disp)
#' print(fit, digits = 1)
print.sgdnet <- function(x, ...) {
cat("\nCall: ", deparse(x$call), "\n\n")
out <- cbind(Df = x$df,
"%Dev" = x$dev.ratio,
Lambda = x$lambda)
print(out, ...)
invisible(out)
}