Skip to content

Something goes wrong with KernelPCA with 32 bits input data #18146

@glemaitre

Description

@glemaitre

When given 32 bits input, KernelPCA succeed to transform the data into a 17-dimensional feature space while the original space was 3 features. I did not debug yet but this seems really unlikely.

# %%
from sklearn.datasets import make_blobs
from sklearn.preprocessing import StandardScaler

X, y = make_blobs(
    n_samples=30,
    centers=[[0, 0, 0], [1, 1, 1]],
    random_state=0,
    cluster_std=0.1
)
X = StandardScaler().fit_transform(X)
X -= X.min()

# %%
import numpy as np
from sklearn.decomposition import KernelPCA

kpca = KernelPCA()
print(kpca.fit_transform(X).shape)
print(kpca.fit_transform(X.astype(np.float32)).shape)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions