Hyunji

Split data set to test and validation set (after split data set to training and test set)

# -*- coding: utf-8 -*-
"""split_to_test_validation.ipynb
Automatically generated by Colaboratory.
Original file is located at
https://colab.research.google.com/drive/16Rn0IDJTE6vJMOZtafDAI19AvGD9eK4C
"""
import pandas as pd
from sklearn.model_selection import train_test_split
dataset_url = '/content/drive/MyDrive/2d-slice-set-networks-for-brain-age-master/data/test0609.csv'
data = pd.read_csv(dataset_url)
print(data.head())
y = data.age_at_scan
X = data
X_train, X_test, y_train, y_test = train_test_split(X, y,test_size=0.3333)
print("\nX_train:\n")
print(X_train.head())
print(X_train.shape)
X_train.to_csv('/content/drive/MyDrive/2d-slice-set-networks-for-brain-age-master/data/test0609.csv', index=False)
print("\nX_test:\n")
print(X_test.head())
print(X_test.shape)
X_test.to_csv('/content/drive/MyDrive/2d-slice-set-networks-for-brain-age-master/data/valid0609.csv', index=False)
\ No newline at end of file