-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathload_train_data.py
More file actions
29 lines (24 loc) · 926 Bytes
/
load_train_data.py
File metadata and controls
29 lines (24 loc) · 926 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
WeChat: cstutorcs
QQ: 749389476
Email: tutorcs@163.com
import numpy as np
import pandas as pd
import os
if __name__ == '__main__':
data_dir = 'data_reviews'
x_train_df = pd.read_csv(os.path.join(data_dir, 'x_train.csv'))
y_train_df = pd.read_csv(os.path.join(data_dir, 'y_train.csv'))
N, n_cols = x_train_df.shape
print("Shape of x_train_df: (%d, %d)" % (N,n_cols))
print("Shape of y_train_df: %s" % str(y_train_df.shape))
# Print out the first five rows and last five rows
tr_text_list = x_train_df['text'].values.tolist()
rows = np.arange(0, 5)
for row_id in rows:
text = tr_text_list[row_id]
print("row %5d | y = %d | %s" % (row_id, y_train_df.values[row_id,0], text))
print("...")
rows = np.arange(N - 5, N)
for row_id in rows:
text = tr_text_list[row_id]
print("row %5d | y = %d | %s" % (row_id, y_train_df.values[row_id,0], text))