Skip to content

Instantly share code, notes, and snippets.

@lmorillas
Last active July 6, 2022 10:48
Show Gist options
  • Save lmorillas/50b5e94fb48d19125fd48ab055850f1f to your computer and use it in GitHub Desktop.
Save lmorillas/50b5e94fb48d19125fd48ab055850f1f to your computer and use it in GitHub Desktop.
Uso de sklearn.model_selection para dividir un modelo
from sklearn.model_selection import train_test_split
'''
Documentación https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.train_test_split.html
divide un dataframe (df):
* 80% train
* 10% validate
* 10% test
'''
train, test_and_validate = train_test_split(df, test_size=0.2, random_state=42, stratify=df['class'])
test, validate = train_test_split(test_and_validate, test_size=0.5, random_state=42, stratify=test_and_validate['class'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment