NILM非侵入式负荷监测
第三章 NILMTK程序运行
文章目录
NILMTK安装完成之后,可以运行程序测试一下,官方给出了教程https://github.com/nilmtk/buildsys2019-paper-notebooks,但该教程是.ipynb
格式,需要利用jupyter notebook打开,本文提供.py
格式文件,可以直接运行。作为对比算法,非常方便!
from nilmtk.api import API
from nilmtk.disaggregate import CO,Mean,FHMMExact
REDD1 = {
'power': {'mains': ['apparent'],'appliance': ['active']},
'sample_rate':60,
'appliances': ['fridge','light','washer dryer','dish washer','microwave'],
'artificial_aggregate': True,
'methods': {
'CO': CO({}),
'Mean': Mean({}),
'FHMMExact': FHMMExact({'num_of_states':3}),
},
'train': {
'datasets': {
'REDD': {
'path': 'D:/data/redd.h5',
'buildings': {
1: {
'start_time': '2011-04-19',
'end_time': '2011-04-25'
}
}
}
}
},
'test': {
'datasets': {
'REDD': {
'path': 'D:/data/redd.h5',
'buildings': {
1: {
'start_time': '2011-05-01',
'end_time': '2011-05-02'
}
}
}
},
'metrics':['rmse','f1score','accuracyscore']
}
}
api_results_experiment_1 = API(REDD1)
errors_keys = api_results_experiment_1.errors_keys
errors = api_results_experiment_1.errors
list_mean_result=[err.mean() for err in errors]
ps_rmse=list_mean_result[0]
ps_f1=list_mean_result[1]
ps_acc=list_mean_result[2]
结果如图所示:
公众号
欢迎收藏、点赞、和转发,你的阅读是我的前进动力!