File size: 531 Bytes
cd847b5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3eedd79
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#%% 
import h5py
import pandas as pd
import numpy as np

#%%
with h5py.File("usps.h5", 'r') as hf:
    train = hf.get('train')
    X_tr = train.get('data')[:]
    y_tr = train.get('target')[:]
    test = hf.get('test')
    X_te = test.get('data')[:]
    y_te = test.get('target')[:]

# %%
X_training = np.concatenate((X_tr, y_tr.reshape(-1, 1)), axis=1)
X_test = np.concatenate((X_te, y_te.reshape(-1, 1)), axis=1)

# %%
pd.DataFrame(X_training).to_csv("train.csv", index=False)
pd.DataFrame(X_test).to_csv("test.csv", index=False)