Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metrics call to align_two_meters parameter order #16

Open
franzmueller opened this issue Jun 16, 2019 · 2 comments
Open

Metrics call to align_two_meters parameter order #16

franzmueller opened this issue Jun 16, 2019 · 2 comments

Comments

@franzmueller
Copy link

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:

aligned_meters = align_two_meters(pred, ground)

@OdysseasKr
Copy link
Owner

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
Copy link
Author

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 _compute_stat
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants