def addFamily(X):
# Family size: index 8
newCol = np.array(X[:, 1] + X[:, 2], np.newaxis)
newCol = newCol.reshape((len(newCol), 1))
X = np.hstack( (X,newCol) )
# Family category: index 9
def determineFamilyCat(row):
# print('row shape = {}, cont = {}'.format(row.shape, row))
if row[8] == 1:
return 0 # singles
elif 2<=row[8]<=4:
return 1 # normal size
else:
return 2 # large size
newCol = np.apply_along_axis(determineFamilyCat, 1, X)
newCol = newCol.reshape((len(newCol), 1))
X = np.hstack((X,newCol))
return X
# Not used
评论列表
文章目录