cross.entropy: Cross-entropy

Description Usage Arguments Value Author(s) Examples

Description

Cross-entropy (Negaitve Multinomial log-likelihood)

∑_i{y_i * log(\hat y_i)}

Usage

1
2
3
4
5
6
7
## S3 method for class 'modello_number'
cross.entropy(y, yh)

## Default S3 method:
cross.entropy(y, yh)

cross.entropy(y, yh)

Arguments

y

predicted probability

yh

target classes (0 or 1)

Value

Returns the entropy

Author(s)

Filippo Monari

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
modello.init(10, 10, 10, 10)
## For modello_numbers
y = number(matrix({x=sample(c(1, 0), 5, replace=TRUE); c(x, 1-x)}, 5, 2), dx=FALSE)
yh = number(t(apply(matrix(runif(10), 5, 2), 1, function(x)x/sum(x))))
h = cross.entropy(y, yh)
print(h)
print(h$v)
modello.close()
## For numerics
y = matrix({x=sample(c(1, 0), 5, replace=TRUE); c(x, 1-x)}, 5, 2)
yh = t(apply(matrix(runif(10), 5, 2), 1, function(x)x/sum(x)))
h = cross.entropy(y, yh)
print(h)

modello documentation built on Feb. 2, 2021, 9:06 a.m.