### Load multivarious R package and basic example setup Source: https://github.com/bbuchsbaum/multivarious/blob/master/README.md A basic example demonstrating how to load the 'multivarious' R package into your R session. This snippet also includes placeholder comments for further example code, serving as a starting point for package usage. ```R library(multivarious) #> #> Attaching package: 'multivarious' #> The following object is masked from 'package:stats': #> #> residuals #> The following object is masked from 'package:base': #> #> truncate ## basic example code ``` -------------------------------- ### R Example: Projecting Data with bi_projector Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/project.html This example demonstrates how to use the `project` function with a `bi_projector` object in R. It shows the creation of a `bi_projector` from SVD results and then projecting new data onto the same subspace. ```R # Example with the bi_projector class X <- matrix(rnorm(10*20), 10, 20) svdfit <- svd(X) p <- bi_projector(svdfit$v, s = svdfit$u %% diag(svdfit$d), sdev=svdfit$d) # Project new_data onto the same subspace as the original data new_data <- matrix(rnorm(5*20), 5, 20) projected_data <- project(p, new_data) ``` -------------------------------- ### R Package Building and Installation Commands Source: https://github.com/bbuchsbaum/multivarious/blob/master/CLAUDE.md This snippet provides commands for building and installing the 'multivarious' R package. It includes methods for both R console (using devtools) and command line (using R CMD). ```R # From R console devtools::install() # Build and install the package devtools::build() # Build package tarball devtools::load_all() # Load all functions for development # From command line R CMD build . R CMD INSTALL . ``` -------------------------------- ### R Usage Example for init_transform Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/init_transform.html Illustrates the basic syntax for calling the `init_transform` function in R, showing its required arguments. ```R init_transform(x, X, ...) ``` -------------------------------- ### R: Example Usage of ncomp with svd_wrapper Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/ncomp.html Demonstrates a practical application of the `ncomp` function. This example shows how to prepare data, fit a model using `svd_wrapper`, and then use `ncomp` to retrieve the number of components, verifying the expected output. ```R # Example using the svd_wrapper function data(iris) X <- iris[, 1:4] fit <- svd_wrapper(X, ncomp = 3, preproc = center(), method = "base") ncomp(fit) # Should return 3 #> [1] 3 ``` -------------------------------- ### Install multivarious R Package from GitHub Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/index.html Instructions to install the development version of the 'multivarious' R package directly from GitHub using the 'devtools' package. This is the recommended way to get the latest features and bug fixes. ```R # install.packages("devtools") devtools::install_github("bbuchsbaum/multivarious") ``` -------------------------------- ### Install multivarious R package from GitHub Source: https://github.com/bbuchsbaum/multivarious/blob/master/README.md Instructions to install the development version of the 'multivarious' R package directly from GitHub using the 'devtools' package. This is the recommended method for obtaining the latest features. ```R # install.packages("devtools") devtools::install_github("bbuchsbaum/multivarious") ``` -------------------------------- ### Example of bi_projector instance creation in R Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/bi_projector.html Demonstrates how to create a `bi_projector` instance in R. It uses a randomly generated matrix, performs singular value decomposition (SVD), and then initializes `bi_projector` with the SVD results. ```R X <- matrix(rnorm(200), 10, 20) svdfit <- svd(X) p <- bi_projector(svdfit$v, s = svdfit$u %% diag(svdfit$d), sdev=svdfit$d) ``` -------------------------------- ### R: Compute SVD using svd_wrapper Example Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/svd_wrapper.html Demonstrates how to use the `svd_wrapper` function in R to perform Singular Value Decomposition. The example loads the `iris` dataset, selects the first four columns, centers the data using `preproc = center()`, and computes SVD with 3 components using the 'base' method. ```R # Load iris dataset and select the first four columns data(iris) X <- iris[, 1:4] # Compute SVD using the base method and 3 components fit <- svd_wrapper(X, ncomp = 3, preproc = center(), method = "base") ``` -------------------------------- ### R Example: Using projector for Dimensionality Reduction Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/projector.html Demonstrates how to create a `projector` instance using SVD results and apply it to a matrix `X` to perform projection. ```R X <- matrix(rnorm(10*10), 10, 10) svdfit <- svd(X) p <- projector(svdfit$v) proj <- project(p, X) ``` -------------------------------- ### Load multivarious R Package Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/index.html A basic example showing how to load the 'multivarious' R package into your R session. This step is necessary before you can use any of the package's functions or classes. ```R library(multivarious) #> #> Attaching package: 'multivarious' #> The following object is masked from 'package:stats': #> #> residuals #> The following object is masked from 'package:base': #> #> truncate ## basic example code ``` -------------------------------- ### API Reference: block_lengths Function Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/block_lengths.html Detailed API documentation for the `block_lengths` function, including its parameters and their descriptions. ```APIDOC block_lengths(x) x: the object ``` -------------------------------- ### R Function: fresh - Get a fresh pre-processing node Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/fresh.html Documents the `fresh` function in R, which returns a pre-processing node cleared of cached data. It takes a processing pipeline `x` and additional arguments `...`. ```R fresh(x, ...) ``` ```APIDOC Arguments: x: the processing pipeline ...: extra args ``` -------------------------------- ### R Function: components Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/components.html Documents the `components` function, which extracts the component matrix from a model fit. It takes a model object `x` and allows for additional arguments. ```APIDOC components(x, ...) x: the model fit ...: extra args ``` -------------------------------- ### R Example: Fit and Reconstruct Multi-Output Regression Models Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/regress.html Illustrates the usage of the `regress` function in R to fit different multi-output linear regression models (LM, Ridge, Elastic Net, PLS) and subsequently reconstruct the response matrix. It includes synthetic data generation and demonstrates how to apply various `method` and associated parameters like `lambda`, `alpha`, and `ncomp`. ```R # Generate synthetic data Y <- matrix(rnorm(100 * 10), 10, 100) X <- matrix(rnorm(10 * 9), 10, 9) # Fit regression models and reconstruct the response matrix r_lm <- regress(X, Y, intercept = FALSE, method = "lm") recon_lm <- reconstruct(r_lm) r_mridge <- regress(X, Y, intercept = TRUE, method = "mridge", lambda = 0.001) recon_mridge <- reconstruct(r_mridge) r_enet <- regress(X, Y, intercept = TRUE, method = "enet", lambda = 0.001, alpha = 0.5) recon_enet <- reconstruct(r_enet) r_pls <- regress(X, Y, intercept = TRUE, method = "pls", ncomp = 5) recon_pls <- reconstruct(r_pls) ``` -------------------------------- ### R: ncomp Function API Reference Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/ncomp.html Provides the API signature, arguments, and return value for the `ncomp` function in the `multivarious` R package. It clarifies the expected input and the type of output. ```APIDOC ncomp(x) Arguments: x: A fitted model object. Value: The number of components in the fitted model. ``` -------------------------------- ### R Example: Partially Projecting Data with bi_projector Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/partial_project.html Demonstrates how to use the `partial_project` function in R. It shows the creation of a `bi_projector` object from SVD results and then applies `partial_project` to new data using a specified subset of columns. ```R # Example with the bi_projector class X <- matrix(rnorm(10*20), 10, 20) svdfit <- svd(X) p <- bi_projector(svdfit$v, s = svdfit$u %*% diag(svdfit$d), sdev=svdfit$d) # Partially project new_data onto the same subspace as the original data # using only the first 10 variables new_data <- matrix(rnorm(5*20), 5, 20) colind <- 1:10 partially_projected_data <- partial_project(p, new_data[,colind], colind) ``` -------------------------------- ### APIDOC: fresh() - Get Fresh Pre-processing Node Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/index.html Retrieves a new pre-processing node, ensuring it is cleared of any previously cached data. ```APIDOC fresh(): Get a fresh pre-processing node cleared of any cached data ``` -------------------------------- ### R Function Usage: block_lengths Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/block_lengths.html Illustrates the basic syntax for calling the `block_lengths` function in R. ```R block_lengths(x) ``` -------------------------------- ### R Function: prep Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/prep.html Detailed API documentation for the `prep` function, which applies a pre-processing pipeline. It takes a pipeline object `x` and additional arguments `...`. ```APIDOC Function: prep Usage: prep(x, ...) Arguments: x: the pipeline ...: extra args ``` -------------------------------- ### API Reference for init_transform Arguments Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/init_transform.html Provides detailed documentation for the parameters of the `init_transform` function, including their purpose. ```APIDOC init_transform(x, X, ...) x: the pre_processor X: the data matrix ``` -------------------------------- ### R projector Function API Documentation Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/projector.html Detailed API documentation for the `projector` function, including its signature, parameters, and return value. ```APIDOC projector(v, preproc = prep(pass()), ..., classes = NULL) Description: A projector maps a matrix from an N-dimensional space to d-dimensional space, where d may be less than N. The projection matrix, v, is not necessarily orthogonal. This function constructs a projector instance which can be used for various dimensionality reduction techniques like PCA, LDA, etc. Arguments: v: A matrix of coefficients with dimensions nrow(v) by ncol(v) (number of columns = number of components) preproc: A prepped pre-processing object. Default is the no-processing pass() preprocessor. ...: Extra arguments to be stored in the projector object. classes: Additional class information used for creating subtypes of projector. Default is NULL. Value: An instance of type projector. ``` -------------------------------- ### prep_node function API documentation Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/prep_node.html Documents the `prep_node` function, its parameters, and usage within the `multivarious` R package for adding a new node to a pipeline. ```APIDOC Function: prep_node Description: prepare a new node and add to pipeline Usage: prep_node(pipeline, name, create, ...) Arguments: pipeline: the pre-processing pipeline name: the name of the step to add create: the creation function ``` -------------------------------- ### R Package Important Implementation Details Source: https://github.com/bbuchsbaum/multivarious/blob/master/CLAUDE.md This section provides critical implementation guidelines for developing within the 'multivarious' R package, covering cache management, preprocessing reversibility, input validation, error handling, and matrix operations. ```APIDOC - When modifying projectors, always clear the cache to ensure consistency. - Preprocessing must be reversible - all transformations need a reverse operation. - Use `chk::chk_*` functions for input validation. - Follow existing patterns for error messages using `rlang::abort()`. - Matrix operations should handle sparse matrices when possible. ``` -------------------------------- ### API Reference for project function Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/project.html Detailed API documentation for the `project` function, including its signature, parameters, and return value. This function is used to project new observations onto a subspace defined by a model fit. ```APIDOC project(x, new_data, ...) x: The model fit, typically an object of class bi_projector or any other class that implements a project method new_data: A matrix or vector of new observations with the same number of columns as the original data. Rows represent observations and columns represent variables ...: Extra arguments to be passed to the specific project method for the object's class Returns: A matrix or vector of the projected observations, where rows represent observations and columns represent the lower-dimensional space ``` -------------------------------- ### R Package Testing Commands Source: https://github.com/bbuchsbaum/multivarious/blob/master/CLAUDE.md This snippet outlines various commands for testing the 'multivarious' R package. It covers running all tests, specific test files, checking code coverage, and performing full package checks. ```R # From R console devtools::test() # Run all tests testthat::test_package("multivarious") # Run tests directly covr::package_coverage() # Run tests with coverage # Run a single test file testthat::test_file("tests/testthat/test_pca.R") # From command line R CMD check . ``` -------------------------------- ### R Package Documentation and Checking Commands Source: https://github.com/bbuchsbaum/multivarious/blob/master/CLAUDE.md This snippet provides commands for generating documentation from roxygen2 comments, performing various package checks (including CRAN-style), and building the package website for the 'multivarious' R package. ```R # Generate/update documentation from roxygen2 comments devtools::document() # Run package checks devtools::check() # Full package check R CMD check --as-cran . # CRAN-style checks rcmdcheck::rcmdcheck() # Enhanced checking # Build package website pkgdown::build_site() ``` -------------------------------- ### API Documentation for partial_project Function Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/partial_project.html Detailed API specification for the `partial_project` function, including its signature, parameters, and return value. ```APIDOC partial_project(x, new_data, colind) Arguments: x: The model fit, typically an object of class `bi_projector` or any other class that implements a `partial_project` method new_data: A matrix or vector of new observations with a subset of columns equal to length of `colind`. Rows represent observations and columns represent variables colind: A numeric vector of column indices to select in the projection matrix. These indices correspond to the variables used for the partial projection Value: A matrix or vector of the partially projected observations, where rows represent observations and columns represent the lower-dimensional space ``` -------------------------------- ### R Package Testing Patterns Source: https://github.com/bbuchsbaum/multivarious/blob/master/CLAUDE.md This section describes the testing methodology and patterns used in the 'multivarious' R package, focusing on file naming conventions, assertion types, edge case handling, and verification of preprocessing and caching effects. ```APIDOC Tests use testthat and follow these patterns: - Test files are named `test_.R`. - Use `expect_equal()` with tolerance for numeric comparisons. - Test both standard and edge cases (empty data, single observation, etc.). - Verify that preprocessing is correctly reversed. - Check that caching doesn't affect results. ``` -------------------------------- ### APIDOC: prep() - Apply Pre-processing Pipeline Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/index.html Prepares a dataset by applying a defined sequence of pre-processing steps. ```APIDOC prep(): prepare a dataset by applying a pre-processing pipeline ``` -------------------------------- ### APIDOC: init_transform() - Initialize Transform Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/index.html Initializes a pre-processing transform, setting up its parameters. ```APIDOC init_transform(): initialize a transform ``` -------------------------------- ### R Package Key Design Patterns Source: https://github.com/bbuchsbaum/multivarious/blob/master/CLAUDE.md This section outlines the fundamental design patterns implemented in the 'multivarious' R package, including the use of S3 generics, a sophisticated preprocessing pipeline, a caching strategy, and support for partial operations. ```APIDOC 1. S3 Generic Functions: - All major operations (`project`, `reconstruct`, `truncate`, etc.) are implemented as S3 generics with method dispatch. 2. Preprocessing Pipeline: - Sophisticated preprocessing system where each step has `forward()`, `apply()`, and `reverse()` methods. 3. Caching Strategy: - Expensive computations (inverse projections, etc.) are cached in each projector's `.cache` environment. 4. Partial Operations: - Framework supports projecting/reconstructing subsets of variables via `partial_project()` and related functions. ``` -------------------------------- ### R Package Common Development Tasks for New Projectors Source: https://github.com/bbuchsbaum/multivarious/blob/master/CLAUDE.md This section outlines the standard steps required when adding a new projector type to the 'multivarious' R package, from class inheritance and method implementation to input validation, testing, and documentation updates. ```APIDOC When adding a new projector type: 1. Inherit from appropriate base class (`projector`, `bi_projector`, etc.). 2. Implement required methods (`project`, `reconstruct`, etc.). 3. Add appropriate S3 method implementations in relevant files. 4. Include input validation using `chk` package. 5. Add comprehensive tests. 6. Update documentation with examples. ``` -------------------------------- ### Initialize a new pre-processing pipeline with prepper (R) Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/prepper.html This function constructs and returns an empty pre-processing pipeline object. It serves as the initial step for building a sequence of data transformations using the `multivarious` package in R. ```R prepper() ``` -------------------------------- ### Define bi_projector function signature and parameters Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/bi_projector.html Documents the `bi_projector` function, its parameters, and return value for creating a bi-directional projection object. It specifies the required input matrices, optional pre-processing, and class attributes. ```APIDOC bi_projector(v, s, sdev, preproc = prep(pass()), classes = NULL, ...) Arguments: v: A matrix of coefficients with dimensions `nrow(v)` by `ncol(v)` (number of columns = number of components) s: The score matrix sdev: The standard deviations of the score matrix preproc: (optional) A pre-processing pipeline, default is prep(pass()) classes: (optional) A character vector specifying the class attributes of the object, default is NULL ...: Extra arguments to be stored in the `projector` object. Value: A bi_projector object ``` -------------------------------- ### R: svd_wrapper Function API Reference Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/svd_wrapper.html Documents the `svd_wrapper` function in R, detailing its parameters (X, ncomp, preproc, method, q, p, tol, ...), their types, default values, and purpose, along with the return value, which is an SVD object extending `projector`. ```APIDOC svd_wrapper( X, ncomp = min(dim(X)), preproc = pass(), method = c("fast", "base", "irlba", "propack", "rsvd", "svds"), q = 2, p = 10, tol = .Machine$double.eps, ... ) Arguments: X: the input matrix ncomp: the number of components to estimate (default: min(dim(X))) preproc: the pre-processor to apply on the input matrix (e.g., center(), standardize(), pass()) method: the SVD method to use: 'base', 'fast', 'irlba', 'propack', 'rsvd', or 'svds' q: parameter passed to method rsvd (default: 2) p: parameter passed to method rsvd (default: 10) tol: minimum eigenvalue magnitude, otherwise component is dropped (default: .Machine$double.eps) ...: extra arguments passed to the selected SVD function Value: an SVD object that extends projector ``` -------------------------------- ### APIDOC: print() - Pretty Print projector Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/index.html A method for pretty printing objects of the `projector` class. ```APIDOC print(): Pretty Print Method for projector Objects ``` -------------------------------- ### R Package Core Projector Class Hierarchy Source: https://github.com/bbuchsbaum/multivarious/blob/master/CLAUDE.md This section describes the hierarchical system of projector classes within the 'multivarious' R package, detailing their purpose and key attributes for dimensionality reduction and mapping. ```APIDOC 1. `projector` - Base class for all dimensionality reduction methods. - Attributes: - `v`: Coefficient matrix for projection. - `preproc`: Preprocessing pipeline. - `.cache`: Environment for performance caching. 2. `bi_projector` - Extends `projector` for two-way mappings (e.g., PCA, SVD). - Additional Attributes: - `s`: Scores matrix. - `sdev`: Standard deviations. - Supports both row and column projections. 3. `cross_projector` - Designed for two-block methods (e.g., CCA). - Maintains separate coefficients for X and Y blocks. - Enables cross-domain transfer operations. 4. `composed_projector` - Chains multiple projectors sequentially. 5. `multiblock_projector` - Handles concatenated blocks of variables. ``` -------------------------------- ### APIDOC: print() - Pretty Print bi_projector Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/index.html An S3 method for pretty printing objects of the `bi_projector` class. ```APIDOC print(): Pretty Print S3 Method for bi_projector Class ``` -------------------------------- ### APIDOC: print() - Pretty Print composed_projector Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/index.html A method for pretty printing objects of the `composed_projector` class. ```APIDOC print(): Pretty Print Method for composed_projector Objects ``` -------------------------------- ### APIDOC: concat_pre_processors() - Concatenate Blockwise Pre-processors Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/index.html Binds multiple blockwise pre-processors together into a single pipeline. ```APIDOC concat_pre_processors(): bind together blockwise pre-processors ``` -------------------------------- ### APIDOC: regress Function Reference Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/regress.html Defines the `regress` function for multi-output linear regression, outlining its parameters such as independent and response variables, preprocessing options, regression methods (lm, enet, mridge, pls), intercept inclusion, and method-specific parameters like lambda, alpha, and ncomp. It also specifies the return type as a bi-projector. ```APIDOC regress( X, Y, preproc = NULL, method = c("lm", "enet", "mridge", "pls"), intercept = FALSE, lambda = 0.001, alpha = 0, ncomp = ceiling(ncol(X)/2), ... ) Arguments: X: the set of independent (basis) variables Y: the response matrix preproc: the pre-processor (currently unused) method: the regression method: `lm`, `enet`, `mridge`, or `pls` intercept: whether to include an intercept term lambda: ridge shrinkage parameter (for methods `mridge` and `enet`) alpha: the elastic net mixing parameter if method is `enet` ncomp: number of PLS components if method is `pls` ...: extra arguments sent to the underlying fitting function Value: a bi-projector of type `regress` ``` -------------------------------- ### APIDOC: print() - Pretty Print bi_projector_union Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/index.html An S3 method for pretty printing objects of the `bi_projector_union` class. ```APIDOC print(): Pretty Print S3 Method for bi_projector_union Class ``` -------------------------------- ### R Function: project_vars API Documentation Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/project_vars.html Documents the `project_vars` function, which projects one or more variables onto a subspace. It details the function's signature, arguments (x, new_data, ...), and return value. ```APIDOC project_vars(x, new_data, ...) Arguments: x: The model fit, typically an object of a class that implements a `project_vars` method new_data: A matrix or vector of new observation(s) with the same number of rows as the original data ...: Additional arguments passed to the underlying `project_vars` method Value: A matrix or vector of the projected variables in the subspace ``` -------------------------------- ### APIDOC: print() - Pretty Print multiblock_biprojector Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/index.html A method for pretty printing objects of the `multiblock_biprojector` class. ```APIDOC print(): Pretty Print Method for multiblock_biprojector Objects ``` -------------------------------- ### APIDOC: bootstrap() - Multivariate Model Resampling Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/index.html Performs bootstrap resampling for multivariate models to estimate confidence intervals. ```APIDOC bootstrap(): Bootstrap Resampling for Multivariate Models ``` -------------------------------- ### APIDOC: perm_ci() - Permutation Confidence Intervals Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/index.html Calculates confidence intervals using permutation methods. ```APIDOC perm_ci(): Permutation Confidence Intervals ``` -------------------------------- ### APIDOC: bootstrap() - PCA Bootstrap Resampling Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/index.html Applies bootstrap resampling specifically for Principal Component Analysis (PCA) models. ```APIDOC bootstrap(): PCA Bootstrap Resampling ``` -------------------------------- ### R: Define a No-Operation Pre-processing Step Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/pass.html The `pass` function in the `multivarious` package implements a no-operation pre-processing step. It accepts a `preproc` argument, which is expected to be a pre-processing pipeline (a `prepper` list), and returns it unchanged. This function is useful when a step in a processing chain needs to be explicitly defined but should not alter the data. ```R pass(preproc = prepper()) ``` -------------------------------- ### APIDOC: reprocess() - Apply Pre-processing to New Data Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/index.html Applies existing pre-processing parameters to a new data matrix. ```APIDOC reprocess(): apply pre-processing parameters to a new data matrix ``` -------------------------------- ### APIDOC: classifier() - Classifier from Projector Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/index.html Generates a classifier object based on an existing projector. ```APIDOC classifier(): create classifier from a projector ``` -------------------------------- ### R: Add Pre-processing Node to Pipeline (add_node) Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/add_node.html Documents the `add_node` function, used to append a pre-processing step to a given processing pipeline. It takes the pipeline object, the step to add, and optional extra arguments. ```APIDOC Function: add_node Usage: add_node(x, step, ...) Arguments: x: The processing pipeline. step: The pre-processing step to add. ...: Extra arguments to be passed to the pre-processing step. ``` -------------------------------- ### APIDOC: rf_classifier() - Random Forest Classifier from Projector Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/index.html Creates a random forest classifier, potentially leveraging an existing projector. ```APIDOC rf_classifier(): create a random forest classifier ``` -------------------------------- ### R: Reprocess new data using existing model parameters Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/reprocess.html This API documentation describes the 'reprocess' function, which is designed to apply pre-processing parameters from an existing model fit object to a new data matrix. It ensures that new data is transformed consistently with the data used to train the original model. ```APIDOC reprocess(x, new_data, colind, ...) x: The model fit object containing the pre-processing parameters. new_data: The new data matrix to be processed. colind: The column indices of the new data that correspond to the original data's columns. ...: Additional arguments passed to or from other methods. ``` -------------------------------- ### APIDOC: classifier() - k-NN Classifier for Discriminant Projector Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/index.html Constructs a k-Nearest Neighbors (k-NN) classifier specifically tailored for use with a discriminant projector. ```APIDOC classifier(): Create a k-NN classifier for a discriminant projector ``` -------------------------------- ### APIDOC: apply_transform() - Apply Pre-processing Transform Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/index.html Applies a specified pre-processing transform to data. ```APIDOC apply_transform(): apply a pre-processing transform ``` -------------------------------- ### APIDOC: rf_classifier() - Random Forest Wrapper Classifier Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/index.html Constructs a wrapper classifier utilizing the random forest algorithm. ```APIDOC rf_classifier(): construct a random forest wrapper classifier ``` -------------------------------- ### APIDOC: add_node() - Add Pre-processing Stage Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/index.html Adds a new stage or node to a pre-processing pipeline. ```APIDOC add_node(): add a pre-processing stage ``` -------------------------------- ### APIDOC: print() - Pretty Print classifier Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/index.html A method for pretty printing objects of the `classifier` class. ```APIDOC print(): Pretty Print Method for classifier Objects ``` -------------------------------- ### APIDOC: classifier() - Multiblock Bi-Projector Classifier Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/index.html Creates a classifier designed for multiblock bi-projector models. ```APIDOC classifier(): Multiblock Bi-Projector Classifier ``` -------------------------------- ### R Function: center a data matrix Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/center.html API documentation for the 'center' function in the 'multivarious' R package. This function is used to remove the mean of all columns in a data matrix, returning a 'prepper' list. It can optionally take a pre-processing pipeline and precomputed column means. ```APIDOC Function: center Usage: center(preproc = prepper(), cmeans = NULL) Arguments: preproc: the pre-processing pipeline cmeans: optional vector of precomputed column means Value: a `prepper` list ``` -------------------------------- ### APIDOC: center() - Center Data Matrix Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/index.html Centers a data matrix by subtracting the mean of each column. ```APIDOC center(): center a data matrix ``` -------------------------------- ### APIDOC: classifier() - Construct Generic Classifier Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/index.html A general function to construct a classifier object. ```APIDOC classifier(): Construct a Classifier ``` -------------------------------- ### Model Construction Functions Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/index.html Functions within the 'multivarious' package that are used to compute various multivariate decompositions, providing core model building capabilities. ```APIDOC pca(): Principal Components Analysis (PCA) svd_wrapper(): Singular Value Decomposition (SVD) Wrapper regress(): Multi-output linear regression ``` -------------------------------- ### multivarious residuals function API documentation Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/residuals.html Provides the API signature, arguments, and return value for the `residuals` function within the `multivarious` R package, which calculates model residuals after factoring out specified components. ```APIDOC residuals(x, ncomp, xorig, ...) Arguments: x: The model fit object. ncomp: The number of components to factor out before calculating residuals. xorig: The original data matrix (X) used to fit the model. ...: Additional arguments passed to the method. Value: A matrix of residuals, with the same dimensions as the original data matrix. ``` -------------------------------- ### API Documentation for `truncate` function in R Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/truncate.html Details the `truncate` function, which is used to take the first 'ncomp' components of a decomposition from an object 'x'. ```APIDOC truncate(x, ncomp) Arguments: x: the object to truncate ncomp: number of components to retain ``` -------------------------------- ### R Function: project_block API Reference Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/project_block.html Documents the `project_block` function, which projects a specific block of data onto a subspace. This function is designed for multi-block fits and is equivalent to a partial projection. ```APIDOC project_block(x, new_data, block, ...) x: The model fit, typically an object of a class that implements a `project_block` method new_data: A matrix or vector of new observation(s) with the same number of columns as the original data block: An integer representing the block ID to select in the block projection matrix. This ID corresponds to the specific block of data to be projected ...: Additional arguments passed to the underlying `project_block` method Returns: A matrix or vector of the projected data for the specified block ``` -------------------------------- ### APIDOC: reverse_transform() - Reverse Pre-processing Transform Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/index.html Reverses a previously applied pre-processing transform. ```APIDOC reverse_transform(): reverse a pre-processing transform ``` -------------------------------- ### APIDOC: standardize() - Center and Scale Data Matrix Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/index.html Centers and scales each vector (column) of a data matrix, typically to unit variance. ```APIDOC standardize(): center and scale each vector of a matrix ``` -------------------------------- ### R Function: block_indices Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/block_indices.html API documentation for the `block_indices` function, which extracts the list of indices associated with each block in a `multiblock` object. It details the function's usage and parameters. ```APIDOC Function: block_indices Description: extract the list of indices associated with each block in a multiblock object Usage: block_indices(x, ...) Arguments: x: the object ...: extra args ``` -------------------------------- ### APIDOC: residuals() - Obtain Model Residuals Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/index.html Retrieves the residuals from a fitted component model. ```APIDOC residuals(): Obtain residuals of a component model fit ``` -------------------------------- ### R: Check Orthogonality of Components Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/is_orthogonal.html This snippet demonstrates the usage of the `is_orthogonal` function in R. It takes an object `x` as input and determines if its components are orthogonal. ```R is_orthogonal(x) ``` -------------------------------- ### R Function: reconstruct Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/reconstruct.html Documents the `reconstruct` function, detailing its purpose, parameters, and return value for reconstructing data from a low-rank representation. This function is useful for analyzing dimensionality reduction impacts or visualizing data approximations. ```APIDOC reconstruct(x, comp, rowind, colind, ...) Arguments: x: The model fit, typically an object of a class that implements a `reconstruct` method comp: A vector of component indices to use in the reconstruction rowind: The row indices to reconstruct (optional). If not provided, all rows are used. colind: The column indices to reconstruct (optional). If not provided, all columns are used. ...: Additional arguments passed to the underlying `reconstruct` method Value: A reconstructed data set based on the selected components, rows, and columns ``` -------------------------------- ### Model Components and Properties Functions Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/index.html Functions for inspecting and manipulating the components and properties of fitted multivariate models, including retrieving scores, standard deviations, and checking orthogonality. ```APIDOC components(): get the components scores(): Retrieve the component scores std_scores(): Compute standardized component scores sdev(): standard deviations ncomp(): Get the number of components shape(): Shape of the Projector is_orthogonal(): is it orthogonal truncate(): truncate a component fit block_lengths(): get block_lengths block_indices(): get block_indices nblocks(): get the number of blocks prinang(): Compute principal angles for a set of subspaces ``` -------------------------------- ### APIDOC: predict() - Predict with Classifier Object Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/index.html Performs predictions using a given classifier object. ```APIDOC predict(): predict with a classifier object ``` -------------------------------- ### R Function: inverse_projection API Reference Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/inverse_projection.html API documentation for the `inverse_projection` function. This function computes the inverse projection matrix, enabling the transformation of data from a component space back to its original data space. It accepts a model fit and optional extra arguments, returning the calculated inverse projection matrix. ```APIDOC inverse_projection(x, ...) x: The model fit. ...: Extra arguments. Returns: The inverse projection matrix. ``` -------------------------------- ### Model Fitting and Projection Functions Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/index.html Functions for fitting multivariate models and applying various types of projections to new or existing data within the 'multivarious' package. This includes operations like residualization, reconstruction, and composing projectors. ```APIDOC project(): New sample projection residualize(): Compute a regression model for each column in a matrix and return residual matrix partial_project(): Partially project a new sample onto subspace partial_projector(): Construct a partial projector project_block(): Project a single "block" of data onto the subspace project_vars(): Project one or more variables onto a subspace transpose(): Transpose a model reconstruct(): Reconstruct the data inverse_projection(): Inverse of the Component Matrix partial_inverse_projection(): Partial Inverse Projection of a Columnwise Subset of Component Matrix compose_projector(): Compose Two Projectors compose_projectors(): Projector Composition refit(): refit a model nystrom_embedding(): Nystrom method for out-of-sample embedding ``` -------------------------------- ### APIDOC: pass() - No-Operation Pre-processing Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/index.html A pre-processing step that performs no operation, useful for pipeline management. ```APIDOC pass(): a no-op pre-processing step ``` -------------------------------- ### APIDOC: colscale() - Scale Data Matrix Columns Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/index.html Scales the columns of a data matrix. ```APIDOC colscale(): scale a data matrix ``` -------------------------------- ### Rotation and Transformation Functions Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/index.html Functions for rotating and transforming model components, allowing for manipulation of the latent space to achieve desired orientations or transfer data between different input domains. ```APIDOC rotate(): Rotate a Component Solution apply_rotation(): Apply rotation convert_domain(): Transfer data from one input domain to another via common latent space ``` -------------------------------- ### Cross Projection Functions Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/index.html Functions specifically designed for creating and working with 'cross_projectors', enabling two-way projection between two distinct sets of variables or features. ```APIDOC project(__): project a cross_projector instance coef(__): Extract coefficients from a cross_projector object reprocess(__): reprocess a cross_projector instance shape(__): shape ``` -------------------------------- ### R Function: sdev Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/sdev.html Documents the `sdev` function, which computes the standard deviations of the projected data matrix. It requires a model fit object as input. ```R sdev(x) Arguments: x: the model fit ``` -------------------------------- ### APIDOC: group_means() - Compute Grouped Column Means Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/index.html Computes the column-wise mean of matrix X for each factor level defined in Y. ```APIDOC group_means(): Compute column-wise mean in X for each factor level of Y ``` -------------------------------- ### Multivariate Model Classes and Extension Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/index.html Generic S3 classes designed to represent multivariate model fits and facilitate their extension within the 'multivarious' package. These classes provide structured representations for various projection types. ```APIDOC projector(): Construct a 'projector' instance bi_projector(): Construct a bi_projector instance bi_projector_union(): A Union of Concatenated 'bi_projector' Fits discriminant_projector(): Construct a Discriminant Projector cross_projector(): Two-way (cross) projection to latent components multiblock_biprojector(): Create a Multiblock Bi-Projector multiblock_projector(): Create a Multiblock Projector partial_projector(__): construct a partial_projector from a 'projector' instance ``` -------------------------------- ### R Function: Extract Component Scores (`scores`) Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/scores.html Documents the 'scores' function, which extracts the factor score matrix from a fitted model. The resulting matrix contains projections of data onto components, useful for analysis or visualization. ```APIDOC scores(x, ...) x: The model fit object. ...: Additional arguments passed to the method. Returns: A matrix of factor scores, with rows corresponding to samples and columns to components. ``` -------------------------------- ### R Function: colscale for Data Matrix Scaling Source: https://github.com/bbuchsbaum/multivarious/blob/master/docs/reference/colscale.html Documents the `colscale` function from the `multivarious` package, used to normalize columns of a data matrix. It supports unit norm, z-scoring, or custom weights for scaling, and integrates with a pre-processing pipeline. ```APIDOC colscale(preproc = prepper(), type = c("unit", "z", "weights"), weights = NULL) Arguments: preproc: the pre-processing pipeline type: the kind of scaling, unit norm, z-scoring, or precomputed weights weights: optional precomputed weights Value: a prepper list ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.