lreg_fit()
fits a logistic regression model for single predictors.
It uses the glm engine for logistic regression and fits the model using the
logistic_reg()
function from the parsnip package. It also calculates the
accuracy, sensitivity, specificity, AUC, and confusion matrix of the model.
Usage
lreg_fit(
train_data,
test_data,
variable = "Disease",
case,
cor_threshold = 0.9,
cv_sets = 4,
ncores = 1,
exclude_cols = NULL,
palette = NULL,
seed = 123
)
Arguments
- train_data
Training data set from
make_groups()
.- test_data
Testing data set from
make_groups()
.- variable
The variable to predict. Default is "Disease".
- case
Case to predict.
- cor_threshold
Threshold of absolute correlation values. This will be used to remove the minimum number of features so that all their resulting absolute correlations are less than this value.
- cv_sets
Number of cross-validation sets. Default is 5.
- ncores
Number of cores to use for parallel processing. Default is 4.
- exclude_cols
Columns to exclude from the data before the model is tuned. Default is NULL.
- palette
Color palette for the ROC curve. Default is NULL.
- seed
Seed for reproducibility. Default is 123.
Value
A list with two elements:
fit_res: A list with 4 elements:
lreg_wf: Workflow object.
train_set: Training set.
test_set: Testing set.
final: Fitted model.
metrics: A list with the model metrics:
accuracy: Accuracy of the model.
sensitivity: Sensitivity of the model.
specificity: Specificity of the model.
auc: AUC of the model.
conf_matrix: Confusion matrix of the model.
roc_curve: ROC curve of the model.