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

Error for train_elec.plot() whcih is :DatetimeArray._generate_range() got an unexpected keyword argument 'closed' #973

Open
hamidreza2122 opened this issue Jan 8, 2024 · 4 comments

Comments

@hamidreza2122
Copy link

I am working on disaggregation_and_metrics and there is an error for train_elec.plot() whcih is :DatetimeArray._generate_range() got an unexpected keyword argument 'closed'
The details of error is:
TypeError Traceback (most recent call last)
Cell In[24], line 1
----> 1 train_elec.plot()

File c:\users\rezaeiha\nilmtk\nilmtk\metergroup.py:1416, in MeterGroup.plot(self, kind, **kwargs)
1408 function_map = {
1409 'separate lines': self._plot_separate_lines,
1410 'sum': super(MeterGroup, self).plot,
(...)
1413 'energy bar': self._plot_energy_bar
1414 }
1415 try:
-> 1416 ax = function_mapkind
1417 except KeyError:
1418 raise ValueError("'{}' not a valid setting for 'kind' parameter."
1419 .format(kind))

File c:\users\rezaeiha\nilmtk\nilmtk\metergroup.py:1425, in MeterGroup._plot_separate_lines(self, ax, plot_legend, **kwargs)
1423 for meter in self.meters:
1424 if isinstance(meter, MeterGroup):
-> 1425 ax = meter.plot(ax=ax, plot_legend=False, kind='sum', **kwargs)
1426 else:
1427 ax = meter.plot(ax=ax, plot_legend=False, **kwargs)

File c:\users\rezaeiha\nilmtk\nilmtk\metergroup.py:1416, in MeterGroup.plot(self, kind, **kwargs)
1408 function_map = {
1409 'separate lines': self._plot_separate_lines,
1410 'sum': super(MeterGroup, self).plot,
(...)
1413 'energy bar': self._plot_energy_bar
1414 }
1415 try:
-> 1416 ax = function_mapkind
1417 except KeyError:
1418 raise ValueError("'{}' not a valid setting for 'kind' parameter."
1419 .format(kind))

File c:\users\rezaeiha\nilmtk\nilmtk\electric.py:179, in Electric.plot(self, ax, timeframe, plot_legend, unit, plot_kwargs, **kwargs)
177 kwargs['sections'] = [timeframe]
178 kwargs = self._set_sample_period(timeframe, **kwargs)
--> 179 power_series = self.power_series_all_data(**kwargs)
180 if power_series is None or power_series.empty:
181 return ax

File c:\users\rezaeiha\nilmtk\nilmtk\electric.py:105, in Electric.power_series_all_data(self, **kwargs)
103 def power_series_all_data(self, **kwargs):
104 chunks = []
--> 105 for series in self.power_series(**kwargs):
106 if len(series) > 0:
107 chunks.append(series)

File c:\users\rezaeiha\nilmtk\nilmtk\electric.py:626, in Electric.load_series(self, **kwargs)
624 physical_quantity = kwargs['physical_quantity']
625 generator = self.load(**kwargs)
--> 626 for chunk in generator:
627 if chunk.empty:
628 yield chunk

File c:\users\rezaeiha\nilmtk\nilmtk\metergroup.py:720, in MeterGroup.load(self, **kwargs)
718 start = normalise_timestamp(section.start, freq)
719 tz = None if start.tz is None else start.tz.zone
--> 720 index = pd.date_range(
721 start.tz_localize(None), section.end.tz_localize(None), tz=tz,
722 closed='left', freq=freq)
723 chunk = combine_chunks_from_generators(
724 index, columns, self.meters, kwargs)
725 yield chunk

File ~\AppData\Local\anaconda3\Lib\site-packages\pandas\core\indexes\datetimes.py:1009, in date_range(start, end, periods, freq, tz, normalize, name, inclusive, unit, **kwargs)
1006 if freq is None and com.any_none(periods, start, end):
1007 freq = "D"
-> 1009 dtarr = DatetimeArray._generate_range(
1010 start=start,
1011 end=end,
1012 periods=periods,
1013 freq=freq,
1014 tz=tz,
1015 normalize=normalize,
1016 inclusive=inclusive,
1017 unit=unit,
1018 **kwargs,
1019 )
1020 return DatetimeIndex._simple_new(dtarr, name=name)

TypeError: DatetimeArray._generate_range() got an unexpected keyword argument 'closed'

@kkkomiii
Copy link

kkkomiii commented Jan 10, 2024

Hi. I'm also working on 'disaggregation_and_metrics.ipynb'. I am asking because I am curious because the results of 'test_elec.plot()' are different from the results posted on github.
스크린샷 2024-01-10 오전 11 36 00
스크린샷 2024-01-10 오전 11 36 05

In the graph posted on github, the part with nan data was flatly plotted as if there was data, but in the result of my plotting, the nan data was plotted as a broken graph because there was no data. Can you tell me why there is a difference?
I like the translation. Please add it to the end of this translation and translate the text below.

I used the code as it was posted on the github notebook, and also experimented with the redd.h5 file using the open data.

I was wondering if the data had been preprocessed in some other way, so I looked at a paper called 'NILMTK: An open source toolkit for non-intrusive load mornitoring' published in 2014, but I couldn't find it.
Can you tell me why there is a difference?

And if you look at appendix A. of the paper, there is a part that says 'building = downsample(building, rule = '1T'), and I wonder if 'downsample()' can be used in nilmtk.

Thanks for the reply in advance.

@hamidreza2122
Copy link
Author

hamidreza2122 commented Jan 10, 2024

Hi ,the first error has been solved but, right now I have the same things in 'test_elec.plot()' are different from the results posted on github,and also my results at the end for the rmse are different.

pic2

@kkkomiii
Copy link

Thank you for the confirmation.

I wanted to see if I could get the same results as the plot results posted on github, so I tried using the fill method(ffill) and saw that the results were different.
And as expected, the rmse results were very different from those posted on github.

When determining the state in the github code, 2000 samples larger than the threshold value are randomly selected, so the rmse results may come out slightly different, but my rmse results differ so greatly that it is strange.

If you find a code that gives the same results as those posted on GitHub, please let me know.

@Virtsionis
Copy link

Virtsionis commented Feb 6, 2024

@hamidreza2122 how did you solve the first error?

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

3 participants