sklearn.decomposition.dict_learning_online?

sklearn.decomposition.dict_learning_online(X, n_components=2, *, alpha=1, n_iter=100, return_code=True, dict_init=None, callback=None, batch_size=3, verbose=False, shuffle=True, n_jobs=None, method='lars', iter_offset=0, random_state=None, return_inner_stats=False, inner_stats=None, return_n_iter=False, positive_dict=False, positive_code=False, method_max_iter=1000)

[源碼]

在線解決字典學習矩陣分解問題。

通過求解,找到逼近數據矩陣X的最佳字典和對應的稀疏代碼:

(U^*, V^*) = argmin 0.5 || X - U V ||_2^2 + alpha * || U ||_1
             (U,V)
             with || V_k ||_2 = 1 for all  0 <= k < n_components

V是字典,U是稀疏代碼。這是通過對輸入數據進行切片,在小批上重復迭代來完成的。

用戶指南中閱讀更多內容

參數 說明
X array of shape (n_samples, n_features)
數據矩陣
n_components int,
要提取的字典原子數。
alpha float,
稀疏的控制參數。
n_iter int,
要執行的小批迭代的數量。
return_code boolean,
是否也返回代碼U或只是字典V。
dict_init array of shape (n_components, n_features),
用于熱重啟場景的字典的初始值。
callback callable or None, optional (default: None)
可調用的,每5次迭代調用一次
batch_size int,
每批取樣的數量。
verbose bool, optional (default: False)
控制程序的冗長。
shuffle boolean,
是否在將數據分拆成批之前打亂數據。
n_jobs int or None, optional (default=None)
要運行的并行作業數量。None是1,除非在joblib.parallel_backend上下文。-1表示使用所有處理器。參詳見術語表
method {‘lars’, ‘cd’}
ars:使用最小角度回歸方法求解lasso問題(linear_model.lars_path) cd:使用坐標下降方法計算lasso解(linear_model.Lasso)。如果估計的組件是稀疏的,Lars會更快。
iter_offset int, default 0
用于初始化的字典上先前完成的迭代次數。
random_state int, RandomState instance or None, optional (default=None)
用于在沒有指定dict_init時初始化字典,在shuffle設置為True時隨機地洗牌數據,以及更新字典。在多個函數調用中傳遞可重復的結果。詳見術語表
return_inner_stats boolean, optional
返回內部統計信息A(字典協方差)和B(數據近似)。在在線設置中重新啟動算法非常有用。如果return_inner_stats為真,則忽略return_code
inner_stats tuple of (A, B) ndarrays
由算法保存的內部充分統計信息。在在線設置中,在初始化時傳遞它們非常有用,這樣可以避免丟失演化的歷史。A (n_components, n_components)是字典協方差矩陣。B (n_features, n_components)是數據近似矩陣
return_n_iter bool
是否返回迭代次數。
positive_dict bool
查找字典時是否要加強積極性。

新版本0.20。
positive_code bool
在尋找代碼時是否加強積極性。

新版本0.20。
method_max_iter int, optional (default=1000)
解決套索問題時要執行的最大迭代次數。

新版本0.22。
返回值 說明
code array of shape (n_samples, n_components),
稀疏代碼(僅在return_code=True時返回)
dictionary array of shape (n_components, n_features),
字典學習問題的解決方法
n_iter int
運行的迭代次數。僅當return_n_iter設置為True時返回。

另見: