✍️
mathematics_basic_for_ML
  • README
  • README
    • Summary
    • Geometry
      • EulerAngle
      • Gimbal lock
      • Quaternion
      • RiemannianManifolds
      • RotationMatrix
      • SphericalHarmonics
    • Information
      • Divergence
      • 信息熵 entropy
    • LinearAlgebra
      • 2D仿射变换(2D Affine Transformation)
      • 2DTransformation
      • 3D变换(3D Transformation)
      • ComplexTransformation
      • Conjugate
      • Hessian
      • IllConditioning
      • 逆变换(Inverse transform)
      • SVD
      • det
      • eigendecomposition
      • 矩阵
      • norm
      • orthogonal
      • special_matrix
      • trace
      • vector
    • Mathematics
      • Complex
      • ExponentialDecay
      • average
      • calculus
      • convex
      • derivative
      • 距离
      • function
      • space
      • Formula
        • euler
        • jensen
        • taylor
        • trigonometric
    • Numbers
      • 几何级数
      • SpecialNumbers
    • NumericalComputation
      • ConstrainedOptimization
      • GradientDescent
      • Newton
      • Nominal
      • ODE_SDE
      • Preprocessing
    • Probability
      • bayes
      • distribution
      • expectation_variance
      • 贝叶斯公式
      • functions
      • likelihood
      • mixture_distribution
      • 一些术语
      • probability_distribution
Powered by GitBook
On this page
  • 归一化 Normalize
  • 标准化 Standardize

Was this helpful?

  1. README
  2. NumericalComputation

Preprocessing

PreviousODE_SDENextProbability

Last updated 2 years ago

Was this helpful?

归一化 Normalize

把数据映射到[0,1]之间。 适用于分布有明显边界的情况,需要知道数据的最大值和最小值,受outlier影响较大。

xscale=x−xminxmax−xminx_{scale} = \frac {x - x_{min}}{x_{max} - x_{min}}xscale​=xmax​−xmin​x−xmin​​

如果使用训练数据的最大值和最小值,则可能出现测试数据超出范围的情况。 可以把超出范围的数据drop或者cutdown。

sklearn实现:

from sklearn.preprocessing import MinMaxScaler

scaler = MinMaxScaler(feature_range=(0,1))
scaler = scaler.fit(values)
normalized = scaler.transform(values)
inversed = scaler.inverse_transform(normalized)

标准化 Standardize

把数据映射到均值为0方差为1的分布中。 数据分布没有明显的边界,有可能存在极端的数据值。但需要知道数据的均值和方差。

xscale=x−xmeanSx_{scale} = \frac {x-x_{mean}}{S}xscale​=Sx−xmean​​

通常使用训练数据的均值和方差。

sklearn实现:

from sklearn.preprocessing import StandardScaler

scaler = StandardScaler()
scaler = scaler.fit(values)
normalized = scaler.transform(values)
inversed = scaler.inverse_transform(normalized)