GithubHelp home page GithubHelp logo

timesynth / timesynth Goto Github PK

View Code? Open in Web Editor NEW
326.0 19.0 62.0 2.94 MB

A Multipurpose Library for Synthetic Time Series Generation in Python

License: MIT License

Python 3.32% Jupyter Notebook 96.68%
timeseries generator series python time-series python3

timesynth's Introduction

Build Status codecov

TimeSynth

Multipurpose Library for Synthetic Time Series

Please cite as:
J. R. Maat, A. Malali, and P. Protopapas, “TimeSynth: A Multipurpose Library for Synthetic Time Series in Python,” 2017. [Online]. Available: http://github.com/TimeSynth/TimeSynth

TimeSynth is an open source library for generating synthetic time series for model testing. The library can generate regular and irregular time series. The architecture allows the user to match different signals with different architectures allowing a vast array of signals to be generated. The available signals and noise types are listed below.

N.B. We only support Python 3.6+ at this time.

Signal Types

  • Harmonic functions(sin, cos or custom functions)
  • Gaussian processes with different kernels
    • Constant
    • Squared exponential
    • Exponential
    • Rational quadratic
    • Linear
    • Matern
    • Periodic
  • Pseudoperiodic signals
  • Autoregressive(p) process
  • Continuous autoregressive process (CAR)
  • Nonlinear Autoregressive Moving Average model (NARMA)

Noise Types

  • White noise
  • Red noise

Installation

To install the package via github,

git clone https://github.com/TimeSynth/TimeSynth.git
cd TimeSynth
python setup.py install

Using TimeSynth

$ python

The code snippet demonstrates creating a irregular sinusoidal signal with white noise.

>>> import timesynth as ts
>>> # Initializing TimeSampler
>>> time_sampler = ts.TimeSampler(stop_time=20)
>>> # Sampling irregular time samples
>>> irregular_time_samples = time_sampler.sample_irregular_time(num_points=500, keep_percentage=50)
>>> # Initializing Sinusoidal signal
>>> sinusoid = ts.signals.Sinusoidal(frequency=0.25)
>>> # Initializing Gaussian noise
>>> white_noise = ts.noise.GaussianNoise(std=0.3)
>>> # Initializing TimeSeries class with the signal and noise objects
>>> timeseries = ts.TimeSeries(sinusoid, noise_generator=white_noise)
>>> # Sampling using the irregular time samples
>>> samples, signals, errors = timeseries.sample(irregular_time_samples)

timesynth's People

Contributors

1kastner avatar 1reinier avatar abhishekmalali avatar alkasm avatar ricpruss avatar swight-prc 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  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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

timesynth's Issues

import ts raises ModuleNotFoundError: No module named 'symengine'

import timesynth as ts
Traceback (most recent call last):
File "", line 1, in
File "/Users/sumitra/work/TimeSynth/timesynth/init.py", line 2, in
from . import signals
File "/Users/sumitra/work/TimeSynth/timesynth/signals/init.py", line 5, in
[_basename(f)[:-3] for f in _glob.glob(_dirname(file) + "/*.py")
File "", line 4, in
File "/Users/sumitra/work/TimeSynth/timesynth/signals/dde.py", line 6, in
from jitcdde import y, t, jitcdde
File "/Users/sumitra/work/scheduling/venv/lib/python3.7/site-packages/jitcdde-1.3.1-py3.7.egg/jitcdde/init.py", line 1, in
File "/Users/sumitra/work/scheduling/venv/lib/python3.7/site-packages/jitcdde-1.3.1-py3.7.egg/jitcdde/_jitcdde.py", line 6, in
ModuleNotFoundError: No module named 'symengine'

Error installing through pip

This is the error log:

Collecting timesynth
  Downloading https://files.pythonhosted.org/packages/90/10/db1a380cbff37963d775e4104d3566c956ea4726f5f51dc6bc3f6b693f01/timesynth-0.2.3.tar.gz
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-rbmeb8l4/timesynth/setup.py'"'"'; __file__='"'"'/tmp/pip-install-rbmeb8l4/timesynth/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-rbmeb8l4/timesynth/pip-egg-info
         cwd: /tmp/pip-install-rbmeb8l4/timesynth/
    Complete output (5 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-rbmeb8l4/timesynth/setup.py", line 9, in <module>
        with open('requirements.txt') as f:
    FileNotFoundError: [Errno 2] No such file or directory: 'requirements.txt'
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

symengine==0.4.0 forestalls Python 3.8 usage

Is there something about symengine>0.4.0 that breaks TimeSynth? Because this requirement keeps your library from being used in Python 3.8

I like your library, but I don't want to stay stuck in 3.7 if I can avoid it.

time_sampler = ts.TimeSampler(stop_time=20)

From the example:

import TimeSynth as ts
time_sampler = ts.TimeSampler(stop_time=20)

gives error:
AttributeError: module 'TimeSynth' has no attribute 'TimeSampler'

instead it should be:

import TimeSynth.timesynth as ts
from TimeSynth.timesynth import timesampler
time_sampler = ts.TimeSampler(stop_time=20)

The above works. Just need one level down.
Yep, this is on Python 3.6

Error installing TimeSynth through Pip

Hi everyone,

I've been trying to install TimeSynth through pip and been receiving the following Error:

PS C:\Users\Nikolas> python -m pip install timesynth
Collecting timesynth
  Using cached timesynth-0.2.4-py3-none-any.whl (15 kB)
Requirement already satisfied: scipy in c:\users\nikolas\appdata\local\programs\python\python38\lib\site-packages (from timesynth) (1.4.1)
Processing c:\users\nikolas\appdata\local\pip\cache\wheels\c1\58\70\ae51394acc9757707a51cb500efed79554e672e05d0d757199\jitcdde-1.4.0-py3-none-any.whl
Requirement already satisfied: sympy in c:\users\nikolas\appdata\local\programs\python\python38\lib\site-packages (from timesynth) (1.6)
Collecting symengine==0.4
  Using cached symengine-0.4.0.tar.gz (86 kB)
Processing c:\users\nikolas\appdata\local\pip\cache\wheels\50\f6\d4\41c32b94ad836f824750f548f722e9480e5cc214e9e86700b9\jitcxde_common-1.4.1-py3-none-any.whl
Requirement already satisfied: numpy in c:\users\nikolas\appdata\local\programs\python\python38\lib\site-packages (from timesynth) (1.18.4)
Requirement already satisfied: mpmath>=0.19 in c:\users\nikolas\appdata\local\programs\python\python38\lib\site-packages (from sympy->timesynth) (1.1.0)
Requirement already satisfied: setuptools in c:\users\nikolas\appdata\local\programs\python\python38\lib\site-packages (from jitcxde-common==1.4.1->timesynth) (41.2.0)
Requirement already satisfied: jinja2 in c:\users\nikolas\appdata\local\programs\python\python38\lib\site-packages (from jitcxde-common==1.4.1->timesynth) (2.11.2)
Requirement already satisfied: MarkupSafe>=0.23 in c:\users\nikolas\appdata\local\programs\python\python38\lib\site-packages (from jinja2->jitcxde-common==1.4.1->timesynth) (1.1.1)
Building wheels for collected packages: symengine
  Building wheel for symengine (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: 'C:\Users\Nikolas\AppData\Local\Programs\Python\Python38\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Nikolas\\AppData\\Local\\Temp\\pip-install-j175yn1z\\symengine\\setup.py'"'"'; __file__='"'"'C:\\Users\\Nikolas\\AppData\\Local\\Temp\\pip-install-j175yn1z\\symengine\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\Nikolas\AppData\Local\Temp\pip-wheel-27wtbhe6'
       cwd: C:\Users\Nikolas\AppData\Local\Temp\pip-install-j175yn1z\symengine\
  Complete output (4 lines):
  running bdist_wheel
  running build
  running build_ext
  error: [WinError 2] Das System kann die angegebene Datei nicht finden
  ----------------------------------------
  ERROR: Failed building wheel for symengine
  Running setup.py clean for symengine
Failed to build symengine
Installing collected packages: symengine, jitcxde-common, jitcdde, timesynth
    Running setup.py install for symengine ... error
    ERROR: Command errored out with exit status 1:
     command: 'C:\Users\Nikolas\AppData\Local\Programs\Python\Python38\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Nikolas\\AppData\\Local\\Temp\\pip-install-j175yn1z\\symengine\\setup.py'"'"'; __file__='"'"'C:\\Users\\Nikolas\\AppData\\Local\\Temp\\pip-install-j175yn1z\\symengine\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\Nikolas\AppData\Local\Temp\pip-record-dv3kb977\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\Nikolas\AppData\Local\Programs\Python\Python38\Include\symengine'
         cwd: C:\Users\Nikolas\AppData\Local\Temp\pip-install-j175yn1z\symengine\
    Complete output (4 lines):
    running install
    running build
    running build_ext
    error: [WinError 2] Das System kann die angegebene Datei nicht finden
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Users\Nikolas\AppData\Local\Programs\Python\Python38\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Nikolas\\AppData\\Local\\Temp\\pip-install-j175yn1z\\symengine\\setup.py'"'"'; __file__='"'"'C:\\Users\\Nikolas\\AppData\\Local\\Temp\\pip-install-j175yn1z\\symengine\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\Nikolas\AppData\Local\Temp\pip-record-dv3kb977\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\Nikolas\AppData\Local\Programs\Python\Python38\Include\symengine' Check the logs for full command output.

(FYI: "Das System kann die angegebene Datei nicht finden" = System can't find the file specified)

I also tried installing each package required seperately. The problem seems to lie within the installation of the symengine-package. Eventhough installing it seperately using python -m pip install symengine seems to work just fine I'm still getting the following error afterwards when trying to install timesynth again:

PS C:\Users\Nikolas> python -m pip install symengine
Collecting symengine
  Using cached symengine-0.6.1-cp38-cp38-win_amd64.whl (10.0 MB)
Installing collected packages: symengine
Successfully installed symengine-0.6.1
PS C:\Users\Nikolas> python -m pip install timesynth
Collecting timesynth
  Using cached timesynth-0.2.4-py3-none-any.whl (15 kB)
Requirement already satisfied: numpy in c:\users\nikolas\appdata\local\programs\python\python38\lib\site-packages (from timesynth) (1.18.4)
Requirement already satisfied: sympy in c:\users\nikolas\appdata\local\programs\python\python38\lib\site-packages (from timesynth) (1.6)
Processing c:\users\nikolas\appdata\local\pip\cache\wheels\c1\58\70\ae51394acc9757707a51cb500efed79554e672e05d0d757199\jitcdde-1.4.0-py3-none-any.whl
Requirement already satisfied: scipy in c:\users\nikolas\appdata\local\programs\python\python38\lib\site-packages (from timesynth) (1.4.1)
Processing c:\users\nikolas\appdata\local\pip\cache\wheels\50\f6\d4\41c32b94ad836f824750f548f722e9480e5cc214e9e86700b9\jitcxde_common-1.4.1-py3-none-any.whl
Collecting symengine==0.4
  Using cached symengine-0.4.0.tar.gz (86 kB)
Requirement already satisfied: mpmath>=0.19 in c:\users\nikolas\appdata\local\programs\python\python38\lib\site-packages (from sympy->timesynth) (1.1.0)
Requirement already satisfied: jinja2 in c:\users\nikolas\appdata\local\programs\python\python38\lib\site-packages (from jitcxde-common==1.4.1->timesynth) (2.11.2)
Requirement already satisfied: setuptools in c:\users\nikolas\appdata\local\programs\python\python38\lib\site-packages (from jitcxde-common==1.4.1->timesynth) (41.2.0)
Requirement already satisfied: MarkupSafe>=0.23 in c:\users\nikolas\appdata\local\programs\python\python38\lib\site-packages (from jinja2->jitcxde-common==1.4.1->timesynth) (1.1.1)
Building wheels for collected packages: symengine
  Building wheel for symengine (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: 'C:\Users\Nikolas\AppData\Local\Programs\Python\Python38\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Nikolas\\AppData\\Local\\Temp\\pip-install-e44hvbbs\\symengine\\setup.py'"'"'; __file__='"'"'C:\\Users\\Nikolas\\AppData\\Local\\Temp\\pip-install-e44hvbbs\\symengine\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d 'C:\Users\Nikolas\AppData\Local\Temp\pip-wheel-fga4zb0o'
       cwd: C:\Users\Nikolas\AppData\Local\Temp\pip-install-e44hvbbs\symengine\
  Complete output (4 lines):
  running bdist_wheel
  running build
  running build_ext
  error: [WinError 2] Das System kann die angegebene Datei nicht finden
  ----------------------------------------
  ERROR: Failed building wheel for symengine
  Running setup.py clean for symengine
Failed to build symengine
Installing collected packages: symengine, jitcxde-common, jitcdde, timesynth
  Attempting uninstall: symengine
    Found existing installation: symengine 0.6.1
    Uninstalling symengine-0.6.1:
      Successfully uninstalled symengine-0.6.1
    Running setup.py install for symengine ... error
    ERROR: Command errored out with exit status 1:
     command: 'C:\Users\Nikolas\AppData\Local\Programs\Python\Python38\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Nikolas\\AppData\\Local\\Temp\\pip-install-e44hvbbs\\symengine\\setup.py'"'"'; __file__='"'"'C:\\Users\\Nikolas\\AppData\\Local\\Temp\\pip-install-e44hvbbs\\symengine\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\Nikolas\AppData\Local\Temp\pip-record-_x2a1o68\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\Nikolas\AppData\Local\Programs\Python\Python38\Include\symengine'
         cwd: C:\Users\Nikolas\AppData\Local\Temp\pip-install-e44hvbbs\symengine\
    Complete output (4 lines):
    running install
    running build
    running build_ext
    error: [WinError 2] Das System kann die angegebene Datei nicht finden
    ----------------------------------------
  Rolling back uninstall of symengine
  Moving to c:\users\nikolas\appdata\local\programs\python\python38\lib\site-packages\symengine-0.6.1.dist-info\
   from C:\Users\Nikolas\AppData\Local\Programs\Python\Python38\Lib\site-packages\~ymengine-0.6.1.dist-info
  Moving to c:\users\nikolas\appdata\local\programs\python\python38\lib\site-packages\symengine\
   from C:\Users\Nikolas\AppData\Local\Programs\Python\Python38\Lib\site-packages\~ymengine
ERROR: Command errored out with exit status 1: 'C:\Users\Nikolas\AppData\Local\Programs\Python\Python38\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Nikolas\\AppData\\Local\\Temp\\pip-install-e44hvbbs\\symengine\\setup.py'"'"'; __file__='"'"'C:\\Users\\Nikolas\\AppData\\Local\\Temp\\pip-install-e44hvbbs\\symengine\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\Nikolas\AppData\Local\Temp\pip-record-_x2a1o68\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\Nikolas\AppData\Local\Programs\Python\Python38\Include\symengine' Check the logs for full command output.

My OS is Win10 (64-Bit)
My Python Version is 3.8.3 (64-Bit)

Thanks in advance!

Generating ARIMA series with TimeSynth

I would like to be able to generate ARIMA series (i.e. with differencing as well as AR and MA components), is this possible using TimeSynth? I'm looking at the NARMA function, but I can't work out if I can specify differences, or if I can have different orders for AR and MA? If there is any existing documentation that answers these questions please direct me to it.
Thanks very much.

Streaming time series data using python generator

Is there any way to generate time series data as a stream manner? Instead of generating all the time series data at once is there a way to generate readings on demand using python generator object?

AR Model Sample fails

import timesynth as ts

Initializing TimeSampler

time_sampler = ts.TimeSampler(stop_time=20)

Sampling regular time samples

regular_time_samples = time_sampler.sample_regular_time(num_points=500)

Initializing AR(2) model
ar_p = ts.signals.AutoRegressive(ar_param=[1.5, -0.75])
ar_p_series = ts.TimeSeries(signal_generator=ar_p)
samples = ar_p_series.sample(regular_time_samples)

Fails with error
Traceback (most recent call last):
File "", line 1, in
File "/home/bill/mambaforge/envs/nn/lib/python3.11/site-packages/timesynth/timeseries.py", line 63, in sample
signal = self.signal_generator.sample_next(t, samples[:i - 1], errors[:i - 1])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/bill/mambaforge/envs/nn/lib/python3.11/site-packages/timesynth/signals/ar.py", line 54, in sample_next
ar_value = np.sum(ar_value) + noise
^^^^^^^^^^^^^^^^
File "<array_function internals>", line 200, in sum
File "/home/bill/mambaforge/envs/nn/lib/python3.11/site-packages/numpy/core/fromnumeric.py", line 2324, in sum
return _wrapreduction(a, np.add, 'sum', axis, dtype, out, keepdims=keepdims,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/bill/mambaforge/envs/nn/lib/python3.11/site-packages/numpy/core/fromnumeric.py", line 86, in _wrapreduction
return ufunc.reduce(obj, axis, dtype, out, **passkwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (2,) + inhomogeneous part.

Running with Python 3.11.3

Example AR model uses irregular instead of regular time samples

In the example IPython notebook TimeSynthExamples.ipynb, the 24th cell has this example code for an AR model:

# Initializing TimeSampler
time_sampler = ts.TimeSampler(stop_time=20)
# Sampling regular time samples
regular_time_samples = time_sampler.sample_irregular_time(num_points=500)

Though it should be regular time samples, i.e., using the sample_regular_time() method from timesampler.py.

Using an own timeseries

Hi,

I've got my own timeseries to which I want to add noise using the noise generator.
Is there a way to integrate my own timeseries as if it was generated by the package?
Within "timeseries.py", I've already circumvented the need for vectorization (which gave an attribute error) by ignoring the if and elif statements.

However, when running, it says that my dataframe has no attribute "sample_next". I understand why this is, but I was wondering if there is an easy way to do something like "sample_next" without using that specific function. If that is achieved, everything should work.

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.