victory的博客

长安一片月,万户捣衣声

0%

伪迹去除方法比较总结

1.(定性比较 or 定量比较)很难对不同伪迹去除方法基于它们去除伪迹的能力进行一个比较,通常只能做一个定性(qualitative)的比较
2.(自动 or 半自动)很多基于EEG的应用需要自动信息处理,尤其是一些对在线/实时(需要效率很高的算法和足够低的计算复杂度)有要求的应用。基于BSS(盲源分离)的方法通常是半自动的,因为伪迹成分的识别需要一些训练或参数选择/调整。涉及ICA的伪迹检测/去除方法需要另一个方法才能实现全过程的自动
3.(单通道 or 多通道)基于盲源分离的方法需要多通道才能起作用,通道数量越多,越能很好的分离出单个的源(这种方法不能用于低通道 e.g. 4-6或者基于单通道的应用)。基于小波变换和经验模态分解的方法可以通过将单个数据序列分解为多个成分进行单通道分析。
4.(参考信号)大多数方法需要参考信号。

PCA

PCA is a type of spatial filter that transforms the time domain datasets into a different space by rotating axes in an N-dimensional space(where n is the number of variables or EEG channels) such that each dimension in the new space has minimum variance and the axes are orthogonal to each other.

PCA reduces data dimension and highlights specific features of data,which is usually difficult to identify in the spatially unfiltered data as the new components are created by weighted combinations of all EEG channels.

One important limitation of PCA (or SVD)

it fails to separate/identify ocular or similar artifacts from
EEG when amplitudes are comparable since PCA depends on
the higher order statistical property

Adaptive Filter

Adaptive Filter is a system with a linear filter that has a transfer function controlled by variable parameters and a means to adjust those parameters according to an optimization algorithm.The filter weights can adapt based on the feedback from output of the system and it requires a reference input o compare the desired output with the observed output.

The use of adaptive filter for EOG artifact removal


where s[n] is observed signal,x[n] is original EEG,r[n] is artifact,x’[n] is artifact-free EEG.

EMD

EMD is an empirical and data-driven method developed to perform on non-stationary,non-linear, stochastic processes(it is ideally suitable for EEG signal analysis and processing)

Disadvantages:

1.the computational complexity is quite heavy(not suitable for online application)
2.the theory behind EMD is still not complete and so far used in empirical studies(difficult to predict its robustness in all EEG recordings)

EMD Algorithm

EMD algorithm decomposes a signal,s[n] into a sum of the band-limited components/functions,c[n] called intrinsic mode funciton(IMF) with well defined instantaneous frequencies.

Two Basic Conditions to be an IMF

1.the numberof extrema must be equal(or at most may differ by one) to the number of zero crossings
2.any point,the mean value of the two envelopes defined by the local maxima and the local minima has to be zero

The General Process flow of EMD Algorithm

Input: data sequence s[n]
1.Identify all the local extrema
2.Separately connect all the maxima and minima with natural cubic spline lines to form the upper,u[n],and lower,l[n],envelopes.
3.Find the mean of the envolopes as z[n]=[u[n]+l[n]]/2
4.Take the difference between the data and the mean as the proto-IMF,h[n]=s[n]-z[n]
5.Check the proto-IMF against the definition of IMF and the stoppage criterion to determine if it is an IMF
6.If the proto-IMF does not satisfy the definition,repeat step 1 to 5 on h[n] as many times as needed till it satisfies the definition
7.If the proto-IMF does satisfy the definition,assign the proto-IMF as an IMF component,c[n]
8.Repeat the operation step 1 to 7 on the residue,q[n]=s[n]-c[n],as the data
9.The operation ends when the residue contains no more than one extrema

EEMD(enhanced version of EMD)

EEMD it inspired from the fact that EMD is very sensitive to noise,which often leads to mode mixing complication.
EEMD is proposed which uses an average number of ensembles(IMFs) from EMD as the optimal IMFs thus it provides a noise-assisted data analysis method.

小波变换(Wavelet Transform,WT)

小波变化是一个时间尺度的表示方法,它把信号分解成时间和尺度的基函数(母小波基函数的扩展/变体)

一些基于小波理论的技术

1.wavelet packets
2.wavelet approximation and decomposition
3.discrete and continuous wavelet transform

其中,最常用的技术是离散小波变换(Discrete Wavelet Transform);
离散小波变换是由离散输入的连续小波变换得到的;
离散小波变换将信号输入到低通滤波器中,得到低频分量,进入高通滤波器得到高频分量。

离散小波变换进行2级分解的示例结构


where g[n] is a low pass filter and h[n] is a high pass filter

时频表示(Time Frequency Representation)

时频表示基于短时傅里叶变换(Short-Time Fourier Transfrom,STFT)。

同时使用时间、频率域分析的原因:

脑电信号的非稳定特性

缺点

在所有的频率范围有统一的时频分辨率,然而我们感兴趣的脑电的频率通常小于30Hz,很多伪迹的频率小于10Hz,这就需要在低频范围有STFT(短时傅里叶变换)不能提供的高频分辨率。

问题的解决

采用基于小波的方法-小波变换(适合为脑电信号的每一个频带提供相应的分辨率)

机器学习中分类标签次数统计代码模板

在使用机器学习的算法进行分类时,很多时候我们需要去统计各个分类标签在数据集中出现的次数,它的实现代码模板如下:

def class_count(class_list):  # class_list:数据集数据的所有标签列表
    # 存放各个分类出现的次数
    class_counts = {}
    # 统计class_list中每个元素出现的次数
    for cla in class_list:
        if cla not in class_counts.keys():
            class_counts[cla] = 0
        class_counts[cla] += 1
    # 排序
    sorted_class_count = sorted(class_counts.items(), key=operator.itemgetter(1), reverse=True)
    return sorted_class_count

决策树

决策树(Decision Tree)是一种基本的分类与回归方法。决策树由结点(Node)和有向边(Directed Edge)组成。结点有两种类型:内部结点(Internnal Node)和叶结点(Leaf Node)。内部结点表示一个特征或属性,叶结点表示一个类。决策树还有一个唯一的根结点(Root Node)。

我们可以把决策树看成一个if-then规则的集合,将决策树转换成if-then规则的过程是这样的:

由决策树的根结点到叶结点的每一条路径构建一条规则;路径上内部结点的特征对应着规则的条件,而叶结点对应着规则的结论。

决策树的路径或其对应的if-then规则集合具有一个重要性质:互斥并且完备(每一个实例都只能被一条路径或一条规则所覆盖(覆盖:实例的特征与路径上的特征一致或实例满足规则的条件))。

决策树做预测的步骤

1.收集数据
2.准备数据(将收集的数据按照一定规则整理出来,方便后续进行处理)
3.分析数据(在决策树构造完成后,检查决策树图形是否符合预期)
4.训练算法(构造决策树/决策树学习—>构造一个决策树的数据结构)
5.测试算法(使用经验树计算错误率。当错误率达到可接受范围,这个决策树就可以投放使用)
6.使用算法(决策树可以更好地理解数据的内在含义)

如何构建决策树?—构建决策树的3个步骤

1.特征选择

特征选择就是决定用哪个特征来划分特征空间
特征选择在于选取训练数据具有分类能力的特征
特征选择的标准:信息增益(Information Gain)/信息增益比。信息增益:在划分数据集之后信息发生的变化。
Note:信息增益最高的特征是最好的选择

1.1香农熵(熵)-信息论之父克劳德.香农:集合信息的度量方式。

熵定义为信息的期望值。在信息论与概率论中,熵是表示随机变脸不确定性的度量。如果待分类的事物可能划分在多个分类之中,则符号xi的信息定义为:


其中p(xi)是该分类的概率。

通过上式,我们可以得到所有类别的信息。为了计算熵,我们需要计算所有类别所有可能值包含的信息期望值(数学期望-反应随机变量平均取值的大小),公式如下:


其中n是分类的数目。熵越大,随机变量的不确定性就越大。

当熵中的概率由数据估计(特别是最大似然估计-Maximum Likelihood Estimation)得到时,所对应的熵称为经验熵(Empirical Entropy)

我们定义样本数据表中的数据为训练数据集D,则训练数据集D的经验熵为H(D),|D|表示其样本容量,及样本个数。设有K个类Ck, = 1,2,3,…,K,|Ck|为属于类Ck的样本个数,因此经验熵公式就可以写为 :

1.2信息增益

如何选择特征,需要看信息增益。也就是说,信息增益是相对特征而言的,信息增益越大,特征对最终的分类结果影响也就越大,我们就应该选择对最终分类结果影响最大的那个特征作为我们的分类特征。

条件熵H(Y|X)表示在一直随机变量X的条件下随机变量Y的不确定性,随机变量X给定条件下随机变量Y的条件熵(Conditional Entropy)H(Y|X),定义为X给定条件下Y的条件概率分布的熵对X的数学期望:


当条件熵中的概率由数据估计(特别是极大似然估计)得到时,岁对应的条件熵称为条件经验熵(empirical conditional entropy)。

特征A对训练数据集D的信息增益g(D,A),定义为集合D的经验熵H(D)与特征A给定条件下D的经验条件熵H(D|A)之差,即:

Note:一般地,熵H(D)与条件熵H(D|A)之差称为互信息(mutual information)。决策树学习中的信息增益等价于训练数据集中类与特征的互信息。

设特征A有n个不同的取值{a1,a2,···,an},根据特征A的取值将D划分为n个子集{D1,D2,···,Dn},|Di|为Di的样本个数。记子集Di中属于Ck的样本的集合为Dik,即Dik = Di ∩ Ck,|Dik|为Dik的样本个数。于是经验条件熵的公式可以些为:

总结

决策树的一些优点

1.易于理解和解释。决策树可以可视化
2.几乎不需要数据预处理。其他方法经常需要数据标准化,创建虚拟变量和删除缺失值。决策树还不支持缺失值。
3.使用树的花费(例如预测数据)是训练数据点(data points)数量的对数
4.可以同时处理数值变量和分类变量。其他方法大都适用于分析一种变量的集合。
5.可以处理多值输出变量问题
6.使用白盒模型.如果一个情况被观察到,使用逻辑判断容易表示这种规则。相反,如果是黑盒模型(例如人工神经网络),结果会非常难解释
7.即使对真实模型来说,假设无效的情况下,也可以较好的使用

决策树的一些缺点

1.决策树学习可能创建一个过于复杂的树,并不能很好的预测数据。也就是过拟合。修剪机制(现在不支持),设置一个叶子节点需要的最小样本数量,或者数的最大深度,可以避免过拟合
2.决策树可能是不稳定的,因为即使非常小的变异,可能会产生一颗完全不同的树。这个问题通过decision trees with an ensemble来缓解。
3.概念难以学习,因为决策树没有很好的解释他们,例如,XOR, parity or multiplexer problems(奇偶校验或多路复用器问题)。
4.如果某些分类占优势,决策树将会创建一棵有偏差的树。因此,建议在训练之前,先抽样使样本均衡。

参考资源1
参考资源2

鸡尾酒宴会问题

鸡尾酒宴会问题是独立成分分析(Indepen Compon Analysis)的经典问题。

问题描述

假设在party中有n个人,他们可以同时说话,我们也在房间中一些角落里共放置了n个声音接收器(Microphone)用来记录声音。宴会过后,我们从n个麦克风中得到了一组数据

,i表示采样的时间顺序,也就是说共得到了m组采样,每一组采样都是n维的。我们的目标是单单从这m组采样数据中分辨出每个人说话的信号。

将第二个问题细化一下,有n个信号源

,每一维都是一个人的声音信号,每个人发出的声音信号独立。A是一个未知的混合矩阵(mixing matrix),用来组合叠加信号s,那么
X = AS
X的意义在上文解释过,这里的x不是一个向量,是一个矩阵。其中每个列向量是

表示成图就是


x(i)的每个分量都由s(i)的分量线性表示。A和s都是未知的,x是已知的,我们要想办法根据x来推出s。这个过程也称作为盲信号分离。

将W表示成

其中,起始就是将wi携程行向量形式。那么得到: