GithubHelp home page GithubHelp logo

isabella232 / countish Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rudderlabs/countish

0.0 0.0 0.0 7 KB

Lossy Counting and Sticky Sampling

License: BSD 3-Clause "New" or "Revised" License

Go 100.00%

countish's Introduction

Approximate frequency counts over data streams for Go

Countish implements two approximate counting algorithms outlined in “Approximate Frequency Counts over Data Streams”.

http://www.vldb.org/conf/2002/S10P03.pdf

Use cases

Have you ever needed to do something like calculate the top URLs or top ips from an infinite stream? This package provides probabalistic frequency counters, with accuracy guarantees and low memory usage.

countish provides an extremely simple interface consisting of an “Observe” method and a “ItemsAboveThreshold” method.

Example:

cat urls.txt | go run ./cmd/countish/main.go -threshold .3
0.428671 /

3 counting implementations are provided.

  1. Naive: exact counts are held in a map
  2. Lossy: corresponding to “lossy counting”
  3. Sticky: corresponding to “sticky sampling”

Example:

counter := countish.NewLossyCounter(.01, .01)
for i:=0;i<100;i++ {
    counter.Observe("value")
}
counter.Observe("another value")
// print all items which *might* occur more than 90% of the time,
// along with their estimated frequency
entries := counter.ItemsAboveThreshold(.9)
fmt.Println(entries)
[{value 1.00009900990099}]

examples showing memory usage comparisons

countish's People

Contributors

shanemhansen 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.