Skip to contents

p_hat = sigmoid(X theta) computed branch-free (exp only on <= 0), then y_pred = 1[p_hat >= threshold].

Usage

morie_geron_binary_classification(X, theta, threshold = 0.5, y_true = NULL)

Arguments

X

Design matrix (bring your own intercept column).

theta

Coefficients.

threshold

Cut in [0, 1].

y_true

Optional 0/1 labels for the confusion summary.

Value

List with y_pred, p_hat, logit and, when y_true is given, tp, fp, fn, tn, accuracy, precision, recall, f1.

Examples

V <- c(1, 2, 3, 4, 5, 6, 7, 8)
morie_geron_binary_classification(V, V)
#> $y_pred
#> [1] 1
#> 
#> $p_hat
#> [1] 1
#> 
#> $logit
#> [1] 204
#> 
#> $threshold
#> [1] 0.5
#> 
#> $tp
#> NULL
#> 
#> $fp
#> NULL
#> 
#> $fn
#> NULL
#> 
#> $tn
#> NULL
#> 
#> $accuracy
#> NULL
#> 
#> $precision
#> NULL
#> 
#> $recall
#> NULL
#> 
#> $f1
#> NULL
#> 
#> $estimate
#> [1] 1
#> 
#> $n
#> [1] 1
#> 
#> $method
#> [1] "Binary classification by thresholding the logistic score"
#>