comp_common.py 文件源码

python
阅读 37 收藏 0 点赞 0 评论 0

项目:Titanic 作者: GeoffBreemer 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号