Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Leer Noise Reduction | Results Analysis
Principal Component Analysis

book
Noise Reduction

Let's look at the way PCA works, when the algorithm does not act as a data processing stage, but as the main stage. The task of noise reduction in images is just that case. The pipeline in this case looks like this: we load the noisy data into the model, after which we can process other data using PCA and the model will restore that data. How it works? By reducing the number of main components - literally only the most important elements of the image remain, i.e. noise will be reduced. We use the USPS dataset with numbers and the scikit-learn library:

python
import numpy as np
from sklearn.datasets import fetch_openml
from sklearn.preprocessing import MinMaxScaler
from sklearn.model_selection import train_test_split

X, y = fetch_openml(data_id = 41082, as_frame = False, return_X_y = True)
X = MinMaxScaler().fit_transform(X)

Let's add some noise to our images:

python
X_train, X_test, y_train, y_test = train_test_split(
X, y, stratify = y, random_state = 0, train_size = 1_000, test_size = 100
)

rng = np.random.RandomState(0)
noise = rng.normal(scale = 0.25, size = X_test.shape)
X_test_noisy = X_test + noise

noise = rng.normal(scale = 0.25, size = X_train.shape)
X_train_noisy = X_train + noise

Create a PCA model:

python
from sklearn.decomposition import PCA

pca_model = PCA(n_components=40)
pca_model.fit(X_train_noisy)

Let's see what came of it! Initial noisy images:

And here is the result of PCA work:

question mark

Is the PCA method designed to reduce noise in the data?

Select the correct answer

Was alles duidelijk?

Hoe kunnen we het verbeteren?

Bedankt voor je feedback!

Sectie 4. Hoofdstuk 4

Vraag AI

expand
ChatGPT

Vraag wat u wilt of probeer een van de voorgestelde vragen om onze chat te starten.

some-alt