# In order to manipulate the array
import numpy as np

# In order to load mat file
from scipy.io import loadmat

# Abalone dataset - Convert the ring = 19 to class 1 and the other to class 0

filename = '../../data/raw/mldata/uci-20070111-abalone.mat'
matfile = loadmat(filename)

sex_array = np.zeros(np.ravel(matfile['int1']).shape[0])
sex_array[np.nonzero(np.ravel(matfile['Sex']) == 'M')] = 0
sex_array[np.nonzero(np.ravel(matfile['Sex']) == 'F')] = 1
sex_array[np.nonzero(np.ravel(matfile['Sex']) == 'I')] = 2

data = np.zeros((np.ravel(matfile['int1']).shape[0], 8))
data[:, 0] = sex_array
data[:, 1::] = matfile['double0'].T

label = np.zeros((np.ravel(matfile['int1']).shape[0], ), dtype=(int))
label[np.nonzero(np.ravel(matfile['int1']) == 19)] = 1

np.savez('../../data/raw/mldata/uci-20070111-abalone.npz', data=data, label=label)

@@ -185,16 +185,18 @@
 lass 0%0A%0A
+# 
 filename
@@ -247,16 +247,18 @@
 ne.mat'%0A
+# 
 matfile 
@@ -278,16 +278,18 @@
 ename)%0A%0A
+# 
 sex_arra
@@ -337,16 +337,18 @@
 ape%5B0%5D)%0A
+# 
 sex_arra
@@ -398,16 +398,18 @@
 ')%5D = 0%0A
+# 
 sex_arra
@@ -459,16 +459,18 @@
 ')%5D = 1%0A
+# 
 sex_arra
@@ -521,16 +521,18 @@
 )%5D = 2%0A%0A
+# 
 data = n
@@ -580,16 +580,18 @@
 0%5D, 8))%0A
+# 
 data%5B:, 
@@ -605,16 +605,18 @@
 x_array%0A
+# 
 data%5B:, 
@@ -644,16 +644,18 @@
 e0'%5D.T%0A%0A
+# 
 label = 
@@ -716,16 +716,18 @@
 =(int))%0A
+# 
 label%5Bnp
@@ -774,16 +774,18 @@
 )%5D = 1%0A%0A
+# 
 np.savez
@@ -859,8 +859,277 @@
 =label)%0A
+%0A# Adult dataset%0A%0A# filename = '../../data/raw/mldata/adult'%0A%0A# input = np.loadtxt(filename, delimiter = ',', usecols = (0, 2, 4, 10, 11, 12, 14))%0A%0A# data = input%5B:, :-1%5D%0A# label = input%5B:, -1%5D%0A%0A# np.savez('../../data/raw/mldata/uci-adult.npz', data=data, label=label)%0A

convert the adult dataset