Giter Site home page Giter Site logo

cvjena / libmaxdiv Goto Github PK

View Code? Open in Web Editor NEW
59.0 8.0 12.0 43.23 MB

Implementation of the Maximally Divergent Intervals algorithm for Anomaly Detection in multivariate spatio-temporal time-series.

License: GNU Lesser General Public License v3.0

Python 44.06% C++ 52.47% C 3.19% CMake 0.28%
machine-learning machine-learning-library machinelearning anomalydetection anomalydiscovery time-series timeseries data-mining datamining data-analysis

libmaxdiv's Introduction

Maximally Divergent Intervals for Anomaly Detection

The Maximally Divergent Intervals (MDI) Algorithm can be used to detect anomalous intervals (as opposed to anomalous points) in multi-variate spatio-temporal time-series. A description of the algorithm along with a variety of application examples can be found in the following article:

Detecting Regions of Maximal Divergence for Spatio-Temporal Anomaly Detection.
Björn Barz, Erik Rodner, Yanira Guanche Garcia, Joachim Denzler.
IEEE Transactions on Pattern Analysis and Machine Intelligence, 2018.

An efficient C++ implementation called libmaxdiv is provided in maxdiv/libmaxdiv and may be used stand-alone. If it has been built in maxdiv/libmaxdiv/bin, it will be used automatically by the GUI and the maxdiv function in the maxdiv.maxdiv Python package. See maxdiv/libmaxdiv/README.md for build instructions.
Otherwise, the pure Python implementation of the MDI algorithm will be used, which is not recommended, since it is extremely slow and lacks some features such as support for spatial data.

The directories experiments and tools contain some benchmarks, experiments and scripts we've been using for development and evaluation of the algorithm; for example, detecting severe North Sea storms like the Hamburg-Flut shown below. You don't need those directories if you just want to use libmaxdiv.

Hamburg-Flut

More examples of what can be done with the MDI algorithm can be found on the project page and in the article mentioned above.

GUI

GUI

Dependencies of the Python implementation and the GUI

  • Python >= 2.7 or Python 3
  • numpy
  • matplotlib
  • scipy
  • scikit-learn <= 0.19
  • PIL/Pillow

libmaxdiv has its own dependencies in addition. Please refer to maxdiv/libmaxdiv/README.md for build instructions.

Getting started

After having installed the dependencies mentioned above and built libmaxdiv according to the instructions in maxdiv/libmaxdiv/README.md, just run python launch-gui.py to start the interactive interface.
If you are using Windows, pre-built binaries of the libmaxdiv library are available, so that it can be used out of the box. However, the default launch-gui.py script will always search for self-built libraries only. To use the pre-built ones, launch the GUI by running python win32\launch-gui.py instead.

A comprehensive installation guide and user manual for the GUI can be found in libmaxdiv user guide.pdf.

You may also use the maxdiv algorithm programmatically via the maxdiv function in the maxdiv.maxdiv package or by using the libmaxdiv library directly from your application. It provides a C-style procedural interface defined in libmaxdiv.h for maximum inter-operability.

Note that not all functions of libmaxdiv are made available through the high-level interface maxdiv python function in the maxdiv.maxdiv package. In particular, it can only process temporal, but not spatio-temporal data. However, you can still use python to interact with libmaxdiv by calling the C-style functions defined in libmaxdiv.h from python using the wrapper provided in maxdiv.libmaxdiv_wrapper.

A simple step-by-step example for using the GUI

In this simple example, we will use the graphical user interface (GUI) for detecting hurricanes in a non-spatial time-series comprising measurements of significant wave height (Hs), sea level pressure (SLP), and wind speed (W). The measurements have been taken in 2012 at a location near the Bahamas and are provided by NOAA.

The hurricane season was particularly active in that year and 3 major hurricanes passed the Bahamas: Isaac (August 22-25), Rafael (October 12-18), and Sandy (October 22-29).

We have already converted the data to the correct format for the libmaxdiv GUI and provide it in the file experiments/HPW_2012_41046_standardized.csv.

First, we launch the user interface loading that file directly on start-up by running the following command on the command line:

python launch-gui.py experiments/HPW_2012_41046_standardized.csv

You may also omit the argument and will then be prompted to select the file using a dialog window.

Since the measured variables have very different scales, it is a bit difficult to see anything in the plot of the time-series. Thus, we first check the box labeled "Plot pre-processed instead of original data", which will show a normalized version of the time-series, which is also used by libmaxdiv.

Since hurricanes usually last at least 12 hours and are considered two independent storms if they last longer than 3 days, we set the "minimum interval length" to 12 and the "maximum interval length" to 72. In order to keep the visualization clean and the analysis easy, we set the "number of detections" to 5.

After hitting the "Detect Anomalous Intervals" button, the time-series will be overlayed with the top 5 detections, shown as red regions. The first three detections should correspond to the three hurricanes mentioned above.

You can use the buttons next to the visualization for zooming and panning or navigating between the individual detections.

libmaxdiv's People

Contributors

callidior avatar erodner avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libmaxdiv's Issues

eigen lib not available anymore

Dear Björn,

I would like to try out the libmaxdiv on satellite time-series data. It seems the eigen library is not available anymore. Do you have an alternative link?

Thanks in advance, und grüße nach good old Jena :)
Andreas

Negative outlier scores found when running function "maxdiv_score_intervals(X, params, intervals)"

Hi! Thank you for providing help!

Here's the weird thing I encountered, I'm running the MDI (time only) algorithm on my own data now, and I am trying to compute the corresponding Full Gaussian outlier scores (under both Crossent & Kullback-Leibler criteria) on the same experiment for the outlier intervals obtained on the ID gaussian method. I used the python program of libmaxdiv_wrapper, however I got outlier scores with negative values. I have attached a screenshot of the results. Furthermore, it is worth noticing that only the Cross entropy criterion produces negative values.

Also, I ran the opposite experiment (using the outlier intervals detected by the Full method to calculate the outlier values for the ID method), however, no negative values were generated for both Cross entropy and Kullback-Leibler.

I would like to ask if this means that the equation maxdiv_score_intervals() is wrong? Or am I making a mistake somewhere?

negative_outlier_score

compilation fails with gcc compiler 7.1.0

Using gcc and g++ version 7.1.0 the build is failing.
Relevant part of error message below.
System:
Linux *** 2.6.32-696.18.7.el6.x86_64 *1 SMP *** x86_64 x86_64 x86_64 GNU/Linux
gcc/g++: 7.1.0
cmake: 3.5.2

compiles with deprecation warnings for gcc/g++ version 5.1.0, 6.1.0
No Problem with gcc/g++ version 4.9.2

In file included from HOME/tools/build/libmaxdiv/libmaxdiv-1.0/maxdiv/libmaxdiv/utils.h:30:0,
                 from HOME/tools/build/libmaxdiv/libmaxdiv-1.0/maxdiv/libmaxdiv/utils.cc:18:
HOME/tools/build/libmaxdiv/libmaxdiv-1.0/maxdiv/libmaxdiv/DataTensor.h: In member function ‘void MaxDiv::DataTensor_<Scalar>::crop(const MaxDiv::IndexRange&)’:
HOME/tools/build/libmaxdiv/libmaxdiv-1.0/maxdiv/libmaxdiv/DataTensor.h:560:26: error: no match for ‘operator&&’ (operand types are ‘bool’ and ‘const Eigen::CwiseBinaryOp<Eigen::internal::scalar_cmp_op<long unsigned int, (Eigen::internal::ComparisonName)0>, const Eigen::Block<Eigen::Map<const Eigen::Array<long unsigned int, 5, 1> >, -1, 1, false>, const Eigen::Block<Eigen::Map<Eigen::Array<long unsigned int, 5, 1> >, -1, 1, false> >’)
         if (range.a == 0 && range.b.vec().tail(MAXDIV_INDEX_DIMENSION - 1) == this->m_shape.vec().tail(MAXDIV_INDEX_DIMENSION - 1))
             ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
HOME/tools/build/libmaxdiv/libmaxdiv-1.0/maxdiv/libmaxdiv/DataTensor.h:560:26: note: candidate: operator&&(bool, bool) <built-in>
HOME/tools/build/libmaxdiv/libmaxdiv-1.0/maxdiv/libmaxdiv/DataTensor.h:560:26: note:   no known conversion for argument 2 from ‘const Eigen::CwiseBinaryOp<Eigen::internal::scalar_cmp_op<long unsigned int, (Eigen::internal::ComparisonName)0>, const Eigen::Block<Eigen::Map<const Eigen::Array<long unsigned int, 5, 1> >, -1, 1, false>, const Eigen::Block<Eigen::Map<Eigen::Array<long unsigned int, 5, 1> >, -1, 1, false> >’ to ‘bool’
make[2]: *** [CMakeFiles/maxdiv.dir/utils.cc.o] Error 1
make[1]: *** [CMakeFiles/maxdiv.dir/all] Error 2
make: *** [all] Error 2

libmaxdiv.maxdiv_score_intervals not found

File "F:\PythonJupyterStudy\thesis-master\MDI\libmaxdiv\maxdiv\libmaxdiv_wrapper.py", line 547, in
libmaxdiv, libmaxdiv_path = _search_libmaxdiv()
File "F:\PythonJupyterStudy\thesis-master\MDI\libmaxdiv\maxdiv\libmaxdiv_wrapper.py", line 255, in _search_libmaxdiv
return _LibMaxDiv(lib), fn
File "F:\PythonJupyterStudy\thesis-master\MDI\libmaxdiv\maxdiv\libmaxdiv_wrapper.py", line 192, in init
(1, 'const_data', True), (1, 'custom_missing_value', False), (1, 'missing_value', 0))
File "F:\PythonJupyterStudy\thesis-master\MDI\libmaxdiv\maxdiv\libmaxdiv_wrapper.py", line 206, in _register_func
self.dict[funcName] = prototype((funcName, self._lib), paramflags)
AttributeError: function 'maxdiv_score_intervals' not found

Hi, I'm trying to run the function "maxdiv_score_intervals", the function indeed in the libmaxdiv_wrapper.py, however, it gave such errors. Could you tell me what I missed?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.