Skip to main content

An easy-to-use Python regression library.

Project description

nemreg

A lightweight regression framework built on top of SciPy.

nemreg is designed to make regression analysis structured, compact, and easy to use — without sacrificing flexibility.
It wraps scipy.optimize.curve_fit in a clean scientific workflow that includes dataset handling, statistics, summaries, and plotting.


Install nemreg

install nemreg

Why nemreg?

SciPy is extremely powerful — but low-level.
With SciPy alone, you must manually:

  • Prepare data shapes
  • Compute residuals
  • Compute R² / RMSE / χ²
  • Handle uncertainties
  • Write plotting code
  • Structure outputs

nemreg provides this structure for you.

import nemreg as nr

ds = nr.Dataset(x, y, yerr=1.0)
res = nr.fit(ds, nr.models.linear())
nr.plot(mode="result_data", dataset=ds, result=res)

That’s it.


Features

  • Clean Dataset abstraction (1D and multivariable)
  • Weighted and unweighted regression
  • Automatic statistics:
    • RMSE
    • χ²
    • Reduced χ²
  • Structured FitResult object
  • Built-in plotting dispatcher
  • Built-in models (linear, polynomial, etc.)
  • Support for replicated measurements
  • Clean summary output
  • Multivariable regression support

Installation

Clone the repository and install dependencies:

pip install numpy scipy matplotlib

Optional:

pip install pytest jupyter

Then install nemreg (editable mode recommended):

pip install -e .

Quick Start

import numpy as np
import nemreg as nr

x = np.linspace(-5, 5, 40)
y = 2.5*x - 1 + np.random.normal(0, 1, size=x.size)

ds = nr.Dataset(x=x, y=y)
res = nr.fit(ds, nr.models.linear())
nr.plot(mode="result_data", dataset=ds, result=res)

Project Philosophy

nemreg is not meant to replace SciPy.

It is meant to:

  • Reduce boilerplate
  • Encourage structured analysis
  • Improve readability
  • Make regression workflows easier to teach and share

SciPy remains the optimization engine under the hood.


Note from the Author

This library is intended for free use and free sharing, as it was created in the spirit of making regression easier for everyone.

Please refer to the LICENCE file for details on usage, modification, and redistribution.

The author strongly recommends browsing through the nemreg_demo.ipynb file.
It allows you to:

  • Verify dependencies
  • Confirm your environment works correctly
  • See example workflows
  • Explore available commands

Planned Features

  • LaTeX export for automatic report generation
  • Native Levenberg–Marquardt (LM) core implementation, trying to improve the regression capabilities on more complex functions
  • Additional diagnostics (influence, leverage, etc.)
  • Robust fitting / outlier handling
  • Extended model library
  • Improved multivariable visualization

License

See the LICENCE file for full details.


Contributing

Contributions, suggestions, and improvements are welcome.
Please open an issue or submit a pull request.


Acknowledgements

Built on top of:

  • NumPy
  • SciPy
  • Matplotlib

These libraries power the numerical engine behind nemreg.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nemreg-0.1.0.tar.gz (37.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nemreg-0.1.0-py3-none-any.whl (51.7 kB view details)

Uploaded Python 3

File details

Details for the file nemreg-0.1.0.tar.gz.

File metadata

  • Download URL: nemreg-0.1.0.tar.gz
  • Upload date:
  • Size: 37.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for nemreg-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3a560f9d4da5d18147f3b5046e113865f6f19ed8d0a854250de63d3ec10aa466
MD5 2ffd06b93724467e1466b1657fbab5e7
BLAKE2b-256 ba9e2749d82ee12416556abeb870b4f7b9c9cb7f57ae36c6dbbcfe1dbfe09f1f

See more details on using hashes here.

File details

Details for the file nemreg-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: nemreg-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 51.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for nemreg-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 40347b07a02e6e49267aac592ed361b3e4433dab3cd1876132620ff039340b47
MD5 1b8500349306249a269c36f8792543f4
BLAKE2b-256 a3a73ef46bc615b75d210331ce4a80d5e49a8761cec3ccbba367a45dedf90335

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page