nilmtk / nilmtk

Non-Intrusive Load Monitoring Toolkit (nilmtk)
http://nilmtk.github.io
Apache License 2.0
817 stars 457 forks source link

API: Select a specific appliance #888

Open klemenjak opened 4 years ago

klemenjak commented 4 years ago

Hi,

thanks for providing such a great extension to NILMTK!

I don't have an issue but a question on the API. In cases where a dataset has multiple appliances of the same kind, how do I select a specific appliance? For instance, how do I select fridge number two if there is more than one fridge in a MeterGroup in your API?

Let me explain what I mean with the help of REDD. I loaded the HDF5 version with NILMTK:

from nilmtk import DataSet
redd = DataSet('REDD.h5')
elec = redd.buildings[1].elec
elec

As we see, there are three different meters related to the appliance type 'light': 9, 17 and 18.

OUT[1]:

MeterGroup(meters=
  ElecMeter(instance=1, building=1, dataset='REDD', site_meter, appliances=[])
  ElecMeter(instance=2, building=1, dataset='REDD', site_meter, appliances=[])
  ElecMeter(instance=5, building=1, dataset='REDD', appliances=[Appliance(type='fridge', instance=1)])
  ElecMeter(instance=6, building=1, dataset='REDD', appliances=[Appliance(type='dish washer', instance=1)])
  ElecMeter(instance=7, building=1, dataset='REDD', appliances=[Appliance(type='sockets', instance=1)])
  ElecMeter(instance=8, building=1, dataset='REDD', appliances=[Appliance(type='sockets', instance=2)])
  ElecMeter(instance=9, building=1, dataset='REDD', appliances=[Appliance(type='light', instance=1)])
  ElecMeter(instance=11, building=1, dataset='REDD', appliances=[Appliance(type='microwave', instance=1)])
  ElecMeter(instance=12, building=1, dataset='REDD', appliances=[Appliance(type='unknown', instance=1)])
  ElecMeter(instance=13, building=1, dataset='REDD', appliances=[Appliance(type='electric space heater', instance=1)])
  ElecMeter(instance=14, building=1, dataset='REDD', appliances=[Appliance(type='electric stove', instance=1)])
  ElecMeter(instance=15, building=1, dataset='REDD', appliances=[Appliance(type='sockets', instance=3)])
  ElecMeter(instance=16, building=1, dataset='REDD', appliances=[Appliance(type='sockets', instance=4)])
  ElecMeter(instance=17, building=1, dataset='REDD', appliances=[Appliance(type='light', instance=2)])
  ElecMeter(instance=18, building=1, dataset='REDD', appliances=[Appliance(type='light', instance=3)])
  ElecMeter(instance=19, building=1, dataset='REDD', appliances=[Appliance(type='unknown', instance=2)])
  MeterGroup(meters=
    ElecMeter(instance=3, building=1, dataset='REDD', appliances=[Appliance(type='electric oven', instance=1)])
    ElecMeter(instance=4, building=1, dataset='REDD', appliances=[Appliance(type='electric oven', instance=1)])
  )
  MeterGroup(meters=
    ElecMeter(instance=10, building=1, dataset='REDD', appliances=[Appliance(type='washer dryer', instance=1)])
    ElecMeter(instance=20, building=1, dataset='REDD', appliances=[Appliance(type='washer dryer', instance=1)])
  )
)

How would I select light number 18 with the help of the new API? I tried using the integer values but ran into problems. Usually, one would use elec[18] to select meter 18 but that didn't work for me.

In the API, I guess the following statement would give me the first instance of lights, right?

redd = {
  'power': {
    'mains': ['apparent','active'],
    'appliance': ['apparent','active']
  },
  'sample_rate': 60,
  'artificial_aggregate':True,
  'appliances': ['light'],
  'methods': {

      'Mean': {},"CO":{},'Hart85':{},"FHMM_EXACT":{},
      "RNN":{'n_epochs':50,'batch_size':1024},"Seq2Point":{'n_epochs':50,'batch_size':1024},
      "Seq2Seq":{'n_epochs':50,'batch_size':1024},"DAE":{'n_epochs':50,'batch_size':1024},"WindowGRU":{'n_epochs':30,'batch_size':1024},

  },
.....
.....
}

I would be happy to receive some hints how I could fix that. For sure, this topic will apply to others as well.

Thanks, Christoph

Rithwikksvr commented 4 years ago

Hello @klemenjak!

I apologize for the really late reply. The API does not support choosing an appliance manually. If you wish to choose it manually, you can load the data as list of data frames and use the nilmtk-contrib algorithms to train and test. Then you can compute the metrics of your choice.

But again the process is just similar to the process of training in the original nilmtk. Definitely the API has a a few advantages, but it also has its fair share of limitations.

I'll add a notebook soon to show the usage of the nilmtk-contrib algorithms on custom data.

klemenjak commented 4 years ago

Hi, thank you so much for your reply. Highly appreciated. I will try to do that :)

Hocafa92 commented 3 years ago

could we use nilmtk.global_meter_group[ElecMeterID(instance=18, building=1, dataset='REDD')] to choose the specific meter?