Learn R Programming

daltoolbox (version 1.3.717)

cla_glm: Logistic regression (GLM)

Description

Logistic regression classifier using stats::glm with binomial family.

Usage

cla_glm(attribute, positive, features = NULL, threshold = 0.5)

Value

returns a cla_glm object

Arguments

attribute

target attribute name

positive

positive class label

features

optional vector of feature names (default: all except attribute)

threshold

probability threshold for positive class

Examples

Run this code
data(iris)
iris_bin <- iris
iris_bin$IsVersicolor <- factor(ifelse(
 iris_bin$Species == "versicolor",
 "versicolor",
 "not_versicolor"
))
model <- cla_glm("IsVersicolor", positive = "versicolor")
model <- suppressWarnings(fit(model, iris_bin))
pred <- predict(model, iris_bin)
table(pred, iris_bin$IsVersicolor)

Run the code above in your browser using DataLab