OdysseasKr / neural-disaggregator

Code for NILM experiments using Neural Networks. Uses Keras/Tensorflow and the NILMTK.
MIT License
138 stars 57 forks source link

Getting a TypeError while calling the function "metrics.recall_precision_accuracy_f1(predicted, ground_truth)" #3

Closed HRafiq closed 4 years ago

HRafiq commented 6 years ago

@OdysseasKr @ChristoferNal @Spatzi

I am trying to execute your code ukdale-test.py. I also tried to execute ipynb file "RNN-example.ipynb". All went well but when I try to call the function "metrics.recall_precision_accuracy_f1(predicted, ground_truth)" to check the performance of the model, it gives me type error like this: " TypeError: Only valid with DatetimeIndex, TimedeltaIndex or PeriodIndex, but got an instance of 'Index' ". I am unable to resolve this error. Something is wrong with "predicted" file (which holds the data of building-2 [dish washer]that was generated after testing the model in HDF5 format.

Please help me out in this matter.

![Uploading SS2.jpg…]()

HRafiq commented 6 years ago

Screenshots of the error are attached below:

ss1

ss2

OdysseasKr commented 6 years ago

Hi @HRafiq. Can you post a list of the packages and their versions? You can do that by running pip freeze Looking at your screenshots I assume that you are using Python3 with Anaconda, is that correct?

HRafiq commented 6 years ago

Yes I'm using Python 3.6.4 with Anaconda in Windows 10. List of packages is shown in the attached screenshots.

While trying to resolve the issue, I noticed that I was writing wrong date format in setting training and testing window size. Then, I wrote the format for training and testing dataset like this:

train.set_window(start="2013-05-21", end="2013-10-08")

When I ran the code again, model was trained and tested successfully but metrics.recall function was again giving an error. It is no more giving type-error as mentioned earlier, This time the error was "ValueError: Arrays lengths must be same". Everything looks fine to me but don't know why i'm getting this error. Is this because of versions of installed packages?

HRafiq commented 6 years ago

Screenshots of installed packages:

ss3

ss4

ss5

OdysseasKr commented 6 years ago

When we wrote the code for this repo, NILMTK was only working correctly with dates using pandas 0.18. They recently moved to pandas 0.22 which may have caused this issue. It will take some time for me to test with the new NILMTK code.

If you figure out the issue, feel free to submit a pull request. If you are in a rush to get some results, you can use my fork of NILMTK or write the metrics without NILMTK imports.

OdysseasKr commented 6 years ago

So I tested the neural-disaggregator with the last version of NILMTK and Pandas. I indeed found a bug and submitted a pull request to NILMTK. You can find more info in #4

However, I am not really sure if this is related to your issue. Do you encounter the same issue with REDD as well?

HRafiq commented 6 years ago

I resolved the issue by running the NILMTK functions in separate python file. I made separate metrics class, and write NILMTK functions in it instead of calling them from electric.py nilm file. Anyhow my issue has been resolved. I couldn't use REDD dataset becuase I'm unable to download dataset from their website (http://redd.csail.mit.edu/). I contacted the concerned persons to download the dataset but got no reply. If you have REDD dataset in HDF5 format then please share that file with me. I really need REDD dataset for my work.


Hasan Rafiq PhD Scholar Key Laboratory of Power System Intelligent Dispatch & Control School of Electrical Engineering, Shandong University, China Ph: +86 155 0863 3171

On Sun, Jul 1, 2018 at 3:41 AM, Odysseas (Ody) Krystalakos < notifications@github.com> wrote:

So I tested the neural-disaggregator with the last version of NILMTK and Pandas. I indeed found a bug and submitted a pull request to NILMTK. You can find more info in #4 https://github.com/OdysseasKr/neural-disaggregator/issues/4

However, I am not really sure if this is related to your issue. Do you encounter the same issue with REDD as well?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/OdysseasKr/neural-disaggregator/issues/3#issuecomment-401562084, or mute the thread https://github.com/notifications/unsubscribe-auth/AltvN76FYIGde6D55GmStaJvDzgCdjNiks5uB9RngaJpZM4UJ0QE .