Lattice

Statistics storage
Download

Lattice Ranking & Summary

Advertisement

  • Rating:
  • License:
  • ISC License
  • Price:
  • FREE
  • Publisher Name:
  • Bertrand Chenal
  • Publisher web site:
  • https://bitbucket.org/bertrandchenal/

Lattice Tags


Lattice Description

Lattice is a Python module designed to receive a flow of data as input and provide live statistics. It works by pre-computing statistics for each combination of possible query. So when a new data point like this is added: :::python {'date': , 'author': Bill", 'nb_words': 523}Eight counters are incremented: :::python ([], None) ([], 'Bill') (, None) (, 'Bill') (, None) (, 'Bill') (, None) (, 'Bill')Each counter is stored in a LevelDB database.ExampleLet's say we want to collect statistics about length of blog posts. we start by creating a Space class: :::python class Post(Space): date = dimension.Tree('Category') author = dimension.Flat('Category') nb_words = measure.Sum('Number')The `load` method allows to store data points: :::python Post.load(, 'author': Bill", 'nb_words': 523}, {'date': , 'author': John", 'nb_words': 148}, ])We can now retrieve data with fetch: :::python Post.fetch('nb_words') # returns 671 Post.fetch('nb_words', author='Bill') # returns 523 Post.fetch('nb_words', author='Bill', date=) # returns 523Or drill the dimensions: :::python Post.date.drill() # yields and Full listing: :::python from lattice import Space, dimension, measure from lattice.common import connect class Post(Space): date = dimension.Tree('Category') author = dimension.Flat('Category') nb_words = measure.Sum('Number') with connect('db/Post'): Post.load(, 'author': "Bill", 'nb_words': 523 }, { 'date': , 'author': "John", 'nb_words': 148 }, ]) print Post.fetch('nb_words') print Post.fetch('nb_words', author='Bill') print Post.fetch('nb_words', author='Bill', date=) print list(Post.date.drill())Product's homepage


Lattice Related Software