Skip to content

Commit

Permalink
Merge pull request #103 from tlverse/rm-lassi-artifacts
Browse files Browse the repository at this point in the history
Remove lassi artifacts
  • Loading branch information
rachaelvp authored Dec 9, 2022
2 parents 6a5084d + f849c45 commit 81093a5
Show file tree
Hide file tree
Showing 70 changed files with 316 additions and 1,259 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/R-CMD-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
uses: actions/checkout@v2

- name: Setup R
uses: r-lib/actions/setup-r@master
uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}

Expand Down
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,5 @@ LinkingTo:
Rcpp,
RcppEigen
VignetteBuilder: knitr
RoxygenNote: 7.1.2
RoxygenNote: 7.2.0
Roxygen: list(markdown = TRUE)
5 changes: 0 additions & 5 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export(make_copy_map)
export(make_design_matrix)
export(make_reduced_basis_map)
export(squash_hal_fit)
import(Rcpp)
importFrom(Matrix,tcrossprod)
importFrom(Rcpp,sourceCpp)
importFrom(assertthat,assert_that)
Expand All @@ -27,13 +26,9 @@ importFrom(data.table,setorder)
importFrom(glmnet,cv.glmnet)
importFrom(glmnet,glmnet)
importFrom(methods,is)
importFrom(methods,new)
importFrom(origami,cross_validate)
importFrom(origami,fold_index)
importFrom(origami,folds2foldvec)
importFrom(origami,make_folds)
importFrom(origami,training)
importFrom(origami,validation)
importFrom(stats,aggregate)
importFrom(stats,as.formula)
importFrom(stats,coef)
Expand Down
10 changes: 0 additions & 10 deletions R/RcppExports.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,6 @@ apply_copy_map <- function(X, copy_map) {
.Call('_hal9001_apply_copy_map', PACKAGE = 'hal9001', X, copy_map)
}

#' Prediction from a Lassi Model
#'
#' @param X A sparse matrix of HAL basis functions.
#' @param beta A vector of coefficient values for the HAL basis functions.
#' @param intercept A numeric value giving the intercept of the HAL model.
#'
lassi_predict <- function(X, beta, intercept) {
.Call('_hal9001_lassi_predict', PACKAGE = 'hal9001', X, beta, intercept)
}

#' Sort Basis Functions
#'
#' Build a sorted list of unique basis functions based on columns, where each
Expand Down
52 changes: 0 additions & 52 deletions R/cv_lasso.R
Original file line number Diff line number Diff line change
@@ -1,55 +1,3 @@
#' Single Lasso estimation for cross-validation with Origami
#'
#' Fits Lasso regression over a single fold of a cross-validated data set. This
#' is meant to be called using \code{\link[origami]{cross_validate}}, which is
#' done through \code{\link{cv_lasso}}. Note that this procedure is NOT meant
#' to be invoked by itself. INTERNAL USE ONLY.
#'
#' @param fold A \code{fold} object produced by a call to \code{make_folds}
#' from the \pkg{origami}.
#' @param data A \code{dgCMatrix} object containing the outcome values (Y) in
#' its first column and vectors corresponding to the basis functions of HAL in
#' all other columns. Consult the description of HAL regression for details.
#' @param lambdas A \code{numeric} vector corresponding to a sequence of lambda
#' values obtained by fitting the Lasso on the full data.
#' @param center binary. If \code{TRUE}, covariates are centered. This is much
#' slower, but matches the \code{glmnet} implementation. Default \code{FALSE}.
#'
#' @importFrom origami training validation fold_index
lassi_origami <- function(fold, data, lambdas, center = FALSE) {
# make sure data is an (augmented) sparse matrix of basis functions
stopifnot(class(data) == "dgCMatrix")

# split data for V-fold cross-validation
train_data <- origami::training(data)
valid_data <- origami::validation(data)

# wrangle objects to clearer forms
train_x_basis <- train_data[, -1]
valid_x_basis <- valid_data[, -1]
train_y <- train_data[, 1]
valid_y <- valid_data[, 1]

# compute the predicted betas for the given training and validation sets
lassi_fit <- lassi(
x = train_x_basis, y = train_y, lambdas = lambdas,
center = center
)
pred_mat <- predict(lassi_fit, valid_x_basis)

# compute the MSE for the given training and validation sets
mses <- apply(pred_mat, 2, function(preds) {
mean((preds - valid_y)^2)
})

# the only output needed is the lambda-wise MSE over each fold
mses_out <- matrix(mses, nrow = 1)
out <- list(mses = mses_out)
return(out)
}

###############################################################################

#' Cross-validated Lasso on Indicator Bases
#'
#' Fits Lasso regression using a customized procedure, with cross-validation
Expand Down
97 changes: 0 additions & 97 deletions R/cv_lasso_early_stopping.R

This file was deleted.

97 changes: 0 additions & 97 deletions R/lassi.R

This file was deleted.

Loading

0 comments on commit 81093a5

Please sign in to comment.