epyt-flow 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- epyt_flow/EPANET/EPANET/SRC_engines/AUTHORS +28 -0
- epyt_flow/EPANET/EPANET/SRC_engines/LICENSE +21 -0
- epyt_flow/EPANET/EPANET/SRC_engines/Readme_SRC_Engines.txt +18 -0
- epyt_flow/EPANET/EPANET/SRC_engines/enumstxt.h +134 -0
- epyt_flow/EPANET/EPANET/SRC_engines/epanet.c +5578 -0
- epyt_flow/EPANET/EPANET/SRC_engines/epanet2.c +865 -0
- epyt_flow/EPANET/EPANET/SRC_engines/epanet2.def +131 -0
- epyt_flow/EPANET/EPANET/SRC_engines/errors.dat +73 -0
- epyt_flow/EPANET/EPANET/SRC_engines/funcs.h +193 -0
- epyt_flow/EPANET/EPANET/SRC_engines/genmmd.c +1000 -0
- epyt_flow/EPANET/EPANET/SRC_engines/hash.c +177 -0
- epyt_flow/EPANET/EPANET/SRC_engines/hash.h +28 -0
- epyt_flow/EPANET/EPANET/SRC_engines/hydcoeffs.c +1151 -0
- epyt_flow/EPANET/EPANET/SRC_engines/hydraul.c +1117 -0
- epyt_flow/EPANET/EPANET/SRC_engines/hydsolver.c +720 -0
- epyt_flow/EPANET/EPANET/SRC_engines/hydstatus.c +476 -0
- epyt_flow/EPANET/EPANET/SRC_engines/include/epanet2.h +431 -0
- epyt_flow/EPANET/EPANET/SRC_engines/include/epanet2_2.h +1786 -0
- epyt_flow/EPANET/EPANET/SRC_engines/include/epanet2_enums.h +468 -0
- epyt_flow/EPANET/EPANET/SRC_engines/inpfile.c +810 -0
- epyt_flow/EPANET/EPANET/SRC_engines/input1.c +707 -0
- epyt_flow/EPANET/EPANET/SRC_engines/input2.c +864 -0
- epyt_flow/EPANET/EPANET/SRC_engines/input3.c +2170 -0
- epyt_flow/EPANET/EPANET/SRC_engines/main.c +93 -0
- epyt_flow/EPANET/EPANET/SRC_engines/mempool.c +142 -0
- epyt_flow/EPANET/EPANET/SRC_engines/mempool.h +24 -0
- epyt_flow/EPANET/EPANET/SRC_engines/output.c +852 -0
- epyt_flow/EPANET/EPANET/SRC_engines/project.c +1359 -0
- epyt_flow/EPANET/EPANET/SRC_engines/quality.c +685 -0
- epyt_flow/EPANET/EPANET/SRC_engines/qualreact.c +743 -0
- epyt_flow/EPANET/EPANET/SRC_engines/qualroute.c +694 -0
- epyt_flow/EPANET/EPANET/SRC_engines/report.c +1489 -0
- epyt_flow/EPANET/EPANET/SRC_engines/rules.c +1362 -0
- epyt_flow/EPANET/EPANET/SRC_engines/smatrix.c +871 -0
- epyt_flow/EPANET/EPANET/SRC_engines/text.h +497 -0
- epyt_flow/EPANET/EPANET/SRC_engines/types.h +874 -0
- epyt_flow/EPANET/EPANET-MSX/MSX_Updates.txt +53 -0
- epyt_flow/EPANET/EPANET-MSX/Src/dispersion.h +27 -0
- epyt_flow/EPANET/EPANET-MSX/Src/hash.c +107 -0
- epyt_flow/EPANET/EPANET-MSX/Src/hash.h +28 -0
- epyt_flow/EPANET/EPANET-MSX/Src/include/epanetmsx.h +102 -0
- epyt_flow/EPANET/EPANET-MSX/Src/include/epanetmsx_export.h +42 -0
- epyt_flow/EPANET/EPANET-MSX/Src/mathexpr.c +937 -0
- epyt_flow/EPANET/EPANET-MSX/Src/mathexpr.h +39 -0
- epyt_flow/EPANET/EPANET-MSX/Src/mempool.c +204 -0
- epyt_flow/EPANET/EPANET-MSX/Src/mempool.h +24 -0
- epyt_flow/EPANET/EPANET-MSX/Src/msxchem.c +1285 -0
- epyt_flow/EPANET/EPANET-MSX/Src/msxcompiler.c +368 -0
- epyt_flow/EPANET/EPANET-MSX/Src/msxdict.h +42 -0
- epyt_flow/EPANET/EPANET-MSX/Src/msxdispersion.c +586 -0
- epyt_flow/EPANET/EPANET-MSX/Src/msxerr.c +116 -0
- epyt_flow/EPANET/EPANET-MSX/Src/msxfile.c +260 -0
- epyt_flow/EPANET/EPANET-MSX/Src/msxfuncs.c +175 -0
- epyt_flow/EPANET/EPANET-MSX/Src/msxfuncs.h +35 -0
- epyt_flow/EPANET/EPANET-MSX/Src/msxinp.c +1504 -0
- epyt_flow/EPANET/EPANET-MSX/Src/msxout.c +401 -0
- epyt_flow/EPANET/EPANET-MSX/Src/msxproj.c +791 -0
- epyt_flow/EPANET/EPANET-MSX/Src/msxqual.c +2010 -0
- epyt_flow/EPANET/EPANET-MSX/Src/msxrpt.c +400 -0
- epyt_flow/EPANET/EPANET-MSX/Src/msxtank.c +422 -0
- epyt_flow/EPANET/EPANET-MSX/Src/msxtoolkit.c +1164 -0
- epyt_flow/EPANET/EPANET-MSX/Src/msxtypes.h +551 -0
- epyt_flow/EPANET/EPANET-MSX/Src/msxutils.c +524 -0
- epyt_flow/EPANET/EPANET-MSX/Src/msxutils.h +56 -0
- epyt_flow/EPANET/EPANET-MSX/Src/newton.c +158 -0
- epyt_flow/EPANET/EPANET-MSX/Src/newton.h +34 -0
- epyt_flow/EPANET/EPANET-MSX/Src/rk5.c +287 -0
- epyt_flow/EPANET/EPANET-MSX/Src/rk5.h +39 -0
- epyt_flow/EPANET/EPANET-MSX/Src/ros2.c +293 -0
- epyt_flow/EPANET/EPANET-MSX/Src/ros2.h +35 -0
- epyt_flow/EPANET/EPANET-MSX/Src/smatrix.c +816 -0
- epyt_flow/EPANET/EPANET-MSX/Src/smatrix.h +29 -0
- epyt_flow/EPANET/EPANET-MSX/readme.txt +14 -0
- epyt_flow/EPANET/compile.sh +4 -0
- epyt_flow/VERSION +1 -0
- epyt_flow/__init__.py +24 -0
- epyt_flow/data/__init__.py +0 -0
- epyt_flow/data/benchmarks/__init__.py +11 -0
- epyt_flow/data/benchmarks/batadal.py +257 -0
- epyt_flow/data/benchmarks/batadal_data.py +28 -0
- epyt_flow/data/benchmarks/battledim.py +473 -0
- epyt_flow/data/benchmarks/battledim_data.py +51 -0
- epyt_flow/data/benchmarks/gecco_water_quality.py +267 -0
- epyt_flow/data/benchmarks/leakdb.py +592 -0
- epyt_flow/data/benchmarks/leakdb_data.py +18923 -0
- epyt_flow/data/benchmarks/water_usage.py +123 -0
- epyt_flow/data/networks.py +650 -0
- epyt_flow/gym/__init__.py +4 -0
- epyt_flow/gym/control_gyms.py +47 -0
- epyt_flow/gym/scenario_control_env.py +101 -0
- epyt_flow/metrics.py +404 -0
- epyt_flow/models/__init__.py +2 -0
- epyt_flow/models/event_detector.py +31 -0
- epyt_flow/models/sensor_interpolation_detector.py +118 -0
- epyt_flow/rest_api/__init__.py +4 -0
- epyt_flow/rest_api/base_handler.py +70 -0
- epyt_flow/rest_api/res_manager.py +95 -0
- epyt_flow/rest_api/scada_data_handler.py +476 -0
- epyt_flow/rest_api/scenario_handler.py +352 -0
- epyt_flow/rest_api/server.py +106 -0
- epyt_flow/serialization.py +438 -0
- epyt_flow/simulation/__init__.py +5 -0
- epyt_flow/simulation/events/__init__.py +6 -0
- epyt_flow/simulation/events/actuator_events.py +259 -0
- epyt_flow/simulation/events/event.py +81 -0
- epyt_flow/simulation/events/leakages.py +404 -0
- epyt_flow/simulation/events/sensor_faults.py +267 -0
- epyt_flow/simulation/events/sensor_reading_attack.py +185 -0
- epyt_flow/simulation/events/sensor_reading_event.py +170 -0
- epyt_flow/simulation/events/system_event.py +88 -0
- epyt_flow/simulation/parallel_simulation.py +147 -0
- epyt_flow/simulation/scada/__init__.py +3 -0
- epyt_flow/simulation/scada/advanced_control.py +134 -0
- epyt_flow/simulation/scada/scada_data.py +1589 -0
- epyt_flow/simulation/scada/scada_data_export.py +255 -0
- epyt_flow/simulation/scenario_config.py +608 -0
- epyt_flow/simulation/scenario_simulator.py +1897 -0
- epyt_flow/simulation/scenario_visualizer.py +61 -0
- epyt_flow/simulation/sensor_config.py +1289 -0
- epyt_flow/topology.py +290 -0
- epyt_flow/uncertainty/__init__.py +3 -0
- epyt_flow/uncertainty/model_uncertainty.py +302 -0
- epyt_flow/uncertainty/sensor_noise.py +73 -0
- epyt_flow/uncertainty/uncertainties.py +555 -0
- epyt_flow/uncertainty/utils.py +206 -0
- epyt_flow/utils.py +306 -0
- epyt_flow-0.1.0.dist-info/LICENSE +21 -0
- epyt_flow-0.1.0.dist-info/METADATA +139 -0
- epyt_flow-0.1.0.dist-info/RECORD +131 -0
- epyt_flow-0.1.0.dist-info/WHEEL +5 -0
- epyt_flow-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Module provides a function for loading the water usage data set by P. Pavlou et al.
|
|
3
|
+
"""
|
|
4
|
+
import os
|
|
5
|
+
import numpy as np
|
|
6
|
+
import pandas as pd
|
|
7
|
+
|
|
8
|
+
from ...utils import get_temp_folder, download_if_necessary
|
|
9
|
+
from ...metrics import accuracy_score, precision_score, roc_auc_score, f1_micro_score
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def compute_evaluation_score(y_pred: np.ndarray, y: np.ndarray) -> dict:
|
|
13
|
+
"""
|
|
14
|
+
Evaluates the performance of a detection method.
|
|
15
|
+
|
|
16
|
+
Note that instead of a single metric, the following set of metrics is used:
|
|
17
|
+
- Accuracy
|
|
18
|
+
- Precision
|
|
19
|
+
- F1-score (using "micro" averaging)
|
|
20
|
+
- Cohen's kappa
|
|
21
|
+
- ROC AUC
|
|
22
|
+
|
|
23
|
+
Parameters
|
|
24
|
+
----------
|
|
25
|
+
y_pred : `numpy.ndarray`
|
|
26
|
+
Event indication prediction over time
|
|
27
|
+
y : `numpy.ndarray`
|
|
28
|
+
Ground truth event indication over time.
|
|
29
|
+
|
|
30
|
+
Returns
|
|
31
|
+
-------
|
|
32
|
+
`dict`
|
|
33
|
+
All evaluation scores.
|
|
34
|
+
"""
|
|
35
|
+
return {"accuracy": accuracy_score(y_pred, y), "precision": precision_score(y_pred, y),
|
|
36
|
+
"f1-micro": f1_micro_score(y_pred, y), "roc-auc": roc_auc_score(y_pred, y)}
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def load_water_usage(download_dir: str = None, return_X_y: bool = True, verbose: bool = True) -> dict:
|
|
40
|
+
"""
|
|
41
|
+
"Monitoring domestic water consumption: A comparative study of model-based and data-driven
|
|
42
|
+
end-use disaggregation methods" by P. Pavlou, S. Filippou, S. Solonos, S. G. Vrachimis,
|
|
43
|
+
K. Malialis, D. G. Eliades, T. Theocharides, M. M. Polycarpou is a benchmark concerning the
|
|
44
|
+
monitoring of water usage of different household appliances. Informing consumers about it has
|
|
45
|
+
been shown to have an impact on their behavior toward drinking water conservation. The data
|
|
46
|
+
were created using the STochastic Residential water End-use Model (STREaM)
|
|
47
|
+
(Cominola et al., 2018), a modelling software developed that generates synthetic time series
|
|
48
|
+
data of a household.
|
|
49
|
+
|
|
50
|
+
This benchmark data set is for identifying active appliances from the aggregated water
|
|
51
|
+
consumption -- i.e. a multi-class classification probelm. The data set considers the use
|
|
52
|
+
of standard toilet, standard shower, standard faucet, high efficiency clothes washer,
|
|
53
|
+
and standard dishwasher in a 2-person household for a period of 180 days (6 months) and
|
|
54
|
+
it has a resolution of 10s.
|
|
55
|
+
The data set is already split into 3 sub-sets for training (90 days), validation (45 days),
|
|
56
|
+
and testing (45 days).
|
|
57
|
+
|
|
58
|
+
For more information see https://github.com/KIOS-Research/Water-Usage-Dataset/
|
|
59
|
+
|
|
60
|
+
.. note::
|
|
61
|
+
|
|
62
|
+
Note that although this data set is synthetic, only the final data set is provided.
|
|
63
|
+
|
|
64
|
+
Parameters
|
|
65
|
+
----------
|
|
66
|
+
download_dir : `str`, optional
|
|
67
|
+
Path to the data files -- if None, the temp folder will be used.
|
|
68
|
+
If the path does not exist, the data files will be downloaded to the given path.
|
|
69
|
+
|
|
70
|
+
The default is None.
|
|
71
|
+
return_X_y : `bool`, optional
|
|
72
|
+
If True, the data is returned together with the multi-class labels as two Numpy arrays,
|
|
73
|
+
otherwise, the data is returned as Pandas data frame.
|
|
74
|
+
|
|
75
|
+
The default is True.
|
|
76
|
+
verbose : `bool`, optional
|
|
77
|
+
If True, a progress bar is shown while downloading files.
|
|
78
|
+
|
|
79
|
+
The default is True.
|
|
80
|
+
|
|
81
|
+
Returns
|
|
82
|
+
-------
|
|
83
|
+
`dict`
|
|
84
|
+
The data set as a dictionary with entries "train", "validation", and "test" containing
|
|
85
|
+
the respective data.
|
|
86
|
+
"""
|
|
87
|
+
# Download data if necessary
|
|
88
|
+
download_dir = download_dir if download_dir is not None else get_temp_folder()
|
|
89
|
+
|
|
90
|
+
base_url = "https://github.com/KIOS-Research/Water-Usage-Dataset/raw/main/Dataset/"
|
|
91
|
+
url_train_data = base_url + "Trainset.csv"
|
|
92
|
+
url_valid_data = base_url + "Validationset.csv"
|
|
93
|
+
url_test_data = base_url + "Testset.csv"
|
|
94
|
+
|
|
95
|
+
f_train_in = os.path.join(download_dir, "train_water_usage.csv")
|
|
96
|
+
f_valid_in = os.path.join(download_dir, "valid_water_usage.csv")
|
|
97
|
+
f_test_in = os.path.join(download_dir, "test_water_usage.csv")
|
|
98
|
+
|
|
99
|
+
download_if_necessary(f_train_in, url_train_data, verbose)
|
|
100
|
+
download_if_necessary(f_valid_in, url_valid_data, verbose)
|
|
101
|
+
download_if_necessary(f_test_in, url_test_data, verbose)
|
|
102
|
+
|
|
103
|
+
# Load and return data
|
|
104
|
+
df_data_train = pd.read_csv(f_train_in)
|
|
105
|
+
df_data_valid = pd.read_csv(f_valid_in)
|
|
106
|
+
df_data_test = pd.read_csv(f_test_in)
|
|
107
|
+
|
|
108
|
+
if return_X_y is False:
|
|
109
|
+
return {"train": df_data_train, "validation": df_data_valid, "test": df_data_test}
|
|
110
|
+
else:
|
|
111
|
+
r = {"train": None, "validation": None, "test": None}
|
|
112
|
+
|
|
113
|
+
for k, df_data in zip(["train", "validation", "test"],
|
|
114
|
+
[df_data_train, df_data_valid, df_data_test]):
|
|
115
|
+
X = df_data["TOTAL"].to_numpy()
|
|
116
|
+
del df_data["TOTAL"]
|
|
117
|
+
|
|
118
|
+
y = df_data.to_numpy()
|
|
119
|
+
y = (y != 0).astype(np.int8)
|
|
120
|
+
|
|
121
|
+
r[k] = (X, y)
|
|
122
|
+
|
|
123
|
+
return r
|