Skip to main content

Statistical Analysis and Regression Library

Project description

SARlib: Statistical Analysis and 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 Analysis 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.4.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.4-py3-none-any.whl (23.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sarlib-0.0.4.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.4.tar.gz
Algorithm Hash digest
SHA256 e9cd6eeb522e5443a32042931441b16110491ff3339bfe23dcbdfd574bdd5a9a
MD5 10e052d23877ed395ee3b06eba1b7579
BLAKE2b-256 987278c3f4fb45ecca1a562262c2d2190661ea68d9434f003e4b4b724e13da24

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sarlib-0.0.4-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.4-py3-none-any.whl
Algorithm Hash digest
SHA256 5054cfebb9d4bff51d0794e0366f9b89b109067decf06ffb5230c287fc628eb2
MD5 53cb33cab34a3e4e0b796093be34ddbd
BLAKE2b-256 ad4de42ee12ddd2a53c30176f1c388291345e5bfbc2358b70797b0d1c45bd287

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