Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# R specific hooks: https://github.com/lorenzwalthert/precommit
repos:
- repo: https://github.com/lorenzwalthert/precommit
rev: v0.4.3.9017
rev: v0.4.3.9020
hooks:
- id: style-files
args: [--style_pkg=styler, --style_fun=tidyverse_style]
Expand Down Expand Up @@ -40,7 +40,7 @@ repos:
- id: parsable-R
- id: no-browser-statement
- id: no-print-statement
exclude: '.*tests_print.*'
exclude: '.*tests_print.*|.*s3methods.*|.*print\.vswift.*'
- id: no-debug-statement
- id: deps-in-desc
- id: pkgdown
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ All notable future changes to vswift will be documented in this file.
noted in the changelog (i.e new functions or parameters, changes in parameter defaults or function names, etc).
- *.patch* : Contains no new features, simply fixes any identified bugs.

## [0.6.0] - 2026-03-21
### 🚀 New/Added
- Returns R6 classes
- Deleted `genFolds`
- Change all methods from camelcase to snakecase

## [0.5.0.9006] - 2025-08-15
### 🐛 Fixes
- Correct misspelling of youden in docs and list components
Expand Down
9 changes: 5 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: vswift
Title: Classification Model Evaluation
Version: 0.5.0.9006
Date: 2025-08-15
Version: 0.6.0
Date: 2026-03-21
Authors@R: person(given = "Donisha",
family = "Smith",
role = c("aut", "cre"),
Expand All @@ -25,7 +25,8 @@ Imports:
future.apply,
kknn,
glmnet,
data.table
data.table,
R6
Suggests:
testthat,
covr,
Expand All @@ -34,5 +35,5 @@ Suggests:
VignetteBuilder:
knitr
Encoding: UTF-8
RoxygenNote: 7.3.2
RoxygenNote: 7.3.3
Config/testthat/edition: 3
10 changes: 4 additions & 6 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# Generated by roxygen2: do not edit by hand

S3method(plot,vswift)
S3method(print,vswift)
export(classCV)
export(CurveResult)
export(Vswift)
export(class_cv)
export(contr.dummy)
export(contr.ordinal)
export(genFolds)
export(prCurve)
export(rocCurve)
importFrom(R6,R6Class)
importFrom(data.table,":=")
importFrom(data.table,.SD)
importFrom(data.table,data.table)
Expand Down
2 changes: 1 addition & 1 deletion R/append_param_keys.R
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Function for appending missing keys to parameters that are lists
.append_param_keys <- function(param, struct, models = NULL, caller = "classCV", ...) {
.append_param_keys <- function(param, struct, models = NULL, ...) {
# Evaluate to get default keys for specific parameters
default_keys <- eval(as.list(.DEFAULT_KEYS[[2]])[[param]])

Expand Down
76 changes: 38 additions & 38 deletions R/categorical_encoding.R
Original file line number Diff line number Diff line change
@@ -1,38 +1,38 @@
# Create dictionary for target variable if needed for certain algos
.create_dictionary <- function(target_vector, threshold = NULL, alternate_warning = FALSE, curve_method = NULL) {
counter <- 0
new_classes <- c()
class_dict <- list()
for (class in names(table(target_vector))) {
new_classes <- c(new_classes, paste(class, "=", counter, collapse = " "))
class_dict[[class]] <- counter
counter <- counter + 1
}
standard_msg <- sprintf(
"due to %s being specified", ifelse(is.null(threshold), "'logistic' or 'xgboost'", "`model_params$threshold`")
)
msg <- if (!alternate_warning) standard_msg else sprintf("for `%sCurve`", curve_method)
warning(sprintf(
"creating keys for target variable %s;\n classes are now encoded: %s",
msg, paste(new_classes, collapse = ", ")
))
return(class_dict)
}
# Helper function to convert keys
.convert_keys <- function(target_vector, keys, direction) {
if (direction == "encode") {
labels <- sapply(target_vector, function(x) keys[[x]])
} else {
converted_keys <- as.list(names(keys))
names(converted_keys) <- as.character(as.vector(unlist(keys)))
labels <- sapply(target_vector, function(x) converted_keys[[as.character(x)]])
}
return(labels)
}
# Create dictionary for target variable if needed for certain algos
.create_dictionary <- function(target_vector, threshold = NULL, alternate_warning = FALSE, curve_method = NULL) {
counter <- 0
new_classes <- c()
class_dict <- list()

for (class in names(table(target_vector))) {
new_classes <- c(new_classes, paste(class, "=", counter, collapse = " "))
class_dict[[class]] <- counter
counter <- counter + 1
}

standard_msg <- sprintf(
"due to %s being specified", ifelse(is.null(threshold), "'logistic' or 'xgboost'", "`model_params$threshold`")
)

msg <- if (!alternate_warning) standard_msg else sprintf("for `%s_curve`", curve_method)

warning(sprintf(
"creating keys for target variable %s;\n classes are now encoded: %s",
msg, paste(new_classes, collapse = ", ")
))

return(class_dict)
}

# Helper function to convert keys
.convert_keys <- function(target_vector, keys, direction) {
if (direction == "encode") {
labels <- sapply(target_vector, function(x) keys[[x]])
} else {
converted_keys <- as.list(names(keys))
names(converted_keys) <- as.character(as.vector(unlist(keys)))
labels <- sapply(target_vector, function(x) converted_keys[[as.character(x)]])
}

return(labels)
}
Loading
Loading