|
1 | | -# Links: |
2 | | -```code |
3 | | -1. git: https://github.com/thieunguyen5991/two_elm/ |
4 | | -2. paper: https://bitbucket.org/nguyenthieu2102/paper_two/ |
5 | | -``` |
| 1 | +# A Novel Workload Prediction Model Using ELM with Opposition-based Tug of War Optimization |
| 2 | + |
| 3 | +## Cite us |
| 4 | +* If you see my code and data useful and use it, please cite us as follows |
| 5 | + |
| 6 | + * Nguyen, T., Nguyen, T., Nguyen, B. M., & Nguyen, G. (2019). Efficient Time-Series Forecasting Using Neural Network and Opposition-Based Coral Reefs Optimization. International Journal of Computational Intelligence Systems, 12(2), 1144-1161. |
| 7 | + |
| 8 | + * Nguyen, T., Nguyen, B. M., & Nguyen, G. (2019, April). Building Resource Auto-scaler with Functional-Link Neural Network and Adaptive Bacterial Foraging Optimization. In International Conference on Theory and Applications of Models of Computation (pp. 501-517). Springer, Cham. |
| 9 | + |
| 10 | + * Nguyen, T., Tran, N., Nguyen, B. M., & Nguyen, G. (2018, November). A Resource Usage Prediction System Using Functional-Link and Genetic Algorithm Neural Network for Multivariate Cloud Metrics. In 2018 IEEE 11th Conference on Service-Oriented Computing and Applications (SOCA) (pp. 49-56). IEEE. |
| 11 | + |
| 12 | +* If you want to know more about code, or want a pdf of both above paper, contact me: [email protected] |
| 13 | + |
| 14 | +* Take a look at this repos, the simplify code using python (numpy) for all algorithms above. (without neural networks) |
| 15 | + |
| 16 | + * https://github.com/thieunguyen5991/metaheuristics |
| 17 | + |
| 18 | +## How to read my repository |
| 19 | +1. data: include raw and formatted data |
| 20 | +2. envs: include conda environment and how to install conda environment |
| 21 | +3. utils: Helped functions such as IO, Draw, Math, Settings (for all model and parameters), Preprocessing... |
| 22 | +4. paper: include 2 main folders: |
| 23 | + * results: forecasting results of all models (3 folders inside) |
| 24 | + * final: final forecasting results (runs on server) |
| 25 | + * test: testing forecasting results (runs on personal computer, just for test) |
| 26 | + * temp: nothing (just for copy of test folder) |
| 27 | + * scaling: scaling results |
| 28 | +5. model: (4 folders) |
| 29 | + * root: (want to understand the code, read this classes first) |
| 30 | + * root_base.py: root for all models (traditional, hybrid and variants...) |
| 31 | + * root_algo.py: root for all optimization algorithms |
| 32 | + * traditional: root for all traditional models (inherit: root_base) |
| 33 | + * hybrid: root for all hybrid models (inherit: root_base) |
| 34 | + * optimizer: (this classes inherit: root_algo.py) |
| 35 | + * evolutionary: include algorithms related to evolution algorithm such as GA, DE,.. |
| 36 | + * swarm: include algorithms related to swarm optimization such as PSO, BFO, ... |
| 37 | + * physics: include algorithms related to physics optimization such as QSO, TWO, ... |
| 38 | + * main: (final models) |
| 39 | + * this classes will use those optimizer above and those root (traditional, hybrid) above |
| 40 | + * the running files (outside with the downloaded folder) will call this classes |
| 41 | + * the traditional models will use single file such as: traditional_elm, traditional_rnn,... |
| 42 | + * the hybrid models will use 2 files, example: hybrid_elm.py and GA.py (optimizer files) |
| 43 | +6. special files |
| 44 | + * *_scipt.py: running files (*: represent model) such as ga_elm_script.py => GA + ELM |
| 45 | + |
| 46 | + |
| 47 | +## Notes |
6 | 48 |
|
7 | | -## Model comparison |
8 | | -1. MLNN |
9 | | -2. ELM |
10 | | -3. GA-ELM |
11 | | -4. PSO-ELM |
12 | | -5. TWO-ELM |
13 | | -6. ITWO-ELM |
| 49 | +1. To improve the speed of Pycharm when opening (because Pycharm will indexing when opening), you should right click to |
| 50 | +paper and data folder => Mark Directory As => Excluded |
14 | 51 |
|
| 52 | +2. How to run models? |
| 53 | +```code |
| 54 | +1. Before runs the models, make sure you clone this repository in your laptop: |
| 55 | + https://github.com/chasebk/code_OTWO_ELM |
15 | 56 |
|
| 57 | +2. Then open it in your editor like Pycharm or Spider... |
16 | 58 |
|
17 | | -=== Running ==== |
18 | | -1. MLNN (normal mode) |
| 59 | +3. Now you need to create python environment using conda (assumpted that you have already had it). Open terminal |
| 60 | + conda your_environment_name create -f envs/env.yml (go to the root project folder and create new environment from my file in: envs/env.yml) |
19 | 61 |
|
20 | | -==> Last: MLNN (stability mode) |
| 62 | +4. Now you can activate your environment and run the models |
| 63 | + conda activate your_environment_name # First, activate your environment to get the needed libraries. |
| 64 | + python model_name |
21 | 65 |
|
| 66 | +For example: |
| 67 | + conda ai_env create -f envs/env.yml |
| 68 | + conda activate ai_env |
| 69 | + python elm_script.py |
22 | 70 |
|
| 71 | +5. My model name: |
23 | 72 |
|
| 73 | + 1. MLNN (1 HL) => mlnn1hl_script.py |
| 74 | + 2. ELM => elm_script.py |
| 75 | + 3. GA-ELM => ga_elm_script.py |
| 76 | + 4. PSO-ELM => pso_elm_script.py |
| 77 | + 5. ABFOLS-ELM => abfols_elm_script.py |
| 78 | + 6. DE-ELM => de_elm_script.py |
| 79 | + 7. TWO-ELM => two_elm_script.py |
| 80 | + 8. OTWO-ELM => otwo_elm_script.py |
| 81 | +``` |
24 | 82 |
|
25 | | -## Optimized the number of hidden neuron in hidden layer |
| 83 | +3. In paper/results/final model includes folder's name represent the data such as |
26 | 84 | ```code |
27 | | -https://iopscience.iop.org/article/10.1088/1757-899X/261/1/012002/pdf |
28 | | -https://sci-hub.tw/10.1016/j.neucom.2011.12.062 |
29 | | -https://arxiv.org/pdf/1501.06115.pdf |
30 | | -https://www.researchgate.net/publication/271201213_A_detailed_analysis_on_extreme_learning_machine_and_novel_approaches_based_on_ELM |
31 | | -https://www.researchgate.net/post/Can_anyone_help_with_Training_Extreme_Learning_Machines_neural_network_on_very_Large_Datasets |
32 | | -https://www.sciencedirect.com/science/article/pii/S2212671612002181 |
33 | | -http://www3.ntu.edu.sg/home/ASAHTan/Papers/2008/ELM%20NEUCOM%2008.pdf |
34 | | -http://or.nsfc.gov.cn/bitstream/00001903-5/112878/1/1000004116461.pdf |
35 | | -
|
| 85 | +cpu: input model would be cpu, output model would be cpu |
| 86 | +ram: same as cpu |
| 87 | +multi_cpu : input model would be cpu and ram, output model would be cpu |
| 88 | +multi_ram : input model would be cpu and ram, output model would be ram |
| 89 | +multi : input model would be cpu and ram, output model would be cpu and ram |
36 | 90 | ``` |
37 | 91 |
|
| 92 | +4. How to change model's parameters? |
| 93 | +```code |
| 94 | +You can change the model's parameters in file: utils/SettingPaper.py |
| 95 | +
|
| 96 | +For example: |
| 97 | +
|
| 98 | ++) For traditional models: MLNN, ELM |
| 99 | +
|
| 100 | +####: MLNN-1HL |
| 101 | +mlnn1hl_paras_final = { |
| 102 | + "sliding": [2, 5, 10], |
| 103 | + "hidden_sizes" : [[5] ], |
| 104 | + "activations": [("elu", "elu")], # 0: elu, 1:relu, 2:tanh, 3:sigmoid |
| 105 | + "learning_rate": [0.0001], |
| 106 | + "epoch": [5000], |
| 107 | + "batch_size": [128], |
| 108 | + "optimizer": ["adam"], # GradientDescentOptimizer, AdamOptimizer, AdagradOptimizer, AdadeltaOptimizer |
| 109 | + "loss": ["mse"] |
| 110 | +} |
| 111 | +
|
| 112 | +- If you want to tune the parameters, you can adding more value in each parameters like this: |
| 113 | +
|
| 114 | +- sliding: [1, 2, 3, 4] or you want just 1 parameter: [12] |
| 115 | +- hidden_sizes: [ [5], [10], [100] ] or [ [14] ] |
| 116 | +- activations: [ ("elu", "relu"), ("elu", "tanh") ] or just: [ ("elu", "elu") ] |
| 117 | +- learning_rate: [0.1, 0.01, 0.001] or just: [0.1] |
| 118 | +.... |
| 119 | +
|
| 120 | +
|
| 121 | ++ For hybrid models: GA_ELM, PSO_ELM, ABFOLS-ELM, TWO-ELM, OTWO-ELM |
| 122 | + |
| 123 | +#### : GA-ELM |
| 124 | +ga_elm_paras_final = { |
| 125 | + "sliding": [2, 3, 5], |
| 126 | + "hidden_size" : [(5, False)], |
| 127 | + "activation": [0], # 0: elu, 1:relu, 2:tanh, 3:sigmoid |
| 128 | + "train_valid_rate": [(0.6, 0.4)], |
| 129 | +
|
| 130 | + "epoch": [100], |
| 131 | + "pop_size": [20], # 100 -> 900 |
| 132 | + "pc": [0.95], # 0.85 -> 0.97 |
| 133 | + "pm": [0.025], # 0.005 -> 0.10 |
| 134 | + "domain_range": [(-1, 1)] # lower and upper bound |
| 135 | +} |
| 136 | +
|
| 137 | +- Same as traditional models. |
| 138 | +``` |
38 | 139 |
|
| 140 | +5. Where is the results folder? |
| 141 | +```code |
| 142 | +- Look at the running file, for example: ga_elm_script.py |
39 | 143 |
|
40 | | -# Project structure |
41 | | -1. General view class |
42 | | - |
43 | | - |
44 | | -2. Details view class |
45 | | -* root files |
46 | | - |
47 | | -   |
| 144 | ++) For normal runs (Only run 1 time for each model). |
| 145 | + _There are 3 type of results file include: model_name.csv file, model_name.png file and Error-model_name.csv file |
| 146 | + _model_name.csv included: y_true and y_predict |
| 147 | + _model_name.png is visualized of: y_true and y_predict (test dataset) |
| 148 | + _Error-model_name.csv included errors of training dataset after epoch. 1st, 2nd column are: MSE, MAE errors |
48 | 149 |
|
49 | | -* algorithm files |
| 150 | +=> All 3 type of files above is automatically generated in folder: paper/results/final/... |
50 | 151 |
|
51 | | -   |
| 152 | ++) For stability runs (Run each model 15 times with same parameters). |
| 153 | +Because in this test, we don't need to visualize the y_true and y_predict and also don't need to save y_true and y_predict |
| 154 | +So I just save 15 times running in the same csv files in folder: paper/results/stability/... |
52 | 155 |
|
53 | | -  |
| 156 | +- Noted: |
54 | 157 |
|
55 | | -* main files |
| 158 | ++ In the training set we can use MSE or MAE error. But for the testing set, we can use so much more error like: R2, MAPE, ... |
| 159 | +You can find the function code described it in file: |
| 160 | + model/root/root_base.py |
| 161 | + + _save_results__: this is for normal runs |
| 162 | + + _save_results_ntimes_run__: this is for stability runs. |
56 | 163 |
|
57 | | - |
| 164 | ++ You want to change the directory to save results?. Simple. |
58 | 165 |
|
59 | | - |
| 166 | +For example: Look at running file: ga_elm_script.py |
60 | 167 |
|
| 168 | +_Line 14: pathsave = "paper/results/final/" --> This is general path to save file. |
| 169 | +But for each dataset like: wc, uk, eu,... I need to save it in different folder right. So now look at |
61 | 170 |
|
| 171 | +_Line 34: "path_save_result": pathsave + requirement_variables[4]. |
| 172 | +Here, the requirement_variables[4]: is inside file: utils/SettingPaper.py ("eu/", # path_save_result) |
62 | 173 |
|
| 174 | +So the final path to save the results for normal runs is: paper/results/final/eu/ |
| 175 | +``` |
63 | 176 |
|
64 | | -## Server Errors: Check lỗi multi-threading giữa numpy và openBlas |
65 | | -Ta phải check xem core-backend của numpy nó đang dùng thư viện hỗ trợ nào : blas hay mkl |
66 | | - python |
67 | | - import numpy |
68 | | - numpy.__config__.show() |
69 | | - |
70 | | -https://stackoverflow.com/questions/17053671/python-how-do-you-stop-numpy-from-multithreading |
71 | | -https://stackoverflow.com/questions/19257070/unintented-multithreading-in-python-scikit-learn |
| 177 | +6. Take a look at project_structure.md file. Describe how the project was built. |
72 | 178 |
|
73 | | ----> Để chặn numpy không chạy multi-thread sẽ tốn thời gian trao đổi: |
74 | | -Thêm vào file ~/.bashrc hoặc ~/.bash_profile dòng sau: |
75 | | - export OPENBLAS_NUM_THREADS=1 (Nếu dùng OpenBlas) |
76 | | - export MKL_NUM_THREADS=1 (Nếu dùng MKL) |
77 | 179 |
|
78 | | - export OPENBLAS_NUM_THREADS=1 |
79 | | - export MKL_NUM_THREADS=1 |
80 | | - |
81 | | - source ~/.bashrc |
| 180 | +## License |
82 | 181 |
|
83 | | -## Neu bi loi: Cannot share object lien quan den matplotlib tren server thi sua nhu sau: |
84 | | -``` |
85 | | - sudo apt update |
86 | | - sudo apt install libgl1-mesa-glx |
87 | | -``` |
| 182 | +[](https://opensource.org/licenses/Apache-2.0) |
| 183 | + |
0 commit comments