new inclusion of the second step: python-exercises

This commit is contained in:
2025-12-03 13:14:52 +01:00
parent ee8c81afbd
commit 52552e20cb
5 changed files with 1447 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
import numpy as np
# set seed
np.random.seed(1)
# Number of observations in the dataset
n = len(default_data)
# Randomly shuffle the indices of the dataset
indices = np.random.permutation(n)
# Compute training and validation sample sizes
nT = int(0.7 * n) # Training sample size
# Split the dataset based on shuffled indices
n_train = indices[:nT] # First 70% for training
n_test = indices[nT:] # Remaining 30% for validation
# Create training and validation datasets
train_data = default_data.iloc[n_train]
test_data = default_data.iloc[n_test]