Learn R Programming

Laurae (version 0.0.0.9001)

interactive.SymbolicLoss: Interactive Dashboard for Symbolic Gradient/Hessian Loss Behavior Exploration

Description

This function runs an interactive dashboard which computes the 1st and 2nd symbolic derivatives of the loss function (gradient/hessian) provided, for up to 4 functions simultaneously without interrupting if you input a bad function.

Usage

interactive.SymbolicLoss(f1 = "(x, y) {(x - y) ^ 2}",
  f2 = "(x, y) {(y * log(x) + (1 - y) * log(1 - x))}",
  f3 = "(x, y) {(x - y * log(x)) + (y * log(y) - y)}",
  f4 = "(x, y) {(y - x) * log(y / x)}", f1_init = c(-20, 20, 50, 0),
  f2_init = c(0.01, 0.99, 50, 1), f3_init = c(0, 100, 100, 20),
  f4_init = c(0, 100, 100, 20), f1_back = "yellow", f2_back = "aqua",
  f3_back = "olive", f4_back = "purple", f_back = "red", type = "o",
  max_height = 580)

Arguments

f1
Type: character. A string describing the first loss function, with potentially multiple arguments. Requires at least (x, y) arguments. Defaults to "(x, y) {(x - y) ^ 2}".
f2
Type: character. A string describing the second loss function, with potentially multiple arguments. Requires at least (x, y) arguments. Defaults to "(x, y) {(y * log(x) + (1 - y) * log(1 - x))}".
f3
Type: character. A string describing the third loss function, with potentially multiple arguments. Requires at least (x, y) arguments. Defaults to "(x, y) {(x - y * log(x)) + (y * log(y) - y)}".
f4
Type: character. A string describing the fourth loss function, with potentially multiple arguments. Requires at least (x, y) arguments. Defaults to "(x, y) {(y - x) * log(y / x)}".
f1_init
Type: numeric vector of length 4. A vector containing sequentially the minimum, the maximum, the number of points, and the y value for the plots of the first loss function. Defaults to c(-20, 20, 50, 0),.
f2_init
Type: numeric vector of length 4. A vector containing sequentially the minimum, the maximum, the number of points, and the y value for the plots of the second loss function. Defaults to c(0.01, 0.99, 50, 1).
f3_init
Type: numeric vector of length 4. A vector containing sequentially the minimum, the maximum, the number of points, and the y value for the plots of the third loss function. Defaults to c(0, 100, 100, 20).
f4_init
Type: numeric vector of length 4. A vector containing sequentially the minimum, the maximum, the number of points, and the y value for the plots of the fourth loss function. Defaults to c(0, 100, 100, 20).
f1_back
Type: character. A background color character for the first function. Defaults to "yellow".
f2_back
Type: character. A background color character for the second function. Defaults to "aqua".
f3_back
Type: character. A background color character for the third function. Defaults to "olive".
f4_back
Type: character. A background color character for the fourth function. Defaults to "purple".
f_back
Type: character. A background color character for the header. Defaults to "red".
type
Type: character. The type of plot to use for plots. "p" for points, "l" for lines, "b" for points+line, "c" for line without points, "o" for overplotted (points+line overlapping), "h" for high-density vertical lines (histogram-like), "s" for optimistic stair steps, "S" for pessimistic stair steps, "n" to plot nothing. Defaults to "o" for overplotted.
max_height
Type: numeric. The maximum height for the plots. Defaults to 580, which fits nicely Full HD screens (1080 vertical pixels).

Value

Nothing

Details

This function cannot handle any type of input. It cannot handle sums or loops in the function code. It handles the following, in the alphabetic order:
\*
Multiplication
/
Division
^
Power
abs
Absolute value function
acos
Arcosine function
acosh
Hyperbolic Arcosine function
asin
Arsine function
asinh
Hyperbolic Arcsine function
atan
Arctangent function
atan2
Arctangent angle function between the x-axis and the vector from the origin (x,y), atan=y/x if x>0 and y>0
atanh
Hyperbolic Arctangent function
besselI
Modified Bessel function of the first kind
besselJ
Bessel function of the first kind
besselK
Modified Bessel function of the second kind
besselY
Sphereical Bessel function
beta
Beta function (Eulerian integral of the first kind)
cos
Cosine function
cosh
Hyperbolic cosine function
cospi
Cosine function with argument multiplicand pi
dbinom
Density binomial function
digamma
First derivative of the logarithm of the gamma function
dnorm
Density normal function
exp
Exponential function
expm1
Exponential function minus 1
gamma
Gamma function (Mellin transform of the negative exponential function)
lbeta
Natural logarithm of the beta function
lgamma
Natural logarithm of the absolute value of the gamma function
log
Natural (e) logarithm function
log10
Common (10) logarithm function
log1p
Natural (e) logarithm function with 1 added to the argument
log2
Binary (2) logarithm function
logb
Logarithm function of base b (base)
pnorm
Normal distribution function
psigamma
Polygamma function (degree specified by deriv)
rep.int
Replicate "times" elements of vectors and lists
rep_len
Replicate "length.out" elements of vectors and lists
sign
Sign function
sin
Sine function
sinh
Hyperbolic sine function
sinpi
Sine function with argument multiplicand pi
sqrt
Square root function
tan
Tangent function
tanh
Hyperbolic tangent function
tanpi
Tangent function with argument multiplicand pi
trigamma
Second derivative of the logarithm of the gamma function
The colors (non header: f1_back, f2_back, f3_back, f4_back) allowed are the following:
red
red color
yellow
yellow color
aqua
aqua color
blue
blue color
light-blue
light-blue color
green
green color
navy
navy color
teal
teal color
olive
olive color
lime
lime color
orange
orange color
fuchsia
fuchsia color
purple
purple color
maroon
maroon color
black
black color
The colors (header: f_back) allowed are the following:
blue
blue color
black
black color
purple
purple color
green
green color
red
red color
yellow
yellow color

Examples

Run this code
## Not run: ------------------------------------
# interactive.SymbolicLoss(f1 = "(x, y) {(x - y) ^ 2}",
#                          f2 = "(x, y) {(y * log(x) + (1 - y) * log(1 - x))}",
#                          f3 = "(x, y) {(x - y * log(x)) + (y * log(y) - y)}",
#                          f4 = "(x, y) {(y - x) * log(y / x)}",
#                          f1_init = c(-20, 20, 50, 0),
#                          f2_init = c(0.01, 0.99, 50, 1),
#                          f3_init = c(0, 100, 100, 20),
#                          f4_init = c(0, 100, 100, 20),
#                          f1_back = "yellow",
#                          f2_back = "aqua",
#                          f3_back = "olive",
#                          f4_back = "purple",
#                          f_back = "red",
#                          type = "o",
#                          max_height = 580)
## ---------------------------------------------

Run the code above in your browser using DataLab