关于sklearn.decomposition.FastICA的介绍http://lijiancheng0614.github.io/scikit-learn/modules/generated/sklearn.decomposition.FastICA.html

import numpy as np
import matplotlib.pyplot as plt
from sklearn.decomposition import FastICAC = 200  # 样本数
x = np.arange(C)
s1 = 2 * np.sin(0.02 * np.pi * x)  # 正弦信号a = np.linspace(-2, 2, 25)
s2 = np.array([a, a, a, a, a, a, a, a]).reshape(200, )  # 锯齿信号
s3 = np.array(20 * (5 * [2] + 5 * [-2]))  # 方波信号
s4 = 4 * (np.random.random([1, C]) - 0.5).reshape(200, ) #随机信号
"""画出4种信号"""
ax1 = plt.subplot(411)
ax2 = plt.subplot(412)
ax3 = plt.subplot(413)
ax4 = plt.subplot(414)
ax1.plot(x,s1)
ax2.plot(x,s2)
ax3.plot(x,s3)
ax4.plot(x,s4)
plt.show()
"""将4种信号混合
其中mix矩阵是混合后的信号矩阵,shape=[4,200]"""
s=np.array([s1,s2,s3,s4])
ran=2*np.random.random([4,4])
mix=ran.dot(s)
ax1 = plt.subplot(411)
ax2 = plt.subplot(412)
ax3 = plt.subplot(413)
ax4 = plt.subplot(414)
ax1.plot(x,mix[0,:])
ax2.plot(x,mix[1,:])
ax3.plot(x,mix[2,:])
ax4.plot(x,mix[3,:])
plt.show()ica = FastICA(n_components=4) #独立成分为4个
mix = mix.T #将信号矩阵转为[n_samples,n_features],即[200,4]
u = ica.fit_transform(mix) # u为解混后的4个独立成分,shape=[200,4]
u = u.T # shape=[4,200]
print(ica.n_iter_) # 算法迭代次数
"""画出解混后的4种独立成分"""
ax1 = plt.subplot(411)
ax2 = plt.subplot(412)
ax3 = plt.subplot(413)
ax4 = plt.subplot(414)
ax1.plot(x,u[0,:])
ax2.plot(x,u[1,:])
ax3.plot(x,u[2,:])
ax4.plot(x,u[3,:])
plt.show()

还有另外一种得到独立成分的写法,思路是将求得的解混矩阵和混合信号矩阵相乘得到独立成分,代码如下:

"""前面一样"""
ica = FastICA(n_components=4)
mix = mix.T
ica.fit(mix)
w = ica.components_ #解混矩阵,shape=[n_components, n_features],即[4,4]
u = np.dot(w,mix.T) #解混矩阵和混合信号相乘得到独立成分
print(ica.n_iter_)
ax1 = plt.subplot(411)
ax2 = plt.subplot(412)
ax3 = plt.subplot(413)
ax4 = plt.subplot(414)
ax1.plot(x,u[0,:])
ax2.plot(x,u[1,:])
ax3.plot(x,u[2,:])
ax4.plot(x,u[3,:])
plt.show()

sklearn.decomposition.FastICA实现FastICA算法相关推荐

  1. 基于sklearn.decomposition.TruncatedSVD的潜在语义分析实践

    文章目录 1. sklearn.decomposition.TruncatedSVD 2. sklearn.feature_extraction.text.TfidfVectorizer 3. 代码实 ...

  2. sklearn专题四:降维算法

    目录 1 概述 1.1 从什么叫"维度"说开来 2 PCA与SVD 2.2 重要参数n_components 2.2.1 迷你案例:高维数据的可视化 2.2.2 最大似然估计自选超 ...

  3. sklearn.decomposition.LatentDirichletAllocation接口详解

    1. Latent Dirichlet Allocation(LDA) 隐式狄利克雷分布是一个生成概率模型,用于离散的数据集比如文本语料库 同时它也是一个主题模型,用来从一堆文件s中发现抽象的主题s ...

  4. (sklearn学习笔记)降维算法PCA与SVD的原理及用法

    听了菜菜讲的机器学习PCA及SVD所写 什么是维度? 什么是"降维"? 为什么要"降维"? PCA基本原理 sklearn中用于降维的类PCA 参数解释 n_c ...

  5. sklearn使用投票器VotingClassifier算法构建多模型融合的软投票器分类器(soft voting)并自定义子分类器的权重(weights)、计算融合模型的混淆矩阵、可视化混淆矩阵

    sklearn使用投票器VotingClassifier算法构建多模型融合的软投票器分类器(soft voting)并自定义子分类器的权重(weights).计算融合模型的混淆矩阵.可视化混淆矩阵 目 ...

  6. sklearn使用投票器VotingClassifier算法构建多模型融合的软投票器分类器(soft voting)并计算融合模型的混淆矩阵、可视化混淆矩阵(confusion matrix)

    sklearn使用投票器VotingClassifier算法构建多模型融合的软投票器分类器(soft voting)并计算融合模型的混淆矩阵.可视化混淆矩阵(confusion matrix) 目录

  7. sklearn使用投票器VotingClassifier算法构建多模型融合的硬投票器分类器(hard voting)并计算融合模型的混淆矩阵、可视化混淆矩阵(confusion matrix)

    sklearn使用投票器VotingClassifier算法构建多模型融合的硬投票器分类器(hard voting)并计算融合模型的混淆矩阵.可视化混淆矩阵(confusion matrix) 目录

  8. sklearn使用投票回归VotingRegressor算法构建多模型融合的投票回归模型、并自定义子回归器的权重(weights)、评估多模型融合的回归模型、评估R2、mse、rmse、mape

    sklearn使用投票回归VotingRegressor算法构建多模型融合的投票回归模型.并自定义子回归器的权重(weights).评估多模型融合的回归模型.评估R2.mse.rmse.mape 目录

  9. 15 分钟带你入门 sklearn 与机器学习(分类算法篇)

    众所周知,Scikit-learn(以前称为scikits.learn)是一个用于Python编程语言的免费软件机器学习库.它具有各种分类,回归和聚类算法,包括支持向量机,随机森林,梯度增强,k-me ...

最新文章

  1. xshell 家庭/学校 免费教育版下载
  2. 缓存穿透、缓存击穿、缓存雪崩及其解决方案
  3. oracle函数中bitand,Oracle bitand()函数使用方法
  4. cad转shp 奥维_CAD转换工具程序包(附下载)
  5. 罗永浩带货520鲜花礼盒再翻车:自掏腰包100多万,双倍赔偿
  6. Codeforces Round #728 (Div. 2)
  7. Google新项目:从一条线开始,完成地球的绘制
  8. VIOS 的一些常用命令
  9. 2004-7-1+ 用户控件(动态加载)
  10. java sencha_开始使用Sencha Cmd
  11. android 预优化oat_Android内存优化大盘点
  12. Java基础视频教程(最适合初学者入门)
  13. weka 贝叶斯 java_weka中朴素贝叶斯的实现
  14. Ubuntu 16.04 解决RTL8111/8168/8411网卡有线连接网速慢的问题
  15. pytube——下载YouTube视频的python库
  16. 小米系统shell_小米平板1(Mi Pad1) 采用神盾内核的 lineageOS 14.1 / 15.1 / 16.0 刷机教程...
  17. 百度地图受邀参加第九届全国化工物流行业年会 助力危化品物流运输安全合规
  18. RecyclerView源码学习笔记(一)构造函数和setLayoutManager方法
  19. k8spod控制器概述
  20. android 实现磨砂效果_Android(Android5.0)下毛玻璃(磨砂)效果如何实现?

热门文章

  1. php增加mysql用户_mysql 增加用户
  2. 将整个表单设置为只读_如何将独立网站设置为制作中,阻止搜索引擎收录网站页面?...
  3. python中如何输入矩阵_python - 如何向矩阵中添加向量_numpy_酷徒编程知识库
  4. 预训练再次跨界!百度提出ERNIE-GeoL,地理位置-语言联合预训练!
  5. 谁说发 paper 一定要追快打新?2021年,研究 word2vec 也能中顶会!
  6. NLP界新SOTA!吸纳5000万级知识图谱,一举刷爆54个中文任务!
  7. 从我开发过的Tensorflow、飞桨、无量框架看深度学习这几年
  8. Spring Cloud Config采用数据库存储配置内容【Edgware+】
  9. 技术动态 | 跨句多元关系抽取
  10. KubeVela 高可扩展的云原生应用平台与核心引擎