{"id":32199548,"url":"https://github.com/corymccartan/bases","last_synced_at":"2026-02-21T13:01:41.177Z","repository":{"id":294541321,"uuid":"987297107","full_name":"CoryMcCartan/bases","owner":"CoryMcCartan","description":" Basis Expansions for Regression Modeling","archived":false,"fork":false,"pushed_at":"2025-09-21T05:24:56.000Z","size":4648,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-09T02:59:15.398Z","etag":null,"topics":["machine-learning","ml","r","statistics"],"latest_commit_sha":null,"homepage":"http://corymccartan.com/bases/","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CoryMcCartan.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-05-20T21:45:12.000Z","updated_at":"2025-09-21T05:24:59.000Z","dependencies_parsed_at":"2025-09-08T15:48:09.095Z","dependency_job_id":null,"html_url":"https://github.com/CoryMcCartan/bases","commit_stats":null,"previous_names":["corymccartan/bases"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/CoryMcCartan/bases","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CoryMcCartan%2Fbases","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CoryMcCartan%2Fbases/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CoryMcCartan%2Fbases/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CoryMcCartan%2Fbases/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CoryMcCartan","download_url":"https://codeload.github.com/CoryMcCartan/bases/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CoryMcCartan%2Fbases/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29681468,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-21T12:30:22.644Z","status":"ssl_error","status_checked_at":"2026-02-21T12:29:55.402Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["machine-learning","ml","r","statistics"],"created_at":"2025-10-22T03:19:10.860Z","updated_at":"2026-02-21T13:01:41.170Z","avatar_url":"https://github.com/CoryMcCartan.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n)\nset.seed(16802)\n```\n\n# **bases** \u003ca href=\"https://corymccartan.com/bases/\"\u003e\u003cimg src=\"man/figures/logo.png\" align=\"right\" height=\"138\" /\u003e\u003c/a\u003e\n\n\u003c!-- badges: start --\u003e\n[![R-CMD-check](https://github.com/CoryMcCartan/bases/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/CoryMcCartan/bases/actions/workflows/R-CMD-check.yaml)\n[![CRAN status](https://www.r-pkg.org/badges/version/bases)](https://CRAN.R-project.org/package=bases)\n\u003c!-- badges: end --\u003e\n\n**bases** provides various basis expansions for flexible regression modeling,\nincluding:\n\n- random Fourier features (`?b_rff`)\n- exact kernel / Gaussian process feature maps (`?b_ker`)\n- Bayesian additive regression trees (BART) prior features (`?b_bart`)\n- neural network features (`?b_nn`)\n- graph Fourier features (`?b_gff`)\n- random convolutional image features (`?b_conv`)\n- a helpful interface for n-way interactions (`?b_inter`)\n\nThe provided functions may be used within any modeling formula, allowing the use\nof kernel methods and other basis expansions in modeling functions that do not\notherwise support them.\n\nAlong with the basis expansions, a number of kernel functions (`?kernels`)\nare also provided, which support kernel arithmetic to form new kernels. Basic\nridge regression functionality (`?ridge`) is included as well.\n\nFinally, the package provides two ways of interfacing with more complex\nmodeling workflows:\n\n1. Integration with `mgcv`, so that basis expansions can be used as smooth\nterms within `s()`. This enables fitting different levels of penalization to\ndifferent basis expansions.\n\n1. A [recipes](https://recipes.tidymodels.org/)-friendly interface, so that these\nbasis expansions can be combined with other transformations and used within the\n[tidymodels](https://www.tidymodels.org/) framework.\n\n## Installation\n\nYou can install **bases** from CRAN:\n\n```r\ninstall.packages(\"bases\")\n```\n\nYou can install the development version with\n\n```r\nremotes::install_github(\"CoryMcCartan/bases\")\n```\n\n## Example: random Fourier features\n\nThe basis functions in **bases** all start with `b_` and are designed to work in\nthe same way as built-in basis expansions like `bs()` or `poly()`: simply\ninclude the function in a model formula.\n\nSo fitting an approximate kernel regression with random Fourier features is as simple as wrapping the relevant variables in a call to the corresponding basis function, `b_rff()`.\nThe default kernel is a Gaussian/RBF kernel with length scale 1 which is applied to predictors after rescaling them to have unit variance.\n\n```{r}\nlibrary(bases)\n\n# Box \u0026 Jenkins (1976) sales data\nx = 1:150\ny = as.numeric(BJsales)\n\nlm(y ~ b_rff(x, p = 5)) # 5 random features\n```\n\nYou can provide a different `kernel = ` argument to switch kernels.\nMany common kernels are provided with the package; see `?kernels`.\n\n```r\nb_rff(x, kernel = k_matern(scale = 0.1, nu = 5/2))\nb_rff(x, kernel = k_rq(scale = 2, alpha = 2))\n```\n\nIn practice, RFF are usually fit with penalization, such as via ridge regression.\nBelow, we visualize several RFF ridge regression fits versus a simple linear model, using the `ridge()` function provided in the package.\n```{r rbf-plot}\nk = k_rbf(scale = 0.2)\nplot(x, y, xlab = \"Month\", ylab = \"Sales\")\nlines(x, fitted(lm(y ~ x)), lty = \"dashed\", lwd = 1.5)\nfor (i in 1:20) {\n    m_rff = ridge(y ~ b_rff(x, kernel = k))\n    lines(x, fitted(m_rff), col = \"#4584\")\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcorymccartan%2Fbases","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcorymccartan%2Fbases","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcorymccartan%2Fbases/lists"}