split_data_in_k_folds_2.py 844 B

12345678910111213141516171819202122
  1. def create_kfold_directories(K_FOLDS):
  2. try:
  3. os.mkdir("folds")
  4. except:
  5. print("Directory 'folds' already exists")
  6. for i in range(K_FOLDS):
  7. try:
  8. os.mkdir(f"folds/fold{i}/")
  9. os.mkdir(f"folds/fold{i}/train")
  10. os.mkdir(f"folds/fold{i}/validation")
  11. os.mkdir(f"folds/fold{i}/train/Alarmed")
  12. os.mkdir(f"folds/fold{i}/train/Annoyed")
  13. os.mkdir(f"folds/fold{i}/train/Curious")
  14. os.mkdir(f"folds/fold{i}/train/Relaxed")
  15. os.mkdir(f"folds/fold{i}/validation/Alarmed")
  16. os.mkdir(f"folds/fold{i}/validation/Annoyed")
  17. os.mkdir(f"folds/fold{i}/validation/Curious")
  18. os.mkdir(f"folds/fold{i}/validation/Relaxed")
  19. except:
  20. print("Can't create directory because it already exists")