sklearn.cross_decomposition.PLSSVD?

class sklearn.cross_decomposition.PLSSVD(n_components=2, *, scale=True, copy=True)

[源碼]

偏最小二乘SVD

只需對交叉協方差矩陣執行svd:X’Y這里沒有迭代壓縮。

用戶指南中閱讀更多內容。

0.8版的新功能。

參數 說明
n_components int, default 2
要保留的組件數。
scale boolean, default True
是否收縮X和Y。
copy boolean, default True
是復制X和Y,還是執行就地計算。
屬性 說明
x_weights_ array, [p, n_components]
X塊的權重變量。
y_weights_ array, [q, n_components]
Y塊的權重變量。
x_scores_ array, [n_samples, n_components]
X得分。
y_scores_ array, [n_samples, n_components]
Y得分。

另見:

PLSCanonical

CCA

示例

>>> import numpy as np
>>> from sklearn.cross_decomposition import PLSSVD
>>> X = np.array([[0.0.1.],
...     [1.,0.,0.],
...     [2.,2.,2.],
...     [2.,5.,4.]])
>>> Y = np.array([[0.1-0.2],
...     [0.91.1],
...     [6.25.9],
...     [11.912.3]])
>>> plsca = PLSSVD(n_components=2)
>>> plsca.fit(X, Y)
PLSSVD()
>>> X_c, Y_c = plsca.transform(X, Y)
>>> X_c.shape, Y_c.shape
((42), (42))
方法 說明
fit(self, X, Y) 訓練數據集
fit_transform(self, X[, y]) 在訓練集上學習并應用降維
get_params(self[, deep]) 獲取評估器參數。
set_params(self, **params) 設置此估算器的參數。
transform(self, X[, Y]) 應用在訓練集上學到的降維。
__init__(self, n_components=2, *, scale=True, copy=True)

[源碼]

初始化self。請參閱幫助(type(self))以獲得準確的簽名。

fit(self, X, Y)

[源碼]

訓練數據。

參數 說明
X array-like of shape (n_samples, n_features)
訓練向量,其中n_samples是樣本數,n_features是預測變量數。
Y array-like of shape (n_samples, n_targets)
目標向量,其中n_samples是樣本數,n_targets是響應變量數。
fit_transform(self, X, y=None)

[源碼]

在訓練集上學習并應用降維。

參數 說明
X array-like of shape (n_samples, n_features)
訓練向量,其中n_samples是樣本數,n_features是預測變量數。
y array-like of shape (n_samples, n_targets)
目標向量,其中n_samples是樣本數,n_targets是響應變量數。
返回值 說明
如果未指定Y,則為x_scores,否則為(x_scores,y_scores)。 -
get_params(self, deep=True)

[源碼]

獲取此估計量的參數。

參數 說明
deep bool, default=True
如果為True,則將返回此估算器和作為估算器的所包含子對象的參數。
返回值 說明
params mapping of string to any
參數名稱映射到其值。
set_params(self, **params)

[源碼]

設置此估算器的參數。

該方法適用于簡單的估計器以及嵌套對象(例如管道)。 后者的參數格式為<component> __ <parameter>,以便可以更新嵌套對象的每個組件。

參數 說明
**params dict
估算器參數。
返回值 說明
self object
估算器實例。
transform(self, X, Y=None)

[源碼]

應用在訓練集上學到的降維。

參數 說明
X array-like of shape (n_samples, n_features)
訓練向量,其中n_samples是樣本數,n_features是預測變量數。
Y array-like of shape (n_samples, n_targets)
目標向量,其中n_samples是樣本數,n_targets是響應變量數。