Skip to main content

Parastat: CPU/GPU 并行的数据统计分析库(OLS/GLM、PCA/SVD、Bootstrap/MC)

Project description

Parastat

Parastat 是一个高性能的 CPU/GPU 并行数据统计分析库,旨在通过 NumPy/Pandas 和 CuPy/CuDF 加速核心矩阵运算,提供统计分析和机器学习任务的快速实现。支持的功能包括普通最小二乘法(OLS)、广义线性模型(GLM)、主成分分析(PCA)、奇异值分解(SVD)、Bootstrap 方法和蒙特卡洛模拟(Monte Carlo)。

功能亮点

  • 高效计算:利用 CPU(NumPy/Pandas)或 GPU(CuPy/CuDF)进行矩阵运算,显著提升性能。
  • 核心统计方法
    • 普通最小二乘法(OLS)和广义线性模型(GLM)用于回归分析。
    • 主成分分析(PCA)和奇异值分解(SVD)用于数据降维和分解。
    • Bootstrap 和 Monte Carlo 方法用于统计推断和不确定性分析。
  • 灵活的数据支持:支持 Parquet 文件格式(通过 pyarrow),适合处理大数据集。
  • 命令行工具:提供 parastat 命令行接口,方便快速执行统计任务。

安装

CPU 安装

在 Python 3.8 或以上版本的环境中,使用以下命令安装 Parastat:

pip install parastat

GPU 安装(可选)

若需启用 GPU 加速,需安装 CuPy(支持 CUDA 12.x):

pip install parastat[gpu]

注意:GPU 安装需要 NVIDIA GPU 和兼容的 CUDA 环境。确保已安装 CUDA Toolkit 和 CuPy。

开发安装

若需进行本地开发,克隆仓库并安装开发依赖:

git clone https://github.com/fept-2024/parastat.git
cd parastat
pip install -e .[dev]

开发依赖包括 pytest(测试)、ruff(代码格式化)和 mypy(类型检查)。

Parquet 支持(可选)

若需处理 Parquet 文件,安装 pyarrow

pip install parastat[parquet]

使用示例

以下是一些 Parastat 的基本用法示例:

1. 运行 OLS 回归

import parastat
import numpy as np

# 生成示例数据
X = np.random.rand(100, 3)  # 100 行,3 个特征
y = np.random.rand(100)     # 目标变量

# 执行 OLS 回归
model = parastat.OLS()
model.fit(X, y)
print("系数:", model.coef_)

2. 主成分分析(PCA)

import parastat
import pandas as pd

# 加载数据
data = pd.DataFrame(np.random.rand(100, 5))

# 执行 PCA
pca = parastat.PCA(n_components=2)
pca.fit(data)
transformed_data = pca.transform(data)
print("主成分:", transformed_data)

3. 通过命令行运行统计任务

parastat --task ols --input data.csv --output results.csv

更多命令行选项请运行:

parastat --help

依赖

  • 核心依赖
    • numpy>=1.22
    • pandas>=1.5
  • 可选依赖
    • cupy-cuda12x(GPU 支持)
    • pyarrow>=9(Parquet 文件支持)
  • 开发依赖
    • pytest>=7
    • ruff>=0.5
    • mypy>=1.0

文档

更多详细信息请参考 项目文档(待完善)。包括:

  • API 参考
  • 高级用法(例如 GPU 加速设置)
  • 性能优化建议

贡献

欢迎为 Parastat 贡献代码!请按照以下步骤:

  1. 克隆仓库:

    git clone https://github.com/fept-2024/parastat.git
    
  2. 创建特性分支:

    git checkout -b feature/your-feature
    
  3. 提交更改并运行测试:

    pytest
    ruff check .
    mypy .
    
  4. 推送并创建 Pull Request。

请遵循 贡献指南(待完善)。

许可证

Parastat 使用 MIT 许可证。详情请见 LICENSE 文件。

联系

  • 问题反馈:请在 GitHub 仓库提交 Issue

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

parastat-0.1.1.tar.gz (15.0 kB view details)

Uploaded Source

Built Distribution

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

parastat-0.1.1-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file parastat-0.1.1.tar.gz.

File metadata

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

File hashes

Hashes for parastat-0.1.1.tar.gz
Algorithm Hash digest
SHA256 49132dd414193a7162687783993eb32b7df5aba3c0e71935465eb3d6e4e20b40
MD5 fcf61cd442966ba55b50152d52b0e6ce
BLAKE2b-256 e220864340237b308bcf819b5c14c66d3d83cccf139cc705a2f8f01ef1d2bb0d

See more details on using hashes here.

File details

Details for the file parastat-0.1.1-py3-none-any.whl.

File metadata

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

File hashes

Hashes for parastat-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 716e11c967d92797b77d8b53c1666ee6d3f423765116795ba153f8206d055335
MD5 388ca44a16d1c656fe33f963de5c8cc3
BLAKE2b-256 dd34d05871635ef4cc45aeea05225d55edc630861332c3ed0196b1290e67b29e

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