split_to_train_test.py
892 Bytes
# -*- coding: utf-8 -*-
"""split_to_train_test.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/IXI0609.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.3)
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/train0609.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/test0609.csv', index=False)