Coder Social home page Coder Social logo

andy-wagner / space-saving Goto Github PK

View Code? Open in Web Editor NEW

This project forked from fzakaria/space-saving

0.0 1.0 0.0 16 KB

Space Saving algorithm implementation (StreamSummary) in Java, used to solve heavy hitters / topk items.

License: MIT License

Java 100.00%

space-saving's Introduction

SpaceSaving

Space Saving algorithm implementation in Java, also know as "HeavyHitter"

The purpose of the algorithm is to find the most frequently used items from an infinite stream. In other words, even if you have millions of different values, the algorithm will try to find the most frequently used within some acceptable error bound.

The datastructure used is described by the paper Efficient Computation of Frequent and Top-k Elements in Data Streams by Ahmed Metwally, Divyakant Agrawal, and Amr El Abbadi

It is a a ϴ(1) "constant time" insert and ϴ(k) lookup for the topk entries.

/**
 An epsilon of 0.001 will create 1000 counters and dictates the accuracy of the elements in the
 resulting topk based on the size of the stream.
 If your stream is 1,000,000 items an item is truly guarenteed to be in the top K elements if
 the frequency reported - error reported > 1000 [0.001 * 1,000,000 = 1000]
 Since top k only cares with skewed data, we generally care for elements in the stream that probably
 have way more than 1000 entries in the stream.
**/
final double epsilon = 0.001;
StreamSummary<String> streamSummary = new StreamSummary<>(0.01);
streamSummary.offer(item);

Aside

This repository is created because although other implementations existed, I was frustrated that they did not include any unit tests or thorough documentation explaining some of the error bounds.

space-saving's People

Watchers

 avatar

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.