BaşlayınÜcretsiz Başlayın

Testing QuantileTransformer

Standardization is prone to the same pitfalls as z-scores. Both use mean and standardization in their calculations, which makes them highly sensitive to extreme values.

To get around this problem, you should use QuantileTransformer which uses quantiles. Quantiles of a distribution stay the same regardless of the magnitude of outliers.

You should use StandardScaler when the data is normally distributed (which can be checked with a histogram). For other distributions, QuantileTransformer is a better choice.

You'll practice on the loaded females dataset. matplotlib.pyplot is loaded under its standard alias, plt.

Bu egzersiz

Anomaly Detection in Python

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Instantiate a QuantileTransformer() that transforms features into a normal distribution and assigns it to qt.
  • Fit and transform the feature array X and preserve the column names.
  • Plot a histogram of the palmlength column.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

from sklearn.preprocessing import QuantileTransformer

# Instantiate an instance that casts to normal
qt = ____

# Fit and transform the feature array
X.____ = ____

# Plot a histogram of palm length
plt.____(____, color='red')

plt.xlabel("Palm length")
plt.show()
Kodu Düzenle ve Çalıştır