Log-Normalisierung

Vorverarbeitung für Machine Learning in Python

James Chapman

Curriculum Manager, DataCamp

Was ist Log-Normalisierung?

 

  • Nützlich für Features mit hoher Varianz
  • Wendet eine Logarithmus-Transformation an
  • Natürlicher Logarithmus mit der Konstante $e$ ($\approx2{,}718$)
Vorverarbeitung für Machine Learning in Python

Was ist Log-Normalisierung?

 

  • Nützlich für Features mit hoher Varianz
  • Wendet eine Logarithmus-Transformation an
  • Natürlicher Logarithmus mit der Konstante $e$ ($\approx2{,}718$)
  • $e^{3.4} = 30$

 

  • Erfasst relative Änderungen, die Änderungsgröße und hält alles positiv

 

Zahl Log
30 3.4
300 5.7
3000 8
Vorverarbeitung für Machine Learning in Python

Log-Normalisierung in Python

print(df)
   col1   col2
0  1.00    3.0
1  1.20   45.5
2  0.75   28.0
3  1.60  100.0
print(df.var())
col1       0.128958
col2    1691.729167
dtype: float64
import numpy as np
df["log_2"] = np.log(df["col2"])
print(df)
   col1   col2     log_2
0  1.00    3.0  1.098612
1  1.20   45.5  3.817712
2  0.75   28.0  3.332205
3  1.60  100.0  4.605170
print(df[["col1", "log_2"]].var())
col1     0.128958
log_2    2.262886
dtype: float64
Vorverarbeitung für Machine Learning in Python

Lass uns üben!

Vorverarbeitung für Machine Learning in Python

Preparing Video For Download...