{"id":20074887,"url":"https://github.com/ncss-tech/interpretation-engine","last_synced_at":"2025-03-02T12:29:21.585Z","repository":{"id":45136261,"uuid":"51330312","full_name":"ncss-tech/interpretation-engine","owner":"ncss-tech","description":"Stand-alone Interpretation Engine using NASIS rules in R","archived":false,"fork":false,"pushed_at":"2024-07-19T19:25:02.000Z","size":104584,"stargazers_count":7,"open_issues_count":2,"forks_count":2,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-01-13T00:43:42.822Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://ncss-tech.github.io/interpretation-engine/","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ncss-tech.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE.md","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}},"created_at":"2016-02-08T21:59:13.000Z","updated_at":"2024-07-19T19:22:05.000Z","dependencies_parsed_at":"2024-07-17T01:10:17.053Z","dependency_job_id":null,"html_url":"https://github.com/ncss-tech/interpretation-engine","commit_stats":{"total_commits":100,"total_committers":5,"mean_commits":20.0,"dds":"0.44999999999999996","last_synced_commit":"6c95c9dbfead5583478a1d6d5c5419f11613a612"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ncss-tech%2Finterpretation-engine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ncss-tech%2Finterpretation-engine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ncss-tech%2Finterpretation-engine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ncss-tech%2Finterpretation-engine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ncss-tech","download_url":"https://codeload.github.com/ncss-tech/interpretation-engine/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241506701,"owners_count":19973665,"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":[],"created_at":"2024-11-13T14:55:27.890Z","updated_at":"2025-03-02T12:29:21.552Z","avatar_url":"https://github.com/ncss-tech.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"---\noutput: md_document\n---\n\n```{r setup, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \"#\u003e\",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n```\n\n \u003c!-- badges: start --\u003e\n  [![R-CMD-check](https://github.com/ncss-tech/interpretation-engine/actions/workflows/R-CMD-check.yml/badge.svg)](https://github.com/ncss-tech/interpretation-engine/actions/workflows/R-CMD-check.yml)\n[![InterpretationEngine Manual](https://img.shields.io/badge/docs-HTML-informational)](http://ncss-tech.github.io/interpretation-engine/)\n  \u003c!-- badges: end --\u003e\n\n# {InterpretationEngine} (alpha) R package\n\nTo install the alpha version of the \"interpretation engine\" R package use {remotes} to get the latest version from GitHub. This will install all dependencies.\n\n```r\n# install package from ncss-tech interpretation-engine repository                   \nremotes::install_github('ncss-tech/interpretation-engine')\n```\n\n# Interpretations Outside of NASIS\n\nThere are many reasons for wanting to develop, test, and apply interpretations to soil data outside the context of NASIS. This project aims to create a prototype from existing interpretation rules, evaluations, and properties as managed in NASIS. Once the prototype is complete it should be possible to generate fuzzy ratings from arbitrary sources of soil and environmental data sources.\n\n## How Does it Work?\n\nThe [data.tree](https://cran.r-project.org/web/packages/data.tree/vignettes/data.tree.html) package defines objects and methods that are well suited to the task of describing the hierarchy of rules and evaluations. NASIS evaluations utilize  definitions of shape functions and cubic splines, which are further interpolated using `approxfun()` and `splinefun()`. NASIS hedges and operators perform arithmetic operations on numeric matrices to facilitate combining multiple properties and\nevaluations into rules.\n\n## Outline\n1. Load all rules, evaluations, properties into R via ODBC as `data.frame` objects \n3. Load single rule and (recursively) load sub-rules into a `data.tree` object\n4. Load evaluation functions into each terminal node of `data.tree` object \n5. Load hedge and operator functions into each decision node of `data.tree` object\n6. Use wrapper function (`interpret()`) to:\n      - Send properties to evaluation functions\n      - Combine fuzzy values via operators and hedges to generate a final fuzzy rating\n\n## Examples\n\n```{r}\nlibrary(InterpretationEngine)\n```\n\n### Evaluation Curves\n\nThe following images show the output of an evaluation function for slope (`\"*Storie Factor C Slope 0 to 100%\"`) in NASIS.\n\n```{r}\neval \u003c- subset(NASIS_evaluations, evalname == \"*Storie Factor C Slope 0 to 100%\")\nplotEvaluation(eval, xlim = c(0, 100))\n\n# zoom in on  custom shape in [0, 8]% slope range\nplotEvaluation(eval, xlim = c(0,8))\n```\n\n### Rule Trees\n\nThe following examples generate data.frame representation of the `data.tree` objects in terms of an input property list, and the hierarchy of rules, operators, hedges, evaluations and properties that define a \"primary rule\" or interpretation.\n\n**Dust PM10 and PM2.5 Generation**\n\n```{r}\n# use initRuleset() to parse a rule by name\nr \u003c- initRuleset(\"Dust PM10 and PM2.5 Generation\")\n\n# view input properties\ngetPropertySet(r)\n\n# view rule tree\ndata.tree::ToDataFrameTree(r, \"Type\", \"Value\", \"RefId\", \"rule_refid\")\n```\n\n\n**California Storie Index**\n\nUsing the `data.tree` representation of the California Storie Index primary rule, we can extract the entire set of evaluations and required properties:\n\n```{r}\nr \u003c- initRuleset(\"AGR - California Revised Storie Index (CA)\")\n\n# view input properties\ngetPropertySet(r)\n\n# view rule tree\ndata.tree::ToDataFrameTree(r, \"Type\", \"Value\", \"RefId\", \"rule_refid\")\n```\n\n## Run a rule tree with custom data\n\nThe `interpret()` function takes a data.frame or SpatRaster where column or variable names correspond to input property names. Property names can be extracted using `getPropertySet()` and then made into compatible names using the base R function `make.names()`.\n\nHere we pick a simple rule that utilizes only one property and evaluation (\"Erodibility Factor Maximum\"). The numeric input to the evaluation function is an erodibility (\"K\") factor ranging from 0 to 1.\n\n```{r}\n# parse rule and properties\nr \u003c- initRuleset(\"Erodibility Factor Maximum\")\np \u003c- getPropertySet(r)\n\n# prepare input data\nkf \u003c- seq(0, 1, 0.01)\ninput \u003c- data.frame(kf = kf)\ncolnames(input) \u003c- make.names(p$propname)\n\n# run interpretation\noutput \u003c- interpret(r, input)\n\n# visualize results\nplot(output$rating ~ input$SOIL.EROSION.FACTOR.MAXIMUM.1.99)\n```\n\n## Resources\n1. MO-6: INTERP-Rule Tree Diagram Chart (Interactive) v1.1+\n\n\n## Sample Spatial Data\nInput data for extended demonstrations by @josephbrehm and others can be found in the `inst/extdata` portion of this repository. \n\nTo have all that data to you can download the repository as a static ZIP file, or \"clone\" with `git`! These larger data sets are not included when the R package is installed with {remotes}. A demonstration script and input boundary files can be found in `/demo` folder.\n\n## Things to Figure Out\n* convert NASIS property scripts into R code (see: https://github.com/brownag/cvirrr/ for an incomplete attempt at this)\n* some properties return an RV, some {low,RV,high}:\n  * alternately, allow for selection of one specific value that can be customized on property basis.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fncss-tech%2Finterpretation-engine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fncss-tech%2Finterpretation-engine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fncss-tech%2Finterpretation-engine/lists"}