mass(mueen的相似性搜索算法)
mass-ts的Python项目详细描述
mass(mueen的相似性搜索算法)
mass允许您在时间序列中搜索产生距离数组的子查询。这些距离数组使您能够识别与查询相似或不同的子序列。mass的核心是有效地计算z-标准化下的欧几里德距离,本质上是领域不可知的。它是建立在矩阵轮廓算法基础上的基本算法。
mass ts是一个与python 2和3兼容的库。
免费软件:apache软件许可证2.0
功能
原始作者的算法
- mass—mass的第一次实现
- mass2-mass的第二个实现速度明显更快。通常这是你会用到的。
- mass3-mass2的分段版本,可以根据硬件进行调整。通常用于搜索非常大的时间序列。
- 质量加权-todo
特定于库的算法
- mass2_batch—mass2的一个批处理版本,它减少了总体内存使用,提供并行化,并使您能够在时间序列中找到前k个匹配项。使用此实现的目标是进行非常大的时间序列相似性搜索。
- top_k_motif-查找给定查询的类似子序列的top k个数。它返回子序列的起始索引。
- top_k_discords-查找给定查询的不同子序列的前k个数。它返回子序列的起始索引。
安装
pip install mass-ts
示例用法
可以在mass-ts-examples repository找到一个专门的实用示例库。
importnumpyasnpimportmass_tsasmtsts=np.loadtxt('ts.txt')query=np.loadtxt('query.txt')# massdistances=mts.mass(ts,query)# mass2distances=mts.mass2(ts,query)# mass3distances=mts.mass3(ts,query,256)# mass2_batch# start a multi-threaded batch job with all cpu cores and give me the top 5 matches.# note that batch_size partitions your time series into a subsequence similarity search.# even for large time series in single threaded mode, this is much more memory efficient than# MASS2 on its own.batch_size=10000top_matches=5n_jobs=-1indices,distances=mts.mass2_batch(ts,query,batch_size,top_matches=top_matches,n_jobs=n_jobs)# find minimum distancemin_idx=np.argmin(distances)# find top 4 motif starting indicesk=4exclusion_zone=25top_motifs=mts.top_k_motifs(distances,k,exclusion_zone)# find top 4 discord starting indicesk=4exclusion_zone=25top_discords=mts.top_k_discords(distances,k,exclusion_zone)
引文
Abdullah Mueen,Yan Zhu,Michael Yeh,Kaveh Kamgar,Krishnamurthy Viswanathan,Chetan Kumar Gupta和Eamonn Keogh(2015),欧氏距离下时间序列子序列最快相似搜索算法,网址:http://www.cs.unm.edu/~mueen/FastestSimilaritySearch.html
======= 历史记录
0.1.0(2019-05-16)
- pypi上的第一个版本。
0.1.1(2019-05-17)
- 小精度错误修复。
0.1.2(2019-05-19)
- mass2_批量发布用于高效的大时间序列搜索。
0.1.3(2019-05-19)
- top_k_基序-找到给定距离剖面的top k相似子序列。
- top_k_discords-在给定距离剖面的情况下,查找top k不同的子序列。