sklearn.kernel_approximation.SkewedChi2Sampler?

class sklearn.kernel_approximation.SkewedChi2Sampler(*, skewedness=1.0, n_components=100, random_state=None)

[源碼]

通過Fourier變換的Monte Carlo逼近來近似“斜卡方(skewed chi-squared)”核的特征圖。

閱讀更多內容用戶指南.

參數 說明
skewedness float
內核的“偏度”參數。 需要進行交叉驗證。
n_components int
每個原始特征的Monte Carlo樣本數。 等于計算的特征空間的維數。
random_state int, RandomState instance or None, optional (default=None)
偽隨機數發生器在擬合訓練數據時控制隨機權值和隨機偏移的產生。通過多個函數調用傳遞可重復輸出的int值。 請參閱詞匯表

另見

參考文獻

1 See “Random Fourier Approximations for Skewed Multiplicative Histogram Kernels” by Fuxin Li, Catalin Ionescu and Cristian Sminchisescu.

實例

>>> from sklearn.kernel_approximation import SkewedChi2Sampler
>>> from sklearn.linear_model import SGDClassifier
>>> X = [[00], [11], [10], [01]]
>>> y = [0011]
>>> chi2_feature = SkewedChi2Sampler(skewedness=.01,
...                                  n_components=10,
...                                  random_state=0)
>>> X_features = chi2_feature.fit_transform(X, y)
>>> clf = SGDClassifier(max_iter=10, tol=1e-3)
>>> clf.fit(X_features, y)
SGDClassifier(max_iter=10)
>>> clf.score(X_features, y)
1.0
方法 說明
fit(self, X[, y]) 擬合模型與X
fit_transform(self, X[, y]) 擬合數據,然后進行轉化。
get_params(self[, deep]) 獲取此估計量的參數。
set_params(self, **params) 設置此估計量的參數。
transform(self, X) 將近似特征映射應用于X。
__init__(self, *, skewedness=1.0, n_components=100, random_state=None)

[源碼]

初始化self, 請參閱help(type(self))以獲得準確的說明

fit(self, X, y=None)

[源碼]

用X擬合模型。

根據n_features對隨機投影進行采樣。

參數 說明
X {array-like, sparse matrix, dataframe} of shape (n_samples, n_features)
y ndarray of shape (n_samples,), default=None
目標值。
**fit_params dict
其他擬合參數。
返回值 說明
X_new ndarray array of shape (n_samples, n_features_new)
變換數組
get_params(self, deep=True)

[源碼]

獲取此估計量的參數。

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

[源碼]

設置此估計量的參數。

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

參數 說明
**params dict
估計參數
返回值 說明
self object
估計實例
transform(self, X)

[源碼]

將近似特征映射應用于X。

參數 說明
x array-like, shape (n_samples, n_features)
新數據,其中n_samples表示樣本數,n_features表示特征數。X的所有值必須嚴格大于“-傾斜度(-skewedness)”。
返回值 說明
X_new array-like, shape (n_samples, n_components)