utils.py 文件源码

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

项目:kdd2017 作者: JinpengLI 项目源码 文件源码
def transform_data(x_i, le, with_fit=True):
    if isinstance(le, preprocessing.MinMaxScaler) or isinstance(le, preprocessing.Binarizer):
        x_i = x_i.astype(np.float)
        if with_fit:
            le.fit(x_i.reshape((-1, 1)))
        x_i = le.transform(x_i.reshape((-1, 1)))
    elif isinstance(le, preprocessing.LabelEncoder):
        if with_fit:
            le.fit(x_i)
        x_i = le.transform(x_i.reshape((-1, 1)))
    else:
        raise ValueError("unknow transform")
    return x_i.reshape((-1)), le
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号