Skip to main content

Statistical library for descriptive, inferential, and computational analysis

Project description

StatsLibX

StatsLibX

Estadística descriptiva, inferencial y computacional para Python — con pandas, polars y ViewX.

PyPI version Python versions License MIT GitHub stars

Documentación · Notebook API · Issues · ViewX


StatsLibX es una librería de Python moderna para análisis estadístico y ciencia de datos. Ofrece una API clara basada en clases, soporte dual pandas / polars, datasets embebidos, preprocesamiento, estadística computacional y un puente de reportes con ViewX.

Versión actual: 0.2.9 · Autor: Emmanuel Ascendra


Novedades en v0.2.9

Área Cambio
Arquitectura Capa Backend unificada en todos los módulos de dominio
Polars load_dataset(backend="polars") y constructores compatibles con pl.DataFrame
API DescriptiveStats.from_file(), InferentialStats.from_file(), ComputationalStats.help()
Preprocessing clean_data() ampliado (escalado, outliers, transforms) y change_dtypes() con polars
ViewX to_report_data() — serializa resultados statslibx para Report / HTML
Packaging pyproject.toml, extras opcionales, CLI statslibx, marcador py.typed
Docs web Sitio Next.js v0.2.9, playground Pyodide alineado con la API real

Instalación

pip install statslibx

Extras opcionales

# ViewX (reportes HTML, slides, matrices)
pip install statslibx[viewx]

# Regresión avanzada (statsmodels / sklearn)
pip install statslibx[statsmodels,sklearn]

# Excel + todo incluido
pip install statslibx[excel]
pip install statslibx[all]
Extra Paquetes
viewx viewx ≥ 0.2.3
statsmodels statsmodels ≥ 0.13
sklearn scikit-learn ≥ 1.0
excel openpyxl ≥ 3.0
all Todos los anteriores

Requisitos: Python ≥ 3.9 · numpy · pandas · scipy · matplotlib · seaborn · plotly · sympy


Inicio rápido

import statslibx as slx
from statslibx import DescriptiveStats, InferentialStats, ComputationalStats, Preprocessing
from statslibx.datasets import load_iris, generate_dataset

print(f"StatsLibX v{slx.__version__}")

# Cargar dataset embebido (iris, penguins, titanic)
iris = load_iris()
print(iris.head())

# Estadística descriptiva
ds = DescriptiveStats(iris)
print(ds.mean("sepal_length"))
print(ds.summary())

# Prueba inferencial
inf = InferentialStats(iris)
print(inf.t_test_1sample("sepal_length", popmean=5.8))

# Desde archivo
stats = DescriptiveStats.from_file("mi_datos.csv")

# Datos sintéticos
schema = {
    "age": {"dist": "normal", "mean": 35, "std": 10, "type": "int"},
    "group": {"dist": "categorical", "choices": ["A", "B", "C"]},
}
df = generate_dataset(n_rows=500, schema=schema, seed=42)

Motores de datos (pandas / polars)

Todas las clases que reciben DataFrames soportan el parámetro backend:

from statslibx import DescriptiveStats, InferentialStats, ComputationalStats, Preprocessing

df = load_iris()

# Auto-detecta: pandas DataFrame → pandas, polars DataFrame → polars
DescriptiveStats(df)
InferentialStats(df)
ComputationalStats(df)
Preprocessing(df)

# Forzar motor polars (convierte pandas → polars internamente)
DescriptiveStats(df, backend="polars")
InferentialStats(df, backend="polars")
ComputationalStats(df, backend="polars")
Preprocessing(df, backend="polars")

# Forzar motor pandas (convierte polars → pandas)
# InferentialStats(pl_df, backend="pandas")

# Desde archivo
DescriptiveStats.from_file("datos.csv", backend="polars")
InferentialStats.from_file("datos.csv", backend="polars")
ComputationalStats.from_file("datos.csv", backend="polars")
Preprocessing.from_file("datos.csv", backend="polars")

# Inspeccionar motor activo
stats = DescriptiveStats(df, backend="polars")
print(stats.backend)  # "polars"

Carga directa con polars:

from statslibx.datasets import load_dataset

df = load_dataset("iris.csv", backend="polars")  # requiere pip install polars
stats = DescriptiveStats(df)
print(stats.backend)  # "polars" (auto-detectado)

Módulos

Clase / Módulo Descripción
DescriptiveStats Media, mediana, varianza, correlación, regresión lineal, outliers, resúmenes
InferentialStats t-tests, ANOVA, chi-cuadrado, intervalos de confianza, normalidad
ComputationalStats Regresión polinomial, bootstrap, k-means, interpolación, correlación
Preprocessing Limpieza, nulos, escalado, outliers, calidad de datos, dtypes
UtilsStats Carga de archivos, visualización (matplotlib / seaborn / plotly), effect size
datasets load_dataset, load_iris, load_penguins, generate_dataset
Backend Abstracción pandas / polars (statslibx.backend)
viewx HTML, Slides, Report, DataMatrix, to_report_data

Integración ViewX

StatsLibX se conecta con ViewX para generar reportes y visualizaciones a partir de resultados estadísticos.

from statslibx import DescriptiveStats, Report, to_report_data

df = load_iris()
summary = DescriptiveStats(df).summary()

ViewX example

pip install statslibx[viewx]

CLI — Terminal

StatsLibX incluye una interfaz de línea de comandos para explorar CSV sin escribir código.

statslibx data iris.csv --summary --types --missing
statslibx describe iris.csv --numeric
statslibx describe iris.csv --categorical
statslibx quality iris.csv --verbose
statslibx preview iris.csv -n 10
statslibx info iris.csv --detailed
statslibx --help

Estadística computacional

from statslibx import ComputationalStats

cs = ComputationalStats(df, seed=42)

# Regresión con términos de interacción
model = cs.regression(X=["age", "score"], y="income", interaction_terms=True)
print(model.get_formula())
print(model.summary())

# Bootstrap
boot = cs.bootstrapping("income", n_samples=1000, statistic="mean")
print(boot.summary())

# Clustering
kmeans = cs.k_means(k=3)
elbow = cs.elbow_method(max_k=10)

Preprocesamiento

pp = Preprocessing(df)

pp.data_quality()
pp.clean_data(
    drop_duplicates=True,
    handle_missing=True,
    missing_strategy="median",
    scale=True,
    scaling_method="standard",
    remove_outliers=True,
)
pp.preview_data(n=5)

Documentación

Recurso Enlace
Documentación estática GitHub Pages
Notebook completo (181 celdas) how_use_statslibx.ipynb
Repositorio github.com/GhostAnalyst30/StatsLibX
ViewX ViewX Page

Estructura del paquete

statslibx/
├── descriptive.py      # DescriptiveStats, DescriptiveSummary, LinearRegressionResult
├── inferential.py      # InferentialStats, TestResult
├── computational.py    # ComputationalStats, RegressionResult, BootstrappingResult
├── preprocessing/      # Preprocessing
├── datasets/           # iris, penguins, titanic + generate_dataset
├── utils.py            # UtilsStats (I/O, plots, outliers)
├── backend.py          # Backend pandas / polars
├── viewx/              # Puente ViewX + to_report_data
├── cli.py              # statslibx CLI
└── py.typed            # PEP 561 typed package

Contribuciones

¡Todas las mejoras e ideas son bienvenidas!

Abre un issue o un pull request en GitHub.

Contacto: ascendraemmanuel@gmail.com


Desarrollado por Emmanuel Ascendra · StatsLibX v0.2.9 · MIT License

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

statslibx-0.2.9.tar.gz (4.7 MB view details)

Uploaded Source

Built Distribution

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

statslibx-0.2.9-py3-none-any.whl (4.8 MB view details)

Uploaded Python 3

File details

Details for the file statslibx-0.2.9.tar.gz.

File metadata

  • Download URL: statslibx-0.2.9.tar.gz
  • Upload date:
  • Size: 4.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for statslibx-0.2.9.tar.gz
Algorithm Hash digest
SHA256 82ecb15723c10fccee8a293b1a0687a9f05a0445dec76996af79d826da7f69a9
MD5 05f0ac0f4c018315e5e2c27504758647
BLAKE2b-256 98914b0de0a22acd36dbd306220e04371241227ad663f6b3d593cff307d57653

See more details on using hashes here.

File details

Details for the file statslibx-0.2.9-py3-none-any.whl.

File metadata

  • Download URL: statslibx-0.2.9-py3-none-any.whl
  • Upload date:
  • Size: 4.8 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for statslibx-0.2.9-py3-none-any.whl
Algorithm Hash digest
SHA256 4a4eba3d71a2d8296b83966c71450115ae41b6c74b41c08668403f76d11b7990
MD5 8aa80e638a83a9aabf2bc10974b888e6
BLAKE2b-256 a6c3c32d651d1b62e1e4db094709e77a93c4e1adf4d136853afa3ca5c39769da

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