SIENTIAPDE-1645: Refactor temporary directory cleanup activity by extracting processing and deletion logic into dedicated helper methods. Update train_test_split to use a local numpy.random generator for improved reproducibility. Remove an unnecessary else: pass block.

This commit is contained in:
Bruno Domingues
2026-08-05 12:10:54 -03:00
parent 4133e200f7
commit e3e1c712a8
3 changed files with 91 additions and 52 deletions

View File

@@ -42,15 +42,13 @@ def train_test_split(
random_state: int | None = None,
shuffle: bool = True,
) -> tuple[pd.DataFrame, pd.DataFrame]:
# 1. Definir a semente (seed) para reprodutibilidade
if random_state is not None:
np.random.seed(random_state)
# 2. Gerar índices e embaralhar se necessário
indices = np.arange(len(data))
if shuffle:
np.random.shuffle(indices)
# 1. Generator local (em vez do estado global np.random) para reprodutibilidade
rng = np.random.default_rng(random_state)
rng.shuffle(indices)
# 3. Calcular o ponto de corte (split point)
# Cálculo: N_treino = tamanho_total * proporcao_treino