Fast OLS and TLS regression using Rust backend
Project description
rustgression
This project provides fast regression analysis (OLS, TLS) as a Python package.
- WebSite: https://pypi.org/project/rustgression/
- Documentation: https://github.com/connect0459/rustgression/blob/main/README.md
- Source code: https://github.com/connect0459/rustgression
- Bug reports and security issues: https://github.com/connect0459/rustgression/issues
Overview
rustgression provides high-performance regression analysis tools implemented in Rust as a Python package.
It includes the following features.
- Ordinary Least Squares (OLS): Traditional least squares method. Minimizes errors only in the y-direction.
- Total Least Squares (TLS): Orthogonal regression. Considers errors in both variables (x-axis and y-axis).
This package targets Python version 3.11 and above.
Installation
pip install rustgression
Usage
import numpy as np
from rustgression import OlsRegressor, TlsRegressor
def generate_sample_data(size: int = 100, noise_std: float = 0.5) -> tuple[np.ndarray, np.ndarray]:
"""Generate sample data for regression example.
Args:
size: Number of data points
noise_std: Standard deviation of noise
Returns:
Tuple of (x, y) arrays
"""
x = np.linspace(0, 10, size)
true_slope, true_intercept = 2.0, 1.0
y = true_slope * x + true_intercept + np.random.normal(0, noise_std, size)
return x, y
def main():
# Generate sample data
x, y = generate_sample_data()
# Ordinary Least Squares (OLS) Regression
print("=== Ordinary Least Squares (OLS) Results ===")
ols_model = OlsRegressor(x, y)
print(f"Slope: {ols_model.slope():.4f}")
print(f"Intercept: {ols_model.intercept():.4f}")
print(f"R-value: {ols_model.r_value():.4f}")
print(f"P-value: {ols_model.p_value():.4e}")
print(f"Standard Error: {ols_model.stderr():.4f}")
print(f"Intercept Standard Error: {ols_model.intercept_stderr():.4f}\n")
# Total Least Squares (TLS) Regression
print("=== Total Least Squares (TLS) Results ===")
tls_model = TlsRegressor(x, y)
print(f"Slope: {tls_model.slope():.4f}")
print(f"Intercept: {tls_model.intercept():.4f}")
print(f"R-value: {tls_model.r_value():.4f}")
if __name__ == "__main__":
main()
Documentation
For detailed documentation in your preferred language.
For developers and contributors.
Author
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rustgression-0.4.1-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: rustgression-0.4.1-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 197.0 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c4922d8c16cebef856f7d0b5996faf8d2ab56322a34cd10466f6c5844b524b8a
|
|
| MD5 |
7882b5807a6c7228f59c4793b06008b4
|
|
| BLAKE2b-256 |
d6ddf50ec74948a669a08606fea68db60c6b358d2b61d0551f65cf70725dfcd1
|
File details
Details for the file rustgression-0.4.1-cp311-cp311-manylinux_2_35_x86_64.whl.
File metadata
- Download URL: rustgression-0.4.1-cp311-cp311-manylinux_2_35_x86_64.whl
- Upload date:
- Size: 349.1 kB
- Tags: CPython 3.11, manylinux: glibc 2.35+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
463fdc4bc6cd23d96e06dbd035985dea560276f277439696aaab6cacaeb95f22
|
|
| MD5 |
4857d6f1cece079aa4aba396d521dc16
|
|
| BLAKE2b-256 |
cbdbd87ecefff45ca1b22c7fe8af2d41da1308c424b627548a2603e6f6f85dc5
|
File details
Details for the file rustgression-0.4.1-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: rustgression-0.4.1-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 297.6 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
70a3c3443406a834f933ef989ebaa8cbcef345891d779e266a22aa569b79e8ca
|
|
| MD5 |
b0f4f42ca4963c2ce6e48403793ba7da
|
|
| BLAKE2b-256 |
ea9d85fd09f938908d378e8321f7461722703b0af38de7ead2f17af15f75c38c
|