Skip to content

r.regression.multi: Add JSON support #6075

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

NishantBansal2003
Copy link
Contributor

Fixes: #6010

This PR adds JSON support to the r.regression.multi module. The JSON output looks like:

{
 "n": 5250,
 "Rsq": 0.11506060292031361,
 "Rsqadj": 0.11455453769133173,
 "RMSE": 0.026742231300608307,
 "MAE": 0.020033893876888382,
 "F": 227.36318626709763,
 "b0": 0.05114332327652484,
 "AIC": -38017.8682981307,
 "AICc": -38017.8682981307,
 "BIC": -37991.60436470836,
 "predictor1": "elevation",
 "b1": 0.0015163347280906883,
 "F1": 637.1296966058939,
 "AIC1": -37418.09754711971,
 "AICc1": -37418.09754711971,
 "BIC1": -37406.96558040854,
 "predictor2": "aspect",
 "b2": 2.2652561928494878e-05,
 "F2": 51.058508308209774,
 "AIC2": -37969.0179184159,
 "AICc2": -37969.0179184159,
 "BIC2": -37957.885951704724,
 "predictor3": "slope",
 "b3": 0.002806567566624831,
 "F3": 115.70987418133342,
 "AIC3": -37905.32879012771,
 "AICc3": -37905.32879012771,
 "BIC3": -37894.19682341653
}

This PR includes the following changes:

  1. Adds a format option with shell, and json modes for output formatting.
  2. Adds format = shell option; the -g flag is now deprecated.
  3. Adds tests covering each of the new formats.
  4. Adds a Python example to the documentation for parsing JSON output.

NOTE: For multiple mapx values, I kept the JSON structure flat, just like the shell output. Let me know if a nested (array) structure would make more sense.

@github-actions github-actions bot added raster Related to raster data processing Python Related code is in Python C Related code is in C module docs markdown Related to markdown, markdown files tests Related to Test Suite CMake labels Jul 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C Related code is in C CMake docs markdown Related to markdown, markdown files module Python Related code is in Python raster Related to raster data processing tests Related to Test Suite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feat] Add JSON output to r.regression.multi
1 participant