Hello all:
I go through the code from FHMM disaggregation algorithm and have a question about it. The FHMM algorithm in the NILMTK package is only using 1-Dimensional data, which is the active power, for the train and predict process. I was wondering that what if we use 2-Dimensional of data (which is active & reactive power) to train and predict? Theoretically, it would make our prediction much more reliable. So I go through the GaussianHMM module, which is the critical one for the FHMM disaggregation, and find no where to input a 2-Dimensional training data.
I have found that the GaussianHMM module has an attribute called "n_features" which explained as the "Dimensionality of the Gaussian emissions". But there's no parameter in the module to change that attribute.
For example, I have a dataframe of the active power(W) and reactive power(VAR) of a fridge. I tried this:
In[1]: data.head()
Out[1]:
W VAR
2013-06-07 00:00:00 0.111 2.483
2013-06-07 00:00:01 0.200 2.547
2013-06-07 00:00:02 0.152 2.480
2013-06-07 00:00:03 0.159 2.444
2013-06-07 00:00:04 0.215 2.510
In[2]: data.shape
Out[2]: (2000, 2)
In[3]: active = np.array(data.W.tolist())
...: reactive = np.array(data.VAR.tolist())
...: total = np.concatenate((active, reactive))
...: length = [len(active), len(reactive)]
In[4]: model = hmm.GaussianHMM(n_components=2)
...: model.fit(total.reshape(-1,1), length)
Out[4]:
GaussianHMM(algorithm='viterbi', covariance_type='diag', covars_prior=0.01,
covars_weight=1, init_params='stmc', means_prior=0, means_weight=0,
min_covar=0.001, n_components=2, n_iter=10, params='stmc',
random_state=None, startprob_prior=1.0, tol=0.01, transmat_prior=1.0,
verbose=False)
In[5]: pred=model.predict(total.reshape(-1,1), length)
Out[5]: array([1, 1, 1, ..., 1, 1, 1])
In[6]: len(pred)
Out[6]: 4000
The "pred" supposed to return a list of states of only 2000 elements. But it returns 4000, which means it regard my "total" as a 1-Dimensional data to disaggregate.
So anyone have ideas about using 2-Dimensional data to train and predict the states?