GiuTan / Weak-NILM

8 stars 1 forks source link

ukdale_experiment_1_2.py output issue #4

Closed ricky5932TW closed 2 months ago

ricky5932TW commented 3 months ago

螢幕擷取畫面 (172) Does your team run the code? Different output formats from exactly the same model with the same input. How do you do that?

GiuTan commented 3 months ago

Hi, if the strong_weak_flag is True, the built model has a different structure and thus produces two outputs. On the other hand, if the flag is False this means that the network is built to produce only the strong predictions. I hope this helps you!

ricky5932TW commented 3 months ago

Ok, I got it. Thanks for your reply and I'm sorry for my rudeness.

So, there are some other problems cause the code is too complex.

  1. How do you do the data pre-processing, what are the concepts? The code you wrote is too hard to read, and It seems not to have been mentioned in the paper.

  2. How do you decide the threshold when we are about to output? Do you let the program know the answer when it shouldn't? 螢幕擷取畫面 (53)

ricky5932TW commented 3 months ago

Currently, I'm trying to reproduce some of your results in pytorch. It's quite helpful if you can help me figure it out.

GiuTan commented 2 months ago

Hi, in the following, there are the answers to your questions.

  1. About the pre-processing I compute the standardization of the aggregate signal (code lines from 346 to 366) by using the mean and the standard deviation calculated on all the input windows.

  2. The threshold to post-process the predictions and compute the evaluation metrics is decided on the validation set. The input variable of the function is called 'Y_test'. Anyway, you can put whatever you want (as for any general function). In fact, in the published work the decision of the best threshold is computed on the validation set, for which the ground truth is known (Y_val). Then, the same threshold is applied also to post-process the test set. In the code you can find this line:

thres_strong = thres_analysis(Y_val, output_strong,classes=5)

where thres_strong is a list of thresholds because we have 5 classes, thus there is one threshold for each class.

About code readability, it is in my plans to upload an updated version. Anyway, everything you need is already there! Let me know if you have other doubts.

ricky5932TW commented 2 months ago

It helps me a lot to understand your article.

The last issue I encountered was how to process the weak label and the on/off status for the strong label. I've read your code in dataset creation, however, I can not get the main idea of them. Can you explain that? Thanks for your effort.

GiuTan commented 2 months ago

The main idea is the possibility of assigning two different types of labels:

  1. Strong labels - one label for each sample of the aggregate signal that refers to the on/off status of the appliance in that sample
  2. Weak labels - one label for the entire window of the aggregate signal that refers to the presence of one or more activations inside the window

Thus, strong labels are assigned based on a power threshold (if the appliance power signal is greater than the threshold it is assigned as 1, otherwise 0). For weak labels, if one or more appliance activations are included in that window, then the weak label of that window is equal to 1. There is a relation between strong and weak labels: if at least one sample of the appliance power signal overcomes the threshold and is assigned with label 1, the weak label is 1 as well. If all the strong labels are 0, also the weak label is 0 for the same window.