maxframe.learn.preprocessing.normalize#
- maxframe.learn.preprocessing.normalize(X, norm='l2', axis=1, copy=True, return_norm=False)[源代码]#
将输入向量各自缩放到单位范数(向量长度)。
- 参数:
X ({array-like, sparse matrix}, shape [n_samples, n_features]) -- 要逐元素归一化的数据。scipy.sparse 矩阵应为 CSR 格式以避免不必要的复制。
norm ('l1', 'l2', or 'max', optional ('l2' by default)) -- 用于归一化每个非零样本(如果 axis 为 0,则为每个非零特征)的范数。
axis (0 or 1, optional (1 by default)) -- 用于沿着进行数据归一化的轴。如果为 1,则独立地归一化每个样本;否则(如果为 0)归一化每个特征。
copy (boolean, optional, default True) -- 设为 False 以执行原地行归一化并避免复制(如果输入已经是张量并且 axis 为 1)。
return_norm (boolean, default False) -- 是否返回计算出的范数
- 返回:
X ({array-like, sparse matrix}, shape [n_samples, n_features]) -- 归一化后的输入 X。
norms (Tensor, shape [n_samples] if axis=1 else [n_features]) -- 沿着给定轴的 X 的范数张量。当 X 是稀疏矩阵时,对于 'l1' 或 'l2' 范数会抛出 NotImplementedError。
参见
Normalizer使用
TransformerAPI 执行归一化(例如作为预处理maxframe.learn.pipeline.Pipeline的一部分)。