Find Best Tree Segmentation — estimador de segmentação binária fiel ao Capítulo 4 da tese (Santos, UFPE 2010)
Project description
fbtseg
Implementação em Python do método FBTSeg (Find Best Tree Segmentation, originalmente nomeado RISKSEG) proposto na tese de Roberto Angelo Fernandes Santos (UFPE, 2010) e nos artigos ICAI 2012 e ICTAI 2012. Estimador sklearn-compatível, focado em alvo binário e reprodução fiel dos resultados publicados.
Instalação
pip install fbtseg
ou em modo desenvolvimento:
pip install -e .[test]
Uso rápido
from fbtseg import FBTSeg, article_uci_preset
model = article_uci_preset(categorical_features=("workclass", "education"))
model.fit(X_train, y_train)
proba = model.predict_proba(X_test)[:, 1]
print(model.plot_model_tree())
summary = model.get_summary()
Custom:
from fbtseg import FBTSeg
model = FBTSeg(
max_depth=3,
min_samples_leaf=0.05,
metric="error",
top_k_variables=1, # rQtdeVarTeste
n_numeric_bins=4, # rQtdeDivisoes
grouping_features=("education",), # rUsaBlocos
max_group_size=2, # rQtdeBlocos
combiner_method="stacking", # ou 'marginal_odds'
prediction_mode="leaf", # 'leaf' | 'pair_combiner' | 'cascade' | 'global_stacking'
drop_split_feature_in_children=True,
)
model.fit(X_train, y_train)
Como funciona
Em cada nó terminal o método:
- Faz screening fatorial — uma regressão por variável candidata, incluindo dummies da variável, efeitos principais e interações.
- Para a(s) melhor(es) variável(eis), testa segmentações binárias (categoria-vs-complemento ou grupo de categorias).
- Treina especialistas para cada segmento e os combina por
StackingouMarginal Odds. - Aceita a divisão se ela melhora a métrica D em validação interna (com tolerância configurável de ganho mínimo / perda máxima).
- Recorre nos filhos até atingir profundidade máxima ou esgotar candidatos.
A predição é vetorizada por folha (1 chamada a predict_proba por
folha, não 1 por linha) — 50× a 3000× mais rápida que implementações
ingênuas.
CLI
# Treinar e salvar
fbtseg fit --dataset chess --preset article_uci --output-dir runs/chess
# CSV próprio
fbtseg fit --csv data.csv --target y --preset thesis \
--categorical cat_col_1 cat_col_2
# Predição com modelo salvo
fbtseg predict --model runs/chess/model.pkl --csv new_data.csv --output preds.csv
Reprodução do paper ICAI 2012
# Tabela 1 do paper — Linear/Logistic/MLP × bases UCI
python scripts/run_paper_table_replication.py --datasets chess magic spambase german \
--n-splits 3 --output-dir artifacts/paper_table
# Datasets sintéticos do ICTAI 2012
python scripts/validate_ictai_synthetic.py --datasets 1 2 3 4 \
--sizes 1000 3000 5000 --n-replications 10
Destaques de fidelidade
| Dataset | Base | Paper Simple | Paper FBTSeg | fbtseg Simple | fbtseg |
|---|---|---|---|---|---|
| Chess | Logistic | 2.60% | 1.02% | 2.41% | 1.41% |
| Magic | Logistic | 20.98% | 18.69% | 20.96% | 16.07% |
| Magic | Linear | 32.03% | 16.06% | 21.61% | 16.93% |
| Spambase | Linear | 14.89% | 13.51% | 11.15% | 10.45% |
Detalhes em docs/paper_table_replicated.md.
Estrutura do repositório
fbtseg/ # pacote (estimator, views, tree, combiners, metrics, base_learners, datasets, CLI)
tests/ # testes (33 cobrindo fit, predict, presets, base learners, métricas)
scripts/ # scripts de reprodução dos experimentos
docs/ # documentação + reference (tese + 2 PDFs)
artifacts/ # resultados de execuções
trash/v1/ # implementação anterior (V1), preservada para auditoria histórica
Documentação
- docs/fbtseg.md: API completa + mapeamento parâmetros tese ↔ código.
- docs/paper_table_replicated.md: replicação da Tabela 1 do ICAI 2012.
- docs/benchmark_final.md: benchmark fbtseg vs LR.
- docs/examples/quickstart.py: notebook linear executável.
- CHANGELOG.md: histórico de versões.
Licença
MIT. Use, copie, modifique e distribua livremente.
Citação
Se você usa este pacote em pesquisa, cite a tese e/ou os artigos:
@phdthesis{santos2010metodo,
author = {Santos, Roberto Angelo Fernandes},
title = {Um Método para Segmentação de Preditores},
school = {Universidade Federal de Pernambuco},
year = {2010},
url = {http://www.cin.ufpe.br/~roberto/AlunosPG/Teses/2010-PhD-Roberto.zip},
}
@inproceedings{santos2012comparing,
author = {Santos, Roberto Angelo Fernandes and Barros, Roberto Souto Maior de},
title = {Comparing Segmentation Methods with Different Base Classifiers},
booktitle = {Proceedings of the 2012 International Conference on Artificial Intelligence (ICAI 2012)},
year = {2012},
}
@inproceedings{santos2012fbtseg,
author = {Santos, Roberto Angelo Fernandes and Barros, Roberto Souto Maior de},
title = {Comparing FBTSeg and NNTree Implementations with Established Ensemble Methods},
booktitle = {Proceedings of the 24th IEEE International Conference on Tools with Artificial Intelligence (ICTAI 2012)},
year = {2012},
}
Referências
- SANTOS, R. A. F. Um Método para Segmentação de Preditores. Tese (Doutorado em Ciência da Computação) — Centro de Informática, UFPE, Recife, 2010. Orientador: Prof. Dr. Roberto Souto Maior de Barros. (docx)
- SANTOS, R. A. F.; BARROS, R. S. M. Comparing Segmentation Methods with Different Base Classifiers. In: Proceedings of the International Conference on Artificial Intelligence (ICAI), Las Vegas, USA, 2012. (PDF)
- SANTOS, R. A. F.; BARROS, R. S. M. Comparing FBTSeg and NNTree Implementations with Established Ensemble Methods. In: Proceedings of the IEEE International Conference on Tools with Artificial Intelligence (ICTAI), Athens, Greece, 2012. (PDF)
Para citações completas (BibTeX) e referências secundárias citadas pelos artigos (Wolpert 1992 — Stacking, Thomas et al. 2002 — Marginal Odds, Maji 2008 — NNTree, etc.), veja docs/references.md.
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 Distribution
Built Distribution
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 fbtseg-0.2.1.tar.gz.
File metadata
- Download URL: fbtseg-0.2.1.tar.gz
- Upload date:
- Size: 47.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ce4e51630f62d18a76c27ba0f5bcacc911d13497061f06531b41cb4c8612678
|
|
| MD5 |
107023703ae7beb48c89bdf91dfa8fd8
|
|
| BLAKE2b-256 |
93a56a96b45e4774acd4d54708c82a4b9df5f5d7a7d256a977cbe7f9c9e09e47
|
File details
Details for the file fbtseg-0.2.1-py3-none-any.whl.
File metadata
- Download URL: fbtseg-0.2.1-py3-none-any.whl
- Upload date:
- Size: 44.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c52c5ec76f04e5df569623843df6bb59ff27b4e3c8da1a25ba5cdff06a741193
|
|
| MD5 |
251d636fefe27ff1deb9c9c186c986f3
|
|
| BLAKE2b-256 |
fab26e6b1ef1e9469e3608aa5b435ee2fb47f4d4125df0d91fabda050269f020
|