All Projects → codesuki → go-time-series

codesuki / go-time-series

Licence: MIT license
Time series implementation in Go

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to go-time-series

Brein Time Utilities
Library which contains several time-dependent data and index structures (e.g., IntervalTree, BucketTimeSeries), as well as algorithms.
Stars: ✭ 94 (+248.15%)
Mutual labels:  data-structure, time-series
CP
Competitive Coding
Stars: ✭ 25 (-7.41%)
Mutual labels:  data-structure
Staticvec
Implements a fixed-capacity stack-allocated Vec alternative backed by an array, using const generics.
Stars: ✭ 236 (+774.07%)
Mutual labels:  data-structure
TSception
PyTorch implementation of TSception
Stars: ✭ 52 (+92.59%)
Mutual labels:  time-series
zestdb
ZestDB
Stars: ✭ 18 (-33.33%)
Mutual labels:  time-series
AI4Water
framework for developing machine (and deep) learning models for structured data
Stars: ✭ 35 (+29.63%)
Mutual labels:  time-series
C Macro Collections
Easy to use, header only, macro generated, generic and type-safe Data Structures in C
Stars: ✭ 192 (+611.11%)
Mutual labels:  data-structure
DataScience ArtificialIntelligence Utils
Examples of Data Science projects and Artificial Intelligence use cases
Stars: ✭ 302 (+1018.52%)
Mutual labels:  time-series
pyRiemann
Python machine learning package based on sklearn API for multivariate data processing and statistical analysis of symmetric positive definite matrices via Riemannian geometry
Stars: ✭ 470 (+1640.74%)
Mutual labels:  time-series
EntityFrameworkCore.AutoFixture
A library aimed to minimize the boilerplate required to unit-test Entity Framework Core code using AutoFixture and in-memory providers.
Stars: ✭ 31 (+14.81%)
Mutual labels:  in-memory
query-selector
LONG-TERM SERIES FORECASTING WITH QUERYSELECTOR – EFFICIENT MODEL OF SPARSEATTENTION
Stars: ✭ 63 (+133.33%)
Mutual labels:  time-series
laravel-quasar
⏰📊✨Laravel Time Series - Provides an API to create and maintain data projections (statistics, aggregates, etc.) from your Eloquent models, and convert them to time series.
Stars: ✭ 78 (+188.89%)
Mutual labels:  time-series
ForestCoverChange
Detecting and Predicting Forest Cover Change in Pakistani Areas Using Remote Sensing Imagery
Stars: ✭ 23 (-14.81%)
Mutual labels:  time-series
Go Patricia
A generic patricia trie (also called radix tree) implemented in Go (Golang)
Stars: ✭ 243 (+800%)
Mutual labels:  data-structure
sktime-tutorial-pydata-amsterdam-2020
Introduction to Machine Learning with Time Series at PyData Festival Amsterdam 2020
Stars: ✭ 115 (+325.93%)
Mutual labels:  time-series
Denormalizr
Denormalize data normalized with normalizr
Stars: ✭ 231 (+755.56%)
Mutual labels:  data-structure
dbnR
Gaussian dynamic Bayesian networks structure learning and inference based on the bnlearn package
Stars: ✭ 33 (+22.22%)
Mutual labels:  time-series
gorilla
An effective time-series data compression/decompression method based on Facebook's Gorilla.
Stars: ✭ 51 (+88.89%)
Mutual labels:  time-series
js-data-structures
🌿 Data structures for JavaScript
Stars: ✭ 56 (+107.41%)
Mutual labels:  data-structure
covid19-time-series-utilities
several utilities to help wrangle COVID-19 data into a time-series format
Stars: ✭ 34 (+25.93%)
Mutual labels:  time-series

go-time-series

License GoDoc Build Status codecov

Time series implementation in Go.

It is used in go-trending as a backend for a trending algorithm. The time series supports storing counts at different granularities, e.g. seconds, minutes, hours, ....
In case of go-trending the time series is configured to have recent data available at small granularity, i.e. the recent 60 seconds, and historical data available at large granularity, i.e. the last few hours, days of data.

A redis backend is planned.

  • Simple interface
  • Store time series data at different granularities
  • Use your own clock implementation, e.g. for testing or similar

Examples

Creating a time series with default settings

The default settings use time.Now() as clock and time.Second * 60, time.Minute * 60 and time.Hour * 24 as granularities.

import "github.com/codesuki/go-time-series"

...

ts, err := timeseries.NewTimeSeries()
if err != nil {
    // handle error
}

Creating a customized time series

You can specify the clock and/or granularities to use. A clock must implement the timeseries.Clock interface.

import "github.com/codesuki/go-time-series"

...
type clock struct {}
func (c *clock) Now() {
    return time.Time{} // always returns the zero time
}
var myClock clock
...

ts, err := timeseries.NewTimeSeries(
    timeseries.WithGranularities(
        []timeseries.Granularity{
            {Granularity: time.Second, Count: 60},
            {Granularity: time.Minute, Count: 60},
            {Granularity: time.Hour, Count: 24},
            {Granularity: time.Hour * 24, Count: 7},
        }),
    timeseries.WithClock(&myClock),
)
if err != nil {
    // handle error
}

Filling the time series

To fill the time series with counts, e.g. events, you can use two different functions.

import "github.com/codesuki/go-time-series"

...

ts, err := timeseries.NewTimeSeries()
if err != nil {
    // handle error
}

ts.Increase(2) // adds 2 to the counter at the current time
ts.IncreaseAtTime(3, time.Now().Add(-2 * time.Minute)) // adds 3 to the counter 2 minutes ago

Querying the time series

The Range() function takes 2 arguments, i.e. the start and end of a time span. Recent() is a small helper function that just uses clock.Now() as end in Range. Please refer to the documentation for how Range() works exactly. There are some details depending on what range you query and what range is available.

import "github.com/codesuki/go-time-series"

...

ts, err := timeseries.NewTimeSeries()
if err != nil {
    // handle error
}

ts.Increase(2) // adds 2 to the counter at the current time
// 1s passes
ts.Increase(3)
// 1s passes

ts.Recent(5 * time.Second) // returns 5

ts.Range(time.Now().Add(-5 * time.Second), time.Now()) // returns 5

Documentation

GoDoc is located here

License

go-time-series is MIT licensed.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].