{"id":18014332,"url":"https://github.com/wwbrannon/sqlscore","last_synced_at":"2025-03-26T18:30:33.394Z","repository":{"id":56936934,"uuid":"75883375","full_name":"wwbrannon/sqlscore","owner":"wwbrannon","description":"R utilities for generating SQL queries from model objects","archived":false,"fork":false,"pushed_at":"2019-03-17T16:48:36.000Z","size":156,"stargazers_count":13,"open_issues_count":1,"forks_count":4,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-22T05:51:08.424Z","etag":null,"topics":["glm","r","sql"],"latest_commit_sha":null,"homepage":null,"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/wwbrannon.png","metadata":{"files":{"readme":"README.Rmd","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-07T23:11:23.000Z","updated_at":"2024-08-14T17:52:48.000Z","dependencies_parsed_at":"2022-08-21T05:50:46.479Z","dependency_job_id":null,"html_url":"https://github.com/wwbrannon/sqlscore","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wwbrannon%2Fsqlscore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wwbrannon%2Fsqlscore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wwbrannon%2Fsqlscore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wwbrannon%2Fsqlscore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wwbrannon","download_url":"https://codeload.github.com/wwbrannon/sqlscore/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245712431,"owners_count":20660238,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["glm","r","sql"],"created_at":"2024-10-30T04:07:49.391Z","updated_at":"2025-03-26T18:30:33.034Z","avatar_url":"https://github.com/wwbrannon.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- rmarkdown v1 --\u003e\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r set-options, echo=FALSE, cache=FALSE}\nlibrary(sqlscore)\nlibrary(knitr)\n\noptions(width=80)\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"README-\",\n  warning = FALSE,\n  message = FALSE,\n  echo = TRUE,\n  tidy = TRUE,\n  size=\"small\",\n  linewidth=80\n)\n\n# From https://github.com/yihui/knitr-examples/blob/master/077-wrap-output.Rmd\nhook_output = knit_hooks$get('output')\nknit_hooks$set(output = function(x, options) {\n  # this hook is used only when the linewidth option is not NULL\n  if (!is.null(n \u003c- options$linewidth)) {\n    x = knitr:::split_lines(x)\n    # any lines wider than n should be wrapped\n    if (any(nchar(x) \u003e n)) x = strwrap(x, width = n)\n    x = paste(x, collapse = '\\n')\n  }\n  hook_output(x, options)\n})\n```\n\n[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/sqlscore)](https://cran.r-project.org/package=sqlscore)\n[![Build Status](https://img.shields.io/travis/wwbrannon/sqlscore.svg?style=flat)](https://travis-ci.org/wwbrannon/sqlscore)\n[![Coverage Status](https://codecov.io/gh/wwbrannon/sqlscore/branch/master/graph/badge.svg)](https://codecov.io/github/wwbrannon/sqlscore?branch=master)\n[![Downloads](https://cranlogs.r-pkg.org/badges/sqlscore)](https://cran.r-project.org/package=sqlscore)\n[![License](https://img.shields.io/:license-mit-blue.svg?style=flat)](https://wwbrannon.mit-license.org/)\n\n# sqlscore\n\nUtilities for scoring GLMs and related models in SQL. Use the create_statement\nand select_statement functions to generate scoring queries from model objects.\nThe most important use case is for very large scoring datasets, especially those\nwhich can't fit into memory or would require too much network or storage I/O if\nscored the usual way in R.\n\nThe SQL-generating functions in sqlscore handle various formula operators, and\nalso take care of wrapping the model's linear predictor in the appropriate link\nfunction. If needed, you can also specify a custom link function.\n\n## Usage:\nThe SQL-generating functions create\\_statement and select\\_statement do what their\nnames suggest and generate CREATE TABLE and SELECT statements for model scoring.\n\nIf, for example, you have a database table of iris measurements, you can model the\nsepal length and generate predictions as follows:\n```\nmod \u003c- glm(Sepal.Length ~ Sepal.Width + Petal.Length + Petal.Width + Species,\n           data=datasets::iris)\n\ncreate_statement(mod, src_table=\"iris\", dest_table=\"iris_scores\", pk=c(\"id\"))\n```\n\n```{r, echo = FALSE}\nmod \u003c- glm(Sepal.Length ~ Sepal.Width + Petal.Length + Petal.Width + Species,\n           data=datasets::iris)\n\ncreate_statement(mod, src_table=\"iris\", dest_table=\"iris_scores\")  \n```\n\nTo get a SELECT statement that's not wrapped in a CREATE TABLE (so that, e.g.,\nyou can add your own database-specific pieces of SQL), use select_statement:\n```\nmod \u003c- glm(Sepal.Length ~ Sepal.Width + Petal.Length + Petal.Width + Species,\n           data=datasets::iris)\n\nselect_statement(mod, src_table=\"iris\", pk=c(\"id\"))\n```\n\n```{r, echo = FALSE}\nmod \u003c- glm(Sepal.Length ~ Sepal.Width + Petal.Length + Petal.Width + Species,\n           data=datasets::iris)\n\nselect_statement(mod, src_table=\"iris\")\n```\n\nHelper functions include linpred(), which generates an R call object representing\nthe linear predictor, and score_expression, an S3 generic that handles wrapping\nthe linear predictor in the response function.\n\n## Supported model types:\nSpecific packages and models that are known to work include: glm and lm from\npackage:stats, cv.glmnet from package:glmnet, glmboost from package:mboost,\nand bayesglm from package:arm.\n\nDefault S3 methods are for objects structured like those of class \"glm\", so\nmodels not listed here may work if they resemble those objects, but are not \nguaranteed to.\n\n## Installation:\nInstall the released version from CRAN:\n```\ninstall.packages('sqlscore')\n```\n\nInstall the dev version from github:\n```\ninstall.packages(\"devtools\")\ndevtools::install_github(\"wwbrannon/sqlscore\")\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwwbrannon%2Fsqlscore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwwbrannon%2Fsqlscore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwwbrannon%2Fsqlscore/lists"}