sklearn.decomposition.sparse_encode?
sklearn.decomposition.sparse_encode(X, dictionary, *, gram=None, cov=None, algorithm='lasso_lars', n_nonzero_coefs=None, alpha=None, copy_cov=True, init=None, max_iter=1000, n_jobs=None, check_input=True, verbose=0, positive=False)[source]
稀疏編碼
結果的每一行都是稀疏編碼問題的解決方案。目標是找到一個稀疏數組代碼,這樣:
X ~= code * dictionary
在用戶指南中閱讀更多內容.
參數 | 說明 |
---|---|
X | array of shape (n_samples, n_features) 數據矩陣 |
dictionary | array of shape (n_components, n_features) 用于求解數據稀疏編碼的字典矩陣。有些算法假設有意義的輸出是標準化的行。 |
gram | array, shape=(n_components, n_components) 預先計算的克矩陣,字典*字典' |
cov | array, shape=(n_components, n_samples) 預計算協方差,字典' * X |
algorithm | {‘lasso_lars’, ‘lasso_cd’, ‘lars’, ‘omp’, ‘threshold’} ars:使用最小角度回歸法(linear_model.lars_path) lasso_lars:使用lars計算Lasso解lasso_cd:使用坐標下降法計算Lasso解(linear_model.Lasso)如果估計的組件是稀疏的,lasso_lars會更快。omp:使用正交匹配追蹤估計稀疏解閾值:將投影字典中所有小于alpha的系數都壓縮為零* X ' |
n_nonzero_coefs | int, 0.1 * n_features by default 在解的每一列中目標的非零系數的數目。這只被算法='lars'和算法='omp'使用,在omp情況下被alpha覆蓋。 |
alpha | float, 1. by default 如果算法='lasso_lars'或算法='lasso_cd',則alpha是對L1范數的懲罰。如果算法='threshold', alpha是閾值的絕對值,低于這個閾值,系數將被壓縮為零。若算法='omp',則alpha為容差參數:目標重構誤差的值。在本例中,它覆蓋n_nonzero_coefs。 |
copy_cov | boolean, optional 是否復制預計算的協方差矩陣;如果為False,則可能被覆蓋。 |
init | array of shape (n_samples, n_components) 稀疏編碼的初始化值。僅當算法='lasso_cd'時使用。 |
max_iter | int, 1000 by default 如果算法='lasso_cd'或lasso_lars,則執行的最大迭代次數。 |
n_jobs | int or None, optional (default=None) 要運行的并行作業數量。沒有一個是1,除非在joblib。parallel_backend上下文。-1表示使用所有處理器。參見術語表了解更多細節。 |
check_input | boolean, optional 如果為假,則不會檢查輸入數組X和dictionary。 |
verbose | int, optional 控制冗長;越高,信息越多。默認值為0。 |
positive | boolean, optional 在尋找編碼時是否要加強積極性。 新版本0.20。 |
返回值 | 說明 |
---|---|
code | array of shape (n_samples, n_components) 稀疏編碼 |
另見: