OdysseasKr / neural-disaggregator

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

Metrics call to align_two_meters parameter order #16

Open franzmueller opened 5 years ago

franzmueller commented 5 years ago

Hi, I've been playing around with your code according to your IPython Notebooks and came across an error when calling the metrics function. Down the line, this function calls nlimtks goodsections.py function _process_chunk (https://github.com/nilmtk/nilmtk/blob/412be54eefd81ae78d0f1ed3053bf8977063e61d/nilmtk/stats/goodsections.py#L36) which expects a DataFrame with parameter timeframe, which did not exist and therefore threw an error.

While trying to fix my error, I came across the documentation of align_two_meters which says it would take the timeframe from meter 'master', which is the first argument of that function. In your call you provide the function with (pred, ground), which seems off to me. After changing the order to (ground, pred) I no longer encountered the problem.

Can you assure me, that the order of your arguments is indeed correct?

This is the section I'm referencing, but the call is them same for all metrics files:

https://github.com/OdysseasKr/neural-disaggregator/blob/dec19c9beeb15e2c23a1dd2b1c52efafc7775810/DAE/metrics.py#L12

OdysseasKr commented 5 years ago

Hi @franzmueller The first argument is pred since we are only care about the timeframe for which we have predicted data. This happens because ground might contain more samples than the pred (due to to dropped samples or other preprocessing).

Which dataset are you using? Are you sure that your dataframes are not empty? What is the exact error message?

franzmueller commented 5 years ago

Thanks for your quick reply!

I'm using the UK-Dale dataset and set the timeframe to a single day for testing. I am sure the dataframes aren't empty, I have checked using the debugger. Sorry for not providing the full message in the first place. Here is what I got:

Traceback (most recent call last): File "E:/github/kafka-operator-disaggregation-python/python/playground/playground.py", line 98, in start="29-11-2015", switch="30-11-2015 00:00:00", end="12-01-2015 00:00:00") File "E:/github/kafka-operator-disaggregation-python/python/playground/playground.py", line 86, in nn rpaf = metrics.recall_precision_accuracy_f1(predicted, ground_truth) File "E:\github\kafka-operator-disaggregation-python\python\neural_disaggregator\RNN\metrics.py", line 16, in recall_precision_accuracy_f1 for chunk in aligned_meters: File "D:\Programme\Anaconda3\envs\nilmtk-env\lib\site-packages\nilmtk\electric.py", line 829, in align_two_meters sections = master.good_sections() File "D:\Programme\Anaconda3\envs\nilmtk-env\lib\site-packages\nilmtk\elecmeter.py", line 626, in good_sections nodes, results_obj, loader_kwargs) File "D:\Programme\Anaconda3\envs\nilmtk-env\lib\site-packages\nilmtk\elecmeter.py", line 707, in _get_stat_from_cache_or_compute computed_result = self._compute_stat(nodes, loader_kwargs) File "D:\Programme\Anaconda3\envs\nilmtk-env\lib\site-packages\nilmtk\elecmeter.py", line 759, in _computestat results.run() File "D:\Programme\Anaconda3\envs\nilmtk-env\lib\site-packages\nilmtk\node.py", line 43, in run for in self.process(): File "D:\Programme\Anaconda3\envs\nilmtk-env\lib\site-packages\nilmtk\stats\goodsections.py", line 33, in process self._process_chunk(chunk, metadata) File "D:\Programme\Anaconda3\envs\nilmtk-env\lib\site-packages\nilmtk\stats\goodsections.py", line 63, in _process_chunk timeframe = df.timeframe File "D:\Programme\Anaconda3\envs\nilmtk-env\lib\site-packages\pandas\core\generic.py", line 3614, in getattr return object.getattribute(self, name) AttributeError: 'DataFrame' object has no attribute 'timeframe' Closing remaining open files:E:\github\kafka-operator-disaggregation-python\python\ukdale\ukdale.h5...done

This is the dataframe that gets to goodsections.py: image