简体   繁体   English

如何将数据拟合到隐马尔可夫模型sklearn / hmmlearn

[英]How to fit data into Hidden Markov Model sklearn/hmmlearn

I have a time series data set as a csv file with following columns- 我有一个时间序列数据集作为csv文件,其中包含以下列 -

ID,TIMESTAMP,MEASUREMENTS[10]

For an ID multiple measurements are there with the associated timestamp when those measurements were made. 对于ID,在进行那些测量时,存在具有相关时间戳的多个测量。 The column measurements contains a list of 10 measurements. 列测量包含10个测量的列表。 Measurement in one record(associated with a particular timestamp) somehow depends on the previous record. 一个记录中的测量(与特定时间戳相关联)以某种方式取决于先前的记录。

eg. 例如。 of dataset: 数据集:

ID,TIMESTAMP,MEASUREMENTS
1,0,[123,456,567.....]
1,100,[....]
1,350,[....]
2,0,[....]
2,200,[.....]

Also, the measurement array contains NaNs at some indexes. 此外,测量数组在某些索引处包含NaN。 Finally, I have some label associated with each ID which is the outcome of the measurements performed till the very last timestamp for that id. 最后,我有一些与每个ID相关联的标签,这是执行测量的结果,直到该id的最后一个时间戳。 My Objective is to fit this data into an HMM model and then Predict the label for the test dataset which is in the same format. 我的目标是将这些数据拟合到HMM模型中,然后预测具有相同格式的测试数据集的标签。 How to fit this model into a HMM Model from sklearn/hmmlearn ? 如何从sklearn / hmmlearn将这个模型融入HMM模型? sklearns documentation is not up to the mark for the model, no parameters are explained. sklearns文档未达到模型的标记,不解释任何参数。

Since your problem require predicting a label for a squence. 由于您的问题需要预测标签的顺序。 You should use seqlearn which is a sequence classification tool. 您应该使用seqlearn这是一个序列分类工具。

Also, fitting the data in an HMM would require some pre processing since it accepts a list of arrays. 此外,在HMM中拟合数据需要一些预处理,因为它接受数组列表。 You could concatenate time stamp and the three measurements associated with each id in an ascending order with respect to time. 您可以按时间升序连接时间戳和与每个ID关联的三个度量。 this would give you a sequence of length 33 for each ID. 这会为每个ID提供一个长度为33的序列。

Let me know if you require further help. 如果您需要进一步的帮助,请告诉我。 I recently used HMMLearn for a project. 我最近使用HMMLearn进行了一个项目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM