1. 程式人生 > >吳裕雄 python 機器學習——數據預處理字典學習模型

吳裕雄 python 機器學習——數據預處理字典學習模型

sklearn 數據預處理 tran imp cti 圖片 component ict form

from sklearn.decomposition import DictionaryLearning

#數據預處理字典學習DictionaryLearning模型
def test_DictionaryLearning():
    X=[[1,2,3,4,5],
       [6,7,8,9,10],
       [10,9,8,7,6,],
       [5,4,3,2,1]]
    print("before transform:",X)
    dct=DictionaryLearning(n_components=3)
    dct.fit(X)
    
print("components is :",dct.components_) print("after transform:",dct.transform(X)) # 調用 test_DictionaryLearning test_DictionaryLearning()

技術分享圖片

from sklearn.decomposition import MiniBatchDictionaryLearning

#數據預處理字典學習MiniBatchDictionaryLearning模型
def test_MiniBatchDictionaryLearning():
    X
=[[1,2,3,4,5], [6,7,8,9,10], [10,9,8,7,6,], [5,4,3,2,1]] print("before transform:",X) dct=DictionaryLearning(n_components=3) dct.fit(X) print("components is :",dct.components_) print("after transform:",dct.transform(X)) # 調用 test_MiniBatchDictionaryLearning
test_MiniBatchDictionaryLearning()

技術分享圖片

吳裕雄 python 機器學習——數據預處理字典學習模型