BizAnalyticsAI
Advanced Data Analysis & Business Intelligence Library for Python
BizAnalyticsAI é uma biblioteca Python avançada para análise de grandes volumes de dados de negócios. Combina ferramentas estatísticas, KPIs financeiros, simulação de Monte Carlo, análise de coorte, clustering, forecasting de séries temporais e geração automática de relatórios — tudo em uma API fluente e intuitiva.
Instalação
pip install bizanalyticsai
Com suporte a Supabase:
pip install bizanalyticsai[supabase]
Instalação completa (inclui XGBoost, LightGBM, Prophet):
pip install bizanalyticsai[full]
Início Rápido
import bizanalyticsai as bai
# ── Carregar e limpar dados ──────────────────────────────────────────────────
df = bai.read_csv("vendas.csv")
df = bai.clean(df)
# ── Perfil dos dados ─────────────────────────────────────────────────────────
profile = df.profile()
print(f"Rows: {profile['shape']['rows']:,} | Cols: {profile['shape']['cols']}")
desc = bai.describe(df)
print(desc) # stats + insights automáticos
# ── KPIs Financeiros ─────────────────────────────────────────────────────────
kpis = bai.finance.kpis(
df,
revenue_col="revenue",
cost_col="cost",
customer_col="customer_id",
date_col="date",
cac=350,
monthly_churn_pct=4.5,
)
print(kpis.summary())
print("Investable?", kpis.is_investable()) # LTV/CAC ≥ 3, margin ≥ 60%, payback ≤ 24mo
# ── Simulação Monte Carlo ────────────────────────────────────────────────────
mc = bai.finance.montecarlo(
initial_revenue=50_000,
growth_pct=8,
fixed_costs=20_000,
variable_cost_pct=25,
initial_investment=300_000,
months=24,
iterations=10_000,
seed=42,
)
print(mc.summary())
# P10: -124.500 | P50: 342.800 | P90: 1.2M | Bankruptcy: 4.2%
# ── Análise de Churn & LTV ───────────────────────────────────────────────────
churn = bai.finance.churn(df, customer_col="customer_id", date_col="date")
print(churn.summary())
# ── Cohort Retention ─────────────────────────────────────────────────────────
retention = bai.finance.cohort_retention(df, "customer_id", "date", "M")
print(retention.head())
# ── Segmentação RFM ──────────────────────────────────────────────────────────
rfm = bai.ml.rfm_segments(df, "customer_id", "date", "revenue")
print(rfm["segment"].value_counts())
# ── Detecção de Anomalias ────────────────────────────────────────────────────
anomalies = bai.ml.detect_anomalies(df, method="isolation_forest")
print(anomalies.summary())
# ── Forecasting de Séries Temporais ─────────────────────────────────────────
import pandas as pd
monthly_revenue = df.set_index("date")["revenue"].resample("M").sum()
forecast = bai.timeseries.forecast(monthly_revenue, horizon=6, method="holtwinters")
print(forecast.forecast)
# ── Market Sizing ────────────────────────────────────────────────────────────
market = bai.market.tam_sam_som(tam=5e9, sam_pct=12, som_pct=8)
print(market.summary())
# ── Probabilidade de Sucesso ─────────────────────────────────────────────────
sp = bai.market.success_probability(
segment="Tecnologia / SaaS",
margin_pct=65, payback_months=12, cac_ratio=3.8,
churn_rate=3, market_size=2e9, growth_trend=2,
team_score=4, has_revenue=True, has_customers=True,
)
print(f"{sp['emoji']} {sp['label']}: {sp['score']}/100")
# ── Relatório HTML ───────────────────────────────────────────────────────────
bai.report.summary_report(df, output="report.html")
Módulos
| Módulo | Descrição |
|---|---|
bai.io |
Leitura de CSV, JSON, Excel, Parquet, SQL, Supabase |
bai.clean |
Limpeza, normalização, outliers, encoding |
bai.stats |
Estatísticas descritivas, correlação, distribuições |
bai.finance |
MRR/ARR, LTV, CAC, Churn, Monte Carlo, Coorte, Break-Even |
bai.ml |
Clustering (K-Means, DBSCAN), RFM, detecção de anomalias |
bai.timeseries |
Holt-Winters, ARIMA, SARIMA, trend, sazonalidade |
bai.market |
TAM/SAM/SOM, benchmarks por setor, probabilidade de sucesso |
bai.viz |
Gráficos Plotly e Matplotlib (bar, line, scatter, heatmap) |
bai.report |
Relatórios HTML, Markdown e JSON automatizados |
BizFrame |
DataFrame com métodos de BI embutidos |
Pipeline |
Pipeline declarativo com timing por etapa |
Pipeline Declarativo
from bizanalyticsai import Pipeline, read_csv, clean, normalize, remove_outliers
result = (
Pipeline("etl_vendas")
.read(read_csv, "vendas.csv")
.step("clean", clean)
.step("outliers", remove_outliers)
.step("normalize", lambda df: normalize(df, cols=["revenue"], method="minmax"))
.filter("revenue > 0")
.select("customer_id", "revenue", "cost", "date")
.sort("revenue", ascending=False)
.limit(10_000)
.run()
)
print(result.pipeline.report())
CLI
# Perfil de dados
bizai profile dados.csv
# Relatório HTML
bizai report dados.csv --output report.html --title "Análise de Vendas"
# Simulação Monte Carlo
bizai montecarlo \
--revenue 50000 \
--growth 8 \
--fixed-costs 20000 \
--investment 300000 \
--months 24
# Versão
bizai version
Monte Carlo — Detalhes
A simulação usa o método Box-Muller para gerar números aleatórios gaussianos sem dependências externas. Em cada iteração:
- Receita é perturbada:
actualRevenue = revenue × N(1, σ) - Custos calculados:
totalCost = fixedCosts + actualRevenue × variablePct - Fluxo de caixa:
cash += actualRevenue - totalCost - Crescimento:
revenue *= (1 + N(growthPct, 0.02)) - Falência se
cash < -3 × investimento inicial
Retorna: P10, P25, P50, P75, P90, média, desvio padrão, % de falência.
Benchmarks por Setor
A biblioteca inclui benchmarks para 9 setores brasileiros baseados em dados reais (SaaStr, ChartMogul, Bessemer, McKinsey, CB Insights):
| Setor | Churn/mês | LTV/CAC médio | Margem Bruta | Taxa Sucesso 5a |
|---|---|---|---|---|
| Tecnologia / SaaS | 3.2% | 3.5× | 72% | 22% |
| E-commerce | 6.5% | 2.2× | 38% | 18% |
| Saúde | 2.5% | 4.2× | 55% | 28% |
| Educação | 4.8% | 2.8× | 60% | 20% |
| Indústria | 1.8% | 4.5× | 30% | 32% |
Deploy para PyPI
Configuração Trusted Publisher (recomendado — sem API keys)
-
Adicione um novo publisher:
- PyPI project name:
bizanalyticsai - Owner: seu usuário GitHub
- Repository:
bizanalyticsai-python - Workflow:
publish.yml - Environment:
pypi
- PyPI project name:
-
Crie a tag e faça push:
git tag v1.0.0 git push origin v1.0.0
O GitHub Actions fará o build, testes e publish automaticamente.
Publicação manual
pip install build twine
python -m build
twine upload dist/* # PyPI
twine upload --repository testpypi dist/* # TestPyPI
Testando a instalação
pip install --index-url https://test.pypi.org/simple/ bizanalyticsai
# ou após o publish oficial:
pip install bizanalyticsai
Requisitos
- Python ≥ 3.9
- numpy ≥ 1.24
- pandas ≥ 2.0
- scipy ≥ 1.10
- scikit-learn ≥ 1.3
- statsmodels ≥ 0.14
- matplotlib ≥ 3.7
- plotly ≥ 5.15
- rich ≥ 13.0
- jinja2 ≥ 3.1
- pyarrow ≥ 12.0
Licença
MIT — veja LICENSE.
BizAnalyticsAI © 2024 — bizanalyticsai.com.br
Metadata
Release files for bizanalyticsai 1.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bizanalyticsai-1.0.2.tar.gz | 51.5 kB | Without provenance | Details for bizanalyticsai-1.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bizanalyticsai-1.0.2-py3-none-any.whl | Python 3 | none | any | Details for bizanalyticsai-1.0.2-py3-none-any.whl |
Total release size: 103.1 kB
Release files / bizanalyticsai-1.0.2.tar.gz
| Download URL | bizanalyticsai-1.0.2.tar.gz |
|---|---|
| Size | 51.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8689d226bee7dcbadac6b2a34e196827b75dd4ac237157be9894f3ceec4a6f33
|
|
BLAKE2b-256 checksum How to use checksums |
597f6e143f324ec708dd3fb4261ee1c061ca93e51bbbbb704edf04dd1b42485f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / bizanalyticsai-1.0.2-py3-none-any.whl
| Download URL | bizanalyticsai-1.0.2-py3-none-any.whl |
|---|---|
| Size | 51.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1ed5232ed66303c5a789d7be01f99bc6e5730e4aedf7ecc863e0b2be7a3c8881
|
|
BLAKE2b-256 checksum How to use checksums |
22ba01789c3823311b7da52a11fa5f5ed02d6e5bbe0588804ef36c49e667edd1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Security for bizanalyticsai 1.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.