当我执行一个KernalPCA时,我得到一个LinAlgE

2024-04-19 01:42:42 发布

您现在位置:Python中文网/ 问答频道 /正文

当我在Kaggle predict House Prices上执行KernalPCA代码时,它返回这样的错误SVD did not converge in Linear Least Squares


    from sklearn.decomposition import KernelPCA
    from sklearn.model_selection import GridSearchCV
    lr_with_kpca_pipeline = Pipeline([
        ('kpca', KernelPCA()),
        ('lr', LinearRegression())
    ])
    lr_with_kpca_param = {
        'kpca__gamma': np.linspace(0.001, 0.03, 10),
        'kpca__kernel': ['rbf', 'linear', 'poly'],
        'lr__normalize': [False, True]
    }
    lr_with_kpca_grid_cv = GridSearchCV(lr_with_kpca_pipeline,   param_grid=lr_with_kpca_param, cv=3, verbose=True, n_jobs=-1, iid=True)
    lr_with_kpca_grid_cv.fit(x_train, y_train)

Tags: fromimporttruepipelineparamwithtrainsklearn