sklearn.decomposition.dict_learning?
sklearn.decomposition.dict_learning(X, n_components, *, alpha, max_iter=100, tol=1e-08, method='lars', n_jobs=None, dict_init=None, code_init=None, callback=None, verbose=False, random_state=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 | int, 稀疏的控制參數。 |
max_iter | int, 要執行的最大迭代次數。 |
tol | float, 停止條件的容忍度。 |
method | {‘lars’, ‘cd’} lars:使用最小角度回歸方法求解lasso問題(linear_model.lars_path) cd:使用坐標下降方法計算lasso解(linear_model.Lasso)。如果估計的組件是稀疏的,Lars會更快。 |
n_jobs | int or None, optional (default=None) 要運行的并行作業數量。 None 是1,除非在joblib.parallel_backend 上下文。-1表示使用所有處理器。詳見術語表。 |
dict_init | array of shape (n_components, n_features), 用于熱重啟場景的字典的初始值。 |
code_init | array of shape (n_samples, n_components), 用于熱重啟場景的稀疏代碼的初始值。 |
callback | callable or None, optional (default: None) 可調用的,每5次迭代調用一次 |
verbose | bool, optional (default: False) 控制程序的冗長。 |
random_state | int, RandomState instance or None, optional (default=None) 用于隨機初始化字典。在多個函數調用中傳遞可重復的結果。詳見術語表。 |
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) 矩陣分解中的稀疏碼因子。 |
dictionary | array of shape (n_components, n_features), 矩陣分解中的字典因子。 |
errors | array 每次迭代的錯誤向量。 |
n_iter | int 運行的迭代次數。僅當return_n_iter設置為真時返回。 |
另見: