Showing
1 changed file
with
29 additions
and
0 deletions
main/split_to_train_test.py
0 → 100644
1 | +# -*- coding: utf-8 -*- | ||
2 | +"""split_to_train_test.ipynb | ||
3 | + | ||
4 | +Automatically generated by Colaboratory. | ||
5 | + | ||
6 | +Original file is located at | ||
7 | + https://colab.research.google.com/drive/16Rn0IDJTE6vJMOZtafDAI19AvGD9eK4C | ||
8 | +""" | ||
9 | + | ||
10 | +import pandas as pd | ||
11 | +from sklearn.model_selection import train_test_split | ||
12 | + | ||
13 | +dataset_url = '/content/drive/MyDrive/2d-slice-set-networks-for-brain-age-master/data/IXI0609.csv' | ||
14 | +data = pd.read_csv(dataset_url) | ||
15 | +print(data.head()) | ||
16 | + | ||
17 | +y = data.age_at_scan | ||
18 | +X = data | ||
19 | + | ||
20 | +X_train, X_test, y_train, y_test = train_test_split(X, y,test_size=0.3) | ||
21 | +print("\nX_train:\n") | ||
22 | +print(X_train.head()) | ||
23 | +print(X_train.shape) | ||
24 | +X_train.to_csv('/content/drive/MyDrive/2d-slice-set-networks-for-brain-age-master/data/train0609.csv', index=False) | ||
25 | + | ||
26 | +print("\nX_test:\n") | ||
27 | +print(X_test.head()) | ||
28 | +print(X_test.shape) | ||
29 | +X_test.to_csv('/content/drive/MyDrive/2d-slice-set-networks-for-brain-age-master/data/test0609.csv', index=False) | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment