Skip to main content

Advanced regression methods with sklearn-like interface

Project description

Better Regressions

Advanced regression methods with an sklearn-like interface.

Current Features

  • Linear regression with configurable regularization:
    • Ridge regression with alpha parameter
    • Automatic Relevance Determination (ARD) regression
    • "Better bias" option to properly regularize the intercept term
  • Input/target scaling wrapper with multiple normalization methods:
    • Standard scaling (zero mean, unit variance)
    • Quantile transformation with uniform output
    • Quantile transformation with normal output

Installation

pip install better-regressions

With uv:

uv pip install better-regressions

Basic Usage

import numpy as np
from better_regressions.linear import Linear
from better_regressions.scaling import Scaler
from sklearn.datasets import make_regression

# Create sample data
X, y = make_regression(n_samples=100, n_features=5, noise=0.1)

# Ridge regression with better bias handling
model = Linear(alpha=1e-6, better_bias=True)

# Wrap model with standard scaling for both inputs and targets
scaled_model = Scaler(model, x_method="standard", y_method="standard")
scaled_model.fit(X, y)
predictions = scaled_model.predict(X)

# Access model parameters
print(f"Coefficients: {model.coef_}")
print(f"Intercept: {model.intercept_}")

# ARD regression with quantile-normal scaling
ard_model = Linear(alpha="ard", better_bias=True)
ard_scaled = Scaler(ard_model, x_method="quantile-normal", y_method="standard")
ard_scaled.fit(X, y)

Project Structure

better-regressions/
├── better_regressions/       # Main package
│   ├── __init__.py           # Package initialization
│   ├── linear.py             # Linear regression models
│   ├── scaling.py            # Data normalization wrappers
│   └── repr_utils.py         # Utility for model representations
└── tests/                    # Test directory
    └── test_linear.py        # Linear model tests

Development

This project uses uv for dependency management:

# Clone the repository
git clone https://github.com/yourusername/better-regressions.git
cd better-regressions

# Create a virtual environment and install dependencies
uv venv
uv pip install -e ".[dev]"

# Run tests
python -m tests.test_linear

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

better_regressions-0.1.0.tar.gz (342.7 kB view details)

Uploaded Source

Built Distribution

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

better_regressions-0.1.0-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: better_regressions-0.1.0.tar.gz
  • Upload date:
  • Size: 342.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.11

File hashes

Hashes for better_regressions-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ae2e3ddfa737e778f248cc264e110fddf94a6ce57ff53d46e76906088d009615
MD5 c6b09d1a199548a0887e2e5cd9022923
BLAKE2b-256 747a7a0d6df4700a8aab6dd55e2f224fc1881fd36b0d9e309fba0d89ac2dafb3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for better_regressions-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 55b8d999508a620aee50fbbb5f0d7c4319708c90b4c8b27e6aeb00b858721b99
MD5 a8f92171426d587ea6c499a4ff78b159
BLAKE2b-256 df766db1f7974f28b752830608039a7a3e920b8e52349cdae361ae789ed3e771

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