Skip to main content

Statistical Agnostic Regression Library

Project description

SARlib: Statistical Agnostic Regression Library

This library provides tools for statistical analysis, regression modeling, sample size analysis, and visualization. It includes OLS and SAR models, as well as utilities for data preprocessing and plotting.

A formal description and analysis are included in the following reference:

J. M. Gorriz, J. Ramirez, F. Segovia, C. Jimenez-Mesa, F. J. Martinez-Murcia, y J. Suckling, «Statistical agnostic regression: A machine learning method to validate regression models», Journal of Advanced Research, may 2025, doi: 10.1016/j.jare.2025.04.026.

Installation

SARlib can be installed via PyPI:

pip install sarlib

Alternatively, you can install it manually by downloading the source code. In that case, make sure you have the following dependencies installed:

  • numpy
  • matplotlib
  • statsmodels
  • scikit-learn
  • scipy

Main Components

Classes:

  • SAR: Statistical Agnostic Regression with PAC-Bayes, Vapnik, and IGP bounds.

  • OLS: Ordinary Least Squares regression with permutation-based significance and power analysis.

  • SampleSizeAnalysis: Analyzes the effect of sample size on model performance and statistics.

Functions:

  • fix_data(x, y): Standardizes and cleans input data.

  • show_scatter(x, y, ...): Visualizes predictors vs. response.

Usage

  1. Import packages and prepare your data as numpy arrays:

    from sarlib import SAR, OLS, SampleSizeAnalysis, show_scatter
    import numpy as np
    x = np.random.randn(100, 3)  # predictors
    y = np.random.randn(100)     # response
    
  2. Visualize data:

    show_scatter(x, y)
    
  3. Fit SAR model:

    model_sar = SAR(n_realiz=100, norm='epsins', alpha=0.05)
    stats_sar = model_sar.fit(x, y, verbose=True)
    
  4. Compare with an OLS model:

    model_ols = OLS(n_realiz=100, alpha=0.05)
    stats_ols = model_ols.fit(x, y, verbose=True)
    
  5. Analyze sample size effect:

    analysis = SampleSizeAnalysis(model_sar, x, y, steps=7)
    analysis.plot_loss()
    analysis.plot_pvalue()
    analysis.plot_coef()
    

Function/Class Documentation

All functions and classes are documented with docstrings. Please refer to the code for parameter details and usage.

Author & License

Author: Sipba Group, UGR, https://sipba.ugr.es/

Please cite: J. M. Gorriz, J. Ramirez, F. Segovia, C. Jimenez-Mesa, F. J. Martinez-Murcia, y J. Suckling, «Statistical agnostic regression: A machine learning method to validate regression models», Journal of Advanced Research, may 2025, doi: 10.1016/j.jare.2025.04.026.

License: GPL Version 3

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

sarlib-0.0.5.tar.gz (23.7 kB view details)

Uploaded Source

Built Distribution

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

sarlib-0.0.5-py3-none-any.whl (23.0 kB view details)

Uploaded Python 3

File details

Details for the file sarlib-0.0.5.tar.gz.

File metadata

  • Download URL: sarlib-0.0.5.tar.gz
  • Upload date:
  • Size: 23.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.11

File hashes

Hashes for sarlib-0.0.5.tar.gz
Algorithm Hash digest
SHA256 979f54284399eee9855b582fa2e0b61272bd9a8eab966f176e9318637b6ee16b
MD5 6f87ee8005ed2a4ea139b30cee1b79f4
BLAKE2b-256 8a42489b2ae6159c0a0a89682032e605dde7ac222880b6683622d2f3c7ae9422

See more details on using hashes here.

File details

Details for the file sarlib-0.0.5-py3-none-any.whl.

File metadata

  • Download URL: sarlib-0.0.5-py3-none-any.whl
  • Upload date:
  • Size: 23.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.11

File hashes

Hashes for sarlib-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 df3a7a543d76009d747de11a596277edbc3008f5d46e579b53268a7807cbf2e8
MD5 c64f0382228a3863cd7fa5e8805c496d
BLAKE2b-256 4b9ae49ccb34299e7b6e43544bb414e5bee7ea96e1ca70cc5cc437565bdc3736

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