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

摘要:
来自sklearn。CompositionimportDictionaryLearning#数据预处理字典学习字典学习模型defest_DictionaryLearning():X=[[1,2,3,4,5],[6,7,8,9,10],[10,9,8,7,6,],[5,4,3,2,1]]print(“beforetransform:”,X)dct=字典
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() 

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

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 机器学习——数据预处理字典学习模型第2张

免责声明:文章转载自《吴裕雄 python 机器学习——数据预处理字典学习模型》仅用于学习参考。如对内容有疑问,请及时联系本站处理。

上篇使用multer搭建一个图片接收服务器Android系统--输入系统(十一)Reader线程_简单处理下篇

宿迁高防,2C2G15M,22元/月;香港BGP,2C5G5M,25元/月 雨云优惠码:MjYwNzM=

相关文章

js和jq获取父,兄弟,子节点

1,js获取节点:   父: parentNode 获取已知节点的父节点。   子: childNodes; 得到全部子节点     children 得到全部子节点     firstChild 获得第一个子节点     lastChild 获得最后一个子节点   兄弟:previousSibling 获取已知节点的前一个节点   nextSibling...

Python Twisted 学习系列21(转载stulife最棒的Twisted入门教程)

第二十一部分 惰性不是迟缓: Twisted和Haskell 简介 在上一个部分我们对比了Twisted与 Erlang,并将注意力集中在它们共有的一些思想上.结果表明使用Erlang也是非常简便的,因为异步I/O和反应式编程是Erlang运行时和进程模型的关键元素. 今天我们想走得更远一点,去看一看 Haskell —— 另一种功能性语言,然而与Erla...

opencv linux

http://docs.opencv.org/doc/tutorials/introduction/linux_install/linux_install.html https://www.google.com.hk/search?q=opencv+linux&ie=utf-8&oe=utf-8&gws_rd=cr&ei=f...

python限制进程、子进程占用内存大小、CPU时间的方法:resource模块

内置模块:resource 在mac环境下功能会存在问题。linux下可以使用:但是for i in range(10000)的值必须是10000或者更大的数值才有用。没有搞清楚为什么 #/usr/bin/env python #-*-coding:utf-8-*- import resource #soft,hard=resource.getrli...

Python 异步编程

介绍几种Python异步执行的方式 参考: 官方文档 python 实现异步执行 Python中协程异步IO 通过 threading.Thread 实现 先将需要异步执行的函数用线程的方式包装为一个装饰器,然后拿去装饰需要异步执行的函数即可。 下面构造两个函数 from threading import Thread from time import...

python判断字符串是否为空和null

1、使用字符串长度判断 len(s==0)则字符串为空 test1 = '' if len(test1) == 0: print('test1为空串') else: print('test非空串,test='+test1) 2、isspace判断字符串是否只由空格组成 >>> str="" >>> pr...