You are on page 1of 6

KNN methods with varied k, distance and training data to

disaggregate NILM with similar load characteristic.


Fitra Hidiyanto Abdul Halim
Electrical Engineering Electrical Engineering
Universitas Indonesia Universitas Indonesia
Depok, Indonesia Depok, Indonesia
fitra.hidiyanto@ui.ac.id ahalim@ee.ui.ac.id

ABSTRACT the average growth in energy consumption is 2.3% - 2.5% and by


the end of 2030, it is estimated that the increase will be twice or
Non-Intrusive Load Monitoring (NILM) enables detection of around 16000 TWh per year [1]. The majority of the world's
appliances which are ON or OFF even the characteristics for each energy that is utilized is more than 83% derived from
equipment installed in homes, industries, laboratories, etc. by unsustainable energy derived from fossil while energy derived
disaggregating the total electrical consumption at the central from renewable energy such as wind, solar, biomass energy is
Power panel. The K-NN method is one of the most simple and only around 2% of total energy [2]. Non-intrusive load monitoring
commonly used machine learning methods for classifying with (NILM) is one of the ways developed and recommended for energy
good performance and competing with even complex methods. efficiency, whether in the housing sector, companies, industries
or government, or for fault diagnosis applications [3], without the
In this paper the K nearest neighbor (KNN) method is performed
need to access each piece of appliances to install additional
on NILM AMPds data which having distinctive similar load equipment or take measurements on each appliance [4].
characteristic between different appliances, with 9 different
distances, 7 types of total training data (10% -70%) and performed In this paper, we research the disaggregation of the NILM data
for k (1-25) for best result, then an accuracy performance that we download from the AMPDs server with the K-Nearest
Neighbors (KNN) machine learning method with variations in the
comparison for disaggregation on 100% data and cross-validation
amount of training data and test data, k variations, distance
(10%-80%) data also performance comparison of disaggregation on variations and comparison of disaggregation results on only real
data which feature real power only, compared with data which power data only (1 feature) and if given additional reactive power
feature having additional reactive power data, have done. data (2 features).
From the test and research results it was found that by adding
reactive power data, the disaggregation results on NILM data 2 Methodology
which having distinctive similar load characteristic between
different appliances with KNN method were more than 20% 2.1 Problem definition
accurate. It up to 95.06% accuracy on 70% training data, while for From NILM research aspects, robust algorithms to distinctive
disaggregation on data that test data were completely different similar load characteristics between different appliances and load
from the training data, disaggregation with 20% training data modeling feature considering unknown appliances are challenges
provides better performance in terms of accuracy as well as to be solved and still remain open up to days [5]. The problem that
process speed. we tested in this research is to prove that the addition of reactive
power data to NILM disaggregation data will provide far more
accurate results than just disaggregation of real power data. NILM
CCS CONCEPTS is a method of recognizing the characteristics of devices,
• Computing methodologies • Machine learning • Learning especially the ON-OFF of each device installed by detection of
paradigms • Supervised learning • Supervised learning by total electric power used which is the accumulated power of
classification several devices that are on.

KEYWORDS
Non-Intrusive Load Monitoring (NILM), k-nearest neighbour
(KNN), disaggregation, Real Power and Reactive power, Accuracy,
Precision, Recall. Where P(t) is the total power consumption reading (aggregated)
while Pi is the power of each device that is on [4]. Fig. 1 below
shows total power consumption chart of 3 appliances which
1 Introduction
shows similar real power overlapping from several conditions. In
Energy management is one of the topics that is developing addition to solve the problem of similar load characteristics in
today, this is one solution to the problem of energy shortages due NILM, in this paper, answers are also sought on what data, both
to an increase in the number of industries and population where
APCORISE’20, June, 2020, Depok, West Java, Indonesia F. Hidiyanto et al.

training data, and test data also at what distance method, as well Table 1. Classification of NILM disaggregation
as what k values will provide maximum accuracy.

Fig. 1. Aggregated Power Consumption 2.3 Distance Measurement

2.2 KNN Methods In this paper, we use 9 distances which is the best in terms of
accuracy of 8 major distance families that contain a total of 54
K-nearest-neighbor (KNN) is one of machine learning kinds of distances [7]. 9 distances used in this paper are :
algorithms used to classify new objects based on a number of their
closest neighbors. This algorithm is relatively simple and is a) Manhattan (MD), has the following formula:
classified as supervised learning, lazy learning algorithm, and
instance-based or memory-based learning [6]. The K-NN
classification algorithm that has been done is as follow:
b) Lorentzian distance (LD), formulated as follows:
 Prepare data training and testing data from NILM data
 Choose K value
 Count distance value (d) for each data test to data
training c) Canberra distance (CanD), formulated as follows:
 Sort d from smallest to biggest
 Classify test data based on k closest neighbor
d) Clark distance (ClaD), formulated as follows:

e) Divergence distance (DivD), formulated as follows:

f) Squared Chi Squared (SCSD), formulated as below :

g) Average distance (AvgD), Known as Euclidean average:

h) Hassanat Distance (HasD), is formulated as below:

Fig. 2. Flowchart K-NN classification method


KNN methods with varied k, distance and training data to
APCORISE’20, June, 2020, Depok, West Java, Indonesia
disaggregate NILM with similar load characteristic.

Where:

i) Euclidean distance (ED), commonly used method: Figure 5. TV and Entertainment Usage Chart

From the Individual AMPds data, we made synthetic data that


fulfilled the possible variations of ON and OFF of the three devices
in time based with features are Real Power and Reactive Power
and obtained data that will be used as a reference for conducting
3 Simulation test and result tests (100% data, contain of 1840 data) which chart shown in Fig.
1, which is chart data in two dimension that indicate overlap data
3.1 Data Preprocessing from similar value of Real Power data from all classes, and
classification variation is shown in table 1, which shows 8
In this paper, we conduct research and tests with synthetic
classification of 8 possible variation from 3 appliances.
data formed from 3 appliances data obtained from AMPds2 data:
The Almanac of Minutely Power dataset (version 2) published
online [8]. The three appliances used are Dishwasher as usage
3.2 Simulation and analysis for Real power
chart is shown in figure 3, Clothes washer which usage chart is data only (1 feature)
shown in figure 4 (appliance type 2) and TV and entertainment
which usage chart is shown in figure 5 below. In the simulation of this sub-chapter we did a test on synthetic
AMPds data but only for real power data and performed on 100%
synthetic data as test data with training data 10% - 70%, with 9
variations in distance and with variations in k 1-25 for each test.
From table 2 below can be seen that the highest Accuracy value is
obtained in the test results with 70.87% training data for 72.61%
accuracy with k = 3 for distance Average, Euclidean and
Manhattan, and it appears that the greater amount of training data
the higher accuracy value will be gotten.

Table 2. Accuracy for Real power only 100% test data and 10%
- 70% training data for k value majorities is 3.

Figure 3. Dishwasher usage chart

From the graph in figure 6 below which shows the value of


accuracy vs k, it can be clearly seen that the highest value on the
graph is 70.87% at k = 3, and the greater the value of K, the
accuracy decreases. Besides that, it seems that the accuracy value
is getting bigger with increasing training data.
Figure 4. Clothes washer Usage Chart
APCORISE’20, June, 2020, Depok, West Java, Indonesia F. Hidiyanto et al.

Tabel 3. Confusion matrix Clark distance with training set


10.33% (k=24) at cross-validation data.

From the confusion matrix table 3 above we can conclude there


is confusion in determining the class between classes 3 and 8, also
between classes 6 and 7, there is also a prediction error where the
Fig 6. Graphic % Accuracy vs K value for training set size 10% actual class 6 but predicted as class 2. Classification of accuracy in
to 70% (KNN Real Power only for 100% data test) this confusion matrix based on the following equation [9].

To test cross-validation data, in this case, test data is


completely different with training data (no data is similar), for
training set 10.3% - 81%, the accuracy of the results can be seen in
the fig. 7 where accuracy increases with the greater K value, and
it is found that for training data 10.33% and 81.09% the accuracy is Where:
almost the same, but because of the large data, classification TP = number of True Positive sample in the test set,
process speed will be much faster with training data 10.33%. TN = number of True negative sample in the test set,
FP = number of False Positive sample in the test set,
FN = number of False Negative samples in the test set.

In order to assess the performance with respect to every class,


we also compute precision and recall measures which defined as
[2]:

From table 4 below it can be seen that the value of precision


and recall is directly proportional to accuracy, and it shows
Fig. 7. Graphic % Accuracy vs K value for training set size
maximum value for training data at 10.33% for distance Canberra,
10.33% to 81.09% (KNN Real Power only for Cross-validation data
Clark, and Divergence, where for the confusion matrix table is
test)
approximately similar as table 3.
KNN methods with varied k, distance and training data to
APCORISE’20, June, 2020, Depok, West Java, Indonesia
disaggregate NILM with similar load characteristic.

3.3 Simulation and analysis for Real Power


and Reactive Power (2 features)

As in the previous sub-chapter, in this sub-chapter we tested


synthetic AMPds data, but for real power & reactive power data
and performed 100% synthetic data as test data with training data
10% - 70%, with 9 variations of distance and with variations k 1 -
25 for each test. From table 5 it can be seen that the highest
Accuracy value is obtained up to 95.06% in the test results with
70.87% training data with k = 1.

Tabel 5. Accuracy of Real & Reactive power 100% test data and
10% - 70% training data

Fig. 9. Graph of % Accuracy vs K value (1-25) for training set


size 10.33% to 81.09% (KNN Real & Reactive Power for Cross-
validation data test.

For cross-validation test with Real & Reactive Power data, you
can see the accuracy results in fig. 9 for training data 10.33% -
81.09% which shows that 21% training data achieved the highest
It can be seen that the accuracy value increases with increasing Accuracy value at 72.69%, for k value 14 so it is very beneficial
of training set data as shown in graphic at fig. 8 below. with small data that can produce high accuracy.

Tabel 6. Confusion matrix Manhattan distance, training set


70% (k=1) tested on 100% data, accuracy 95.06%

Confusion matrix shown in table 6 above is from Manhattan


distance, 70% training data and accuracy up to 95.06%. To get a
better result we have to check confusion between actual class and
Fig. 8. Graphic % Accuracy vs K value (1-25) for training set wrong prediction result which marked with red circle, for
size 10% to 70% (KNN Real & Reactive Power for 100% data test) example between actual class 6 and predicted as class 7 vice versa.
APCORISE’20, June, 2020, Depok, West Java, Indonesia F. Hidiyanto et al.

From table 7 Precision and Recall above, it can be seen that the From tests results in only real power data with variations in
value of precision and recall has a maximum value when the the amount of training data from 10% to 70%, for testing the initial
accuracy is maximum, namely, the Euclidean distance with 21% data 100%, obtained highest Accuracy / RR value at 72.61% in 70%
training data with a precision value of 0.7659 and a recall of 0.7606, training data with Manhattan, average and Euclidean distance for
can be compared with the results on the Real power only data test k = 3 , whereas when tested with cross-validation data which test
which is only 0.5593 precision and 0.5637 recall. data are different and not the same as training data, obtained
highest Accuracy / RR value is 54.93% with 81% training data for
It can be conclude that the results of disaggregation in Real Average, Euclidean, Hassanat, Lontzian, Manhattan distance with
Power and Reactive Power feature data get more than 20% higher k = 20.
in accuracy, precision and recall compared to disaggregation only
in real power feature only, both test on 100% data or cross- The interesting thing in disaggregation test results for all
validation test. distance on 100% initial data, the accuracy value will increase with
the number of training data addition with k value 1, but for KNN
disaggregation test results on cross-validation data where the test
4 Conclusion data is different and not similar compared to the training data, it
is obtained for maximum Accuracy for KNN with features are real
Power data & reactive power is 20% training data, with 72.69%
The k-nn method for disaggregating NILM data that has
accuracy for k = 14, while for KNN with feature only Real Power
similar load characteristic will give much better results when
data, maximum Accuracy is obtained at 81% training data with
adding other data as a differentiator, which in this research is
54.93% accuracy for k = 20, but only a small difference with
reactive power data which will give different values for some
training data 10.33% with 54.77% accuracy at k = 24. In terms of
equipment even with the same real power values with the result
processing time, it will be more efficient with small training data
of more than 20% accuracy compared to the disaggregation
but produces maximum accuracy or only a little difference
method with only real power value. Of the 9 methods tested, the
compared to KNN with large training data.
Average, Canberra, Clark, Divergence, Euclidean, Hassanat,
Lorentzian, Manhattan and Squared Chi-Squared methods all give
good accuracy and vary for each amount of training data.
REFERENCES
From tests results with variations in the amount of training
[1] Sigit. T. A., Abdul. H.(2018)."Steady State Modification Method Based On
data from 10% to 70%, the results are with more training data, Backpropagation Neural Network For Non-Intrusive Load Monitoring
recognition rate will be better for testing the initial 100% data (NILM)".MATEC Web of Conferences 218, 02013 (2018). ICIEE 2018.
which obtained highest Accuracy value at 95.06%, precision 0.957 https://doi.org/10.1051/matecconf/201821802013
[2] J. Z. Kolter, M. J. Johnson.(2011). "REDD: A Public Data Set for Energy
and recall 0.9568 in 70% training data with Manhattan and Disaggregation Research". In proceedings of the SustKDD workshop on Data
Lontzian distance for k = 1 , whereas when tested with cross- Mining Applications in Sustainability, http://redd.csail.mit.edu/
[3] Antonio R., Alvaro H., Jesus U., Maria R. & Juan G.(2019)."NILM Techniques for
validation data which test data are different and not similar as Intelligent Home Energy Management and Ambient Assisted Living: A
training data, highest Accuracy value obtained is 72.69% with 21% Review". Energies 2019, 12, 2203; doi: 10.3390/en12112203.
www.mdpi.com/journal/energies.
training data for Euclidean distance with k = 14. [4] G. W. Hart, “Nonintrusive appliance load monitoring,” in Proceedings of the
IEEE, 1992, vol. 80, no. 12, pp. 1870–1891.
The results of disaggregation with the K-nn algorithm with [5] M. Zhuang, M. Shahidehpour, and Z. Li. (2018). "An Overview of Non-Intrusive
Load Monitoring: Approaches, Business Applications, and Challenges". 2018
additional reactive power have very good results up to 95% International Conference on Power System Technology (POWERCON).
accuracy, 0.957 precision and 0.9568 recall value for POWERCON2018 Paper NO. 201804270000624.
[6 ]Rifkie P. (2018). "Belajar Machine Learning, Teori dan Praktik". Penerbit
disaggregation tests on the initial 100% data with 70% training Informatika.
data from the initial data, while disaggregation with the K-nn [7] V. B. S. Prasatha, H. A. A. Alfeilate, A. B. A. Hassanate, O. Lasassmehe, A. S.
algorithm without additional reactive power have around 72.61% Tarawnehf, M. B. Alhasanat, H. S. E. Salmane.(2019)."Effects of Distance
Measure Choice on KNN Classifier Performance - A Review". Big Data. Volume:
accuracy, 0.7654 precision and 0.7382 recall value on the initial 7 Issue 4: December 16, 2019.221-248. http://doi.org/10.1089/big.2018.0175.
100% data with 70% training data from the initial data. [8] Makonin, Stephen. (2016). "AMPds2: The Almanac of Minutely Power dataset
(Version2)",
"https://dataverse.harvard.edu/dataset.xhtml?persistentId=doi:10.7910/DVN/FI
The results of disaggregation by KNN method with additional E0S4"
[9] C. C. Yang, C. S. Soh, V. V. Yap.(2017)" A systematic approach in appliance
reactive power values with the cross-validation method which disaggregation using k-nearest neighbours and naive Bayes classifiers for
test data are different and not the same as training data, have an energy efficiency ". Springer Science+Business Media B.V. 2017.
up to 72.69% accuracy, 0.7659 precision and 0.7606 recall value [10] I. Abubakar, S. N. Khalid, M. W. Mustafa, H. Shareef and M. Mustapha.(2016).
"Recent Approaches and Applications of Non-Intrusive Load Monitoring".
with training data 21%, While the results of disaggregation by ARPN Journal of Engineering and Applied Sciences. VOL. 11, NO. 7, APRIL
KNN method with data only real power with cross-validation 2016. ISSN 1819-6608. http://www.arpnjournals.com.
methods have an up to 54.77% accuracy, 0.5593 precision and
0.5637 recall value for training data 10.3%.

You might also like