We were asked to create application that will be able to detect anomalies. The application displays a form and the user should provide the following parameters:
- Training csv file
- Testing csv file
- Algorithm type
- Threshold
By given these parameters and sending them by submission, the application will return anomalies report.
The application supports MVC architecture:
- View - "index.html" that design how the app should looks like, "result.html" that displays the form's output
- Control - "expServer.js" that is our API and includes the requested http requests: GET and POST.
GET - "/" - the method returns the "index.html" - main view
POST - "/Detect" - the method returns response JSON with anomalies records
POST - "/Detect/fromView" - we added this function in order to display our app view anomalies report - Model - "Model" folder - our server that by calling to some parameters, it returns the response to our API (controller)
To run the server, please make sure the following components are installed on your system:
- Linux based OS or WSL2 for Windows (WSL Ubuntu 20.04 recommended)
- node v10.19.0 or higher version (v14.17.0 recommended)
- npm v6.14.4 or higher version (v7.10.0 recommended)
- node-gyp v6.1.0 or higher version (v8.0.0 recommended)
If you need to install one (or more) of the components to meet the requirements, open a linux terminal and use the following commands:
- It is recommend to update and upgrage the apt-get. To do so, enter the command "sudo apt-get update" and after it's done, enter "sudo apt-get upgrade -y".
- To install node-js, use the command: "sudo apt-get install nodejs -y".
- To install npm, use the command: "sudo apt-get install npm -y".
- To install node-gyp, use the command: "sudo npm install -g node-gyp".
Note: for node-gyp, it is required to have Python v3.6 (or above) and GCC compiler pre-installed on your system.
- To install python3 use the command: "sudo apt-get install python3.6" (or 3.7 or 3.8 and so on).
- GCC usually pre-installed on Unix-based systems.
- Please make sure your system meet the requirements above.
- Open the terminal in the server's main dictionary the and run the command: "./run.sh". This script will run "npm install" in the relevant diretories to get the required dependencies, and compile C++ part of the program using node-gyp.
- After server's setup is done, you can work in two ways:
Open the browser and connect to the server at "localhost:8080". Then, Fill the form and submit.
Send a POST request to "localhost:8080/detect" with the following data in the body:
- algorithm: "Regression Algorithm" or "Circular Algorithm" or "Hybrid Algorithm".
- new_threshold: a fraction between 0 and 1.
- training_file: a CSV file for system training.
- testing_file: a CSV file for anomaly detection.
After making the POST request, you will get a POST response with a JSON.
If you receive some errors with run.sh file, you can enter the following commands:
- cd ./Model
- npm install
- node-gyp configure
- node-gyp build
- cd ../Controller
- npm install
- node expServer.js