Can someone explain to me what exactly this section of code does please?

Viewed 17

This is a section of code copied from some software I use:

# Group Splitting for train & Val (Dev)
if not is_predict:
    
  gss_train_val = GroupShuffleSplit(n_splits=1,
                                    test_size=(1/4),
                                    random_state=42).split(train_dataset,
                                                          groups=train_dataset['id'])

  X_train_inds, X_val_inds = next(gss_train_val)

  training_data = train_dataset.iloc[X_train_inds]
  val_data = train_dataset.iloc[X_val_inds]

  training_data.reset_index(drop=True)
  val_data.reset_index(drop=True)

  # Group Splitting for train & test (Dev)
  gss_train_test = GroupShuffleSplit(n_splits=1,
                                    test_size=(1/Vars.FOLDS),
                                    random_state=42).split(training_data,
                                                            groups=training_data['id'])

  X_train_inds, X_test_inds = next(gss_train_test)

  train_data = training_data.iloc[X_train_inds]
  test_data = training_data.iloc[X_test_inds]

  train_data.reset_index(drop=True)
  test_data.reset_index(drop=True)

What I am curious about is varying the test data size to see the effect on accuracy, and also altering the random_state value. E.G. if I alter test_size=(1/4) to test_size=(1/3), does this effectively test a bigger data sample, and potentially increase accuracy? Am I likely to break anything by messing about with these numbers; as long as I note the original script, I should be able to re-run the software and be back where I started? Thanks in advance for any help

0 Answers
Related