首页 > 编程语言 > 详细

吴裕雄 python 机器学习——数据预处理字典学习模型

时间:2019-05-02 14:11:38      阅读:292      评论:0      收藏:0      [点我收藏+]
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 机器学习——数据预处理字典学习模型

原文:https://www.cnblogs.com/tszr/p/10802189.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!