Chaotic datasets on pyFTS.data: logistic_map, mackey_glass, henon, lorentz and rossler
This commit is contained in:
parent
9be5c611a7
commit
8fde4c4ea6
4
Docs/.buildinfo
Normal file
4
Docs/.buildinfo
Normal file
@ -0,0 +1,4 @@
|
||||
# Sphinx build info version 1
|
||||
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
|
||||
config: 23a83af8fc84956f406e435cfed523f9
|
||||
tags: 645f666f9bcd5a90fca523b33c5a78b7
|
BIN
Docs/.doctrees/environment.pickle
Normal file
BIN
Docs/.doctrees/environment.pickle
Normal file
Binary file not shown.
BIN
Docs/.doctrees/index.doctree
Normal file
BIN
Docs/.doctrees/index.doctree
Normal file
Binary file not shown.
0
Docs/.nojekyll
Normal file
0
Docs/.nojekyll
Normal file
20
Makefile
Normal file
20
Makefile
Normal file
@ -0,0 +1,20 @@
|
||||
# Minimal makefile for Sphinx documentation
|
||||
#
|
||||
|
||||
# You can set these variables from the command line.
|
||||
SPHINXOPTS =
|
||||
SPHINXBUILD = sphinx-build
|
||||
SPHINXPROJ = pyFTS
|
||||
SOURCEDIR = source
|
||||
BUILDDIR = build
|
||||
|
||||
# Put it first so that "make" without argument is like "make help".
|
||||
help:
|
||||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||
|
||||
.PHONY: help Makefile
|
||||
|
||||
# Catch-all target: route all unknown targets to Sphinx using the new
|
||||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
||||
%: Makefile
|
||||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
36
make.bat
Normal file
36
make.bat
Normal file
@ -0,0 +1,36 @@
|
||||
@ECHO OFF
|
||||
|
||||
pushd %~dp0
|
||||
|
||||
REM Command file for Sphinx documentation
|
||||
|
||||
if "%SPHINXBUILD%" == "" (
|
||||
set SPHINXBUILD=sphinx-build
|
||||
)
|
||||
set SOURCEDIR=source
|
||||
set BUILDDIR=build
|
||||
set SPHINXPROJ=pyFTS
|
||||
|
||||
if "%1" == "" goto help
|
||||
|
||||
%SPHINXBUILD% >NUL 2>NUL
|
||||
if errorlevel 9009 (
|
||||
echo.
|
||||
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
|
||||
echo.installed, then set the SPHINXBUILD environment variable to point
|
||||
echo.to the full path of the 'sphinx-build' executable. Alternatively you
|
||||
echo.may add the Sphinx directory to PATH.
|
||||
echo.
|
||||
echo.If you don't have Sphinx installed, grab it from
|
||||
echo.http://sphinx-doc.org/
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
|
||||
goto end
|
||||
|
||||
:help
|
||||
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
|
||||
|
||||
:end
|
||||
popd
|
4
pyFTS/.directory
Normal file
4
pyFTS/.directory
Normal file
@ -0,0 +1,4 @@
|
||||
[Dolphin]
|
||||
Timestamp=2018,2,27,12,11,58
|
||||
Version=4
|
||||
ViewMode=1
|
174
pyFTS/conf.py
Normal file
174
pyFTS/conf.py
Normal file
@ -0,0 +1,174 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Configuration file for the Sphinx documentation builder.
|
||||
#
|
||||
# This file does only contain a selection of the most common options. For a
|
||||
# full list see the documentation:
|
||||
# http://www.sphinx-doc.org/en/stable/config
|
||||
|
||||
# -- Path setup --------------------------------------------------------------
|
||||
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
#
|
||||
# import os
|
||||
# import sys
|
||||
# sys.path.insert(0, os.path.abspath('.'))
|
||||
|
||||
|
||||
# -- Project information -----------------------------------------------------
|
||||
|
||||
project = 'pyFTS'
|
||||
copyright = '2018, Petrônio Cândido de Lima e Silva'
|
||||
author = 'Petrônio Cândido de Lima e Silva'
|
||||
|
||||
# The short X.Y version
|
||||
version = ''
|
||||
# The full version, including alpha/beta/rc tags
|
||||
release = '1.2.2'
|
||||
|
||||
|
||||
# -- General configuration ---------------------------------------------------
|
||||
|
||||
# If your documentation needs a minimal Sphinx version, state it here.
|
||||
#
|
||||
# needs_sphinx = '1.0'
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be
|
||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||
# ones.
|
||||
extensions = [
|
||||
'sphinx.ext.autodoc',
|
||||
'sphinx.ext.intersphinx',
|
||||
'sphinx.ext.todo',
|
||||
'sphinx.ext.mathjax',
|
||||
'sphinx.ext.viewcode',
|
||||
'sphinx.ext.githubpages',
|
||||
]
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['.templates']
|
||||
|
||||
# The suffix(es) of source filenames.
|
||||
# You can specify multiple suffix as a list of string:
|
||||
#
|
||||
# source_suffix = ['.rst', '.md']
|
||||
source_suffix = '.rst'
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'index'
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
#
|
||||
# This is also used if you do content translation via gettext catalogs.
|
||||
# Usually you set "language" from the command line for these cases.
|
||||
language = None
|
||||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
# This pattern also affects html_static_path and html_extra_path .
|
||||
exclude_patterns = []
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = 'sphinx'
|
||||
|
||||
|
||||
# -- Options for HTML output -------------------------------------------------
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
#
|
||||
html_theme = 'alabaster'
|
||||
|
||||
# Theme options are theme-specific and customize the look and feel of a theme
|
||||
# further. For a list of options available for each theme, see the
|
||||
# documentation.
|
||||
#
|
||||
# html_theme_options = {}
|
||||
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
html_static_path = ['.static']
|
||||
|
||||
# Custom sidebar templates, must be a dictionary that maps document names
|
||||
# to template names.
|
||||
#
|
||||
# The default sidebars (for documents that don't match any pattern) are
|
||||
# defined by theme itself. Builtin themes are using these templates by
|
||||
# default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
|
||||
# 'searchbox.html']``.
|
||||
#
|
||||
# html_sidebars = {}
|
||||
|
||||
|
||||
# -- Options for HTMLHelp output ---------------------------------------------
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = 'pyFTSdoc'
|
||||
|
||||
|
||||
# -- Options for LaTeX output ------------------------------------------------
|
||||
|
||||
latex_elements = {
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
#
|
||||
# 'papersize': 'letterpaper',
|
||||
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#
|
||||
# 'pointsize': '10pt',
|
||||
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#
|
||||
# 'preamble': '',
|
||||
|
||||
# Latex figure (float) alignment
|
||||
#
|
||||
# 'figure_align': 'htbp',
|
||||
}
|
||||
|
||||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title,
|
||||
# author, documentclass [howto, manual, or own class]).
|
||||
latex_documents = [
|
||||
(master_doc, 'pyFTS.tex', 'pyFTS Documentation',
|
||||
'Petrônio Cândido de Lima e Silva', 'manual'),
|
||||
]
|
||||
|
||||
|
||||
# -- Options for manual page output ------------------------------------------
|
||||
|
||||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
(master_doc, 'pyfts', 'pyFTS Documentation',
|
||||
[author], 1)
|
||||
]
|
||||
|
||||
|
||||
# -- Options for Texinfo output ----------------------------------------------
|
||||
|
||||
# Grouping the document tree into Texinfo files. List of tuples
|
||||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
(master_doc, 'pyFTS', 'pyFTS Documentation',
|
||||
author, 'pyFTS', 'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
]
|
||||
|
||||
|
||||
# -- Extension configuration -------------------------------------------------
|
||||
|
||||
# -- Options for intersphinx extension ---------------------------------------
|
||||
|
||||
# Example configuration for intersphinx: refer to the Python standard library.
|
||||
intersphinx_mapping = {'https://docs.python.org/': None}
|
||||
|
||||
# -- Options for todo extension ----------------------------------------------
|
||||
|
||||
# If true, `todo` and `todoList` produce output, else they produce nothing.
|
||||
todo_include_todos = True
|
6
pyFTS/data/.directory
Normal file
6
pyFTS/data/.directory
Normal file
@ -0,0 +1,6 @@
|
||||
[Dolphin]
|
||||
SortOrder=1
|
||||
SortRole=size
|
||||
Timestamp=2018,3,2,14,0,24
|
||||
Version=4
|
||||
ViewMode=1
|
30
pyFTS/data/henon.py
Normal file
30
pyFTS/data/henon.py
Normal file
@ -0,0 +1,30 @@
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
|
||||
|
||||
def get_data(var, a=1.4, b=0.3, initial_values = [1, 1], iterations=1000):
|
||||
return get_dataframe(a,b, initial_values, iterations)[var].values
|
||||
|
||||
|
||||
def get_dataframe(a=1.4, b=0.3, initial_values = [1, 1], iterations=1000):
|
||||
'''
|
||||
M. Hénon. "A two-dimensional mapping with a strange attractor". Commun. Math. Phys. 50, 69-77 (1976)
|
||||
|
||||
dx/dt = a + by(t-1) - x(t-1)^2
|
||||
dy/dt = x
|
||||
|
||||
:param a: Equation coefficient
|
||||
:param b: Equation coefficient
|
||||
:param initial_values: numpy array with the initial values of x and y. Default: [1, 1]
|
||||
:param iterations: number of iterations. Default: 1000
|
||||
:return: Panda dataframe with the x and y values
|
||||
'''
|
||||
|
||||
x = [initial_values[0]]
|
||||
y = [initial_values[1]]
|
||||
for t in np.arange(0, iterations):
|
||||
xx = a + b * y[t] - x[t] ** 2
|
||||
y.append(x[t])
|
||||
x.append(xx)
|
||||
|
||||
return pd.DataFrame({'x': x, 'y':y})
|
22
pyFTS/data/logistic_map.py
Normal file
22
pyFTS/data/logistic_map.py
Normal file
@ -0,0 +1,22 @@
|
||||
#
|
||||
|
||||
import numpy as np
|
||||
|
||||
|
||||
def get_data(r = 4, initial_value = 0.3, iterations=100):
|
||||
'''
|
||||
May, Robert M. (1976). "Simple mathematical models with very complicated dynamics".
|
||||
Nature. 261 (5560): 459–467. doi:10.1038/261459a0.
|
||||
|
||||
x(t) = r * x(t-1) * (1 - x(t -1) )
|
||||
|
||||
:param r: Equation coefficient
|
||||
:param initial_value: Initial value of x. Default: 0.3
|
||||
:param iterations: number of iterations. Default: 100
|
||||
:return:
|
||||
'''
|
||||
x = [initial_value]
|
||||
for t in np.arange(0,iterations):
|
||||
x.append(r * x[t]*(1 - x[t]))
|
||||
|
||||
return x
|
41
pyFTS/data/lorentz.py
Normal file
41
pyFTS/data/lorentz.py
Normal file
@ -0,0 +1,41 @@
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
|
||||
|
||||
def get_data(var, a = 10.0, b = 28.0, c = 8.0 / 3.0, dt = 0.01,
|
||||
initial_values = [0.1, 0, 0], iterations=1000):
|
||||
return get_dataframe(a, b, c, dt, initial_values, iterations)[var].values
|
||||
|
||||
|
||||
def get_dataframe(a = 10.0, b = 28.0, c = 8.0 / 3.0, dt = 0.01,
|
||||
initial_values = [0.1, 0, 0], iterations=1000):
|
||||
'''
|
||||
Lorenz, Edward Norton (1963). "Deterministic nonperiodic flow". Journal of the Atmospheric Sciences. 20 (2): 130–141.
|
||||
https://doi.org/10.1175/1520-0469(1963)020<0130:DNF>2.0.CO;2
|
||||
|
||||
dx/dt = a(y -x)
|
||||
dy/dt = x(b - z) - y
|
||||
dz/dt = xy - cz
|
||||
|
||||
:param a: Equation coefficient. Default value: 10
|
||||
:param b: Equation coefficient. Default value: 28
|
||||
:param c: Equation coefficient. Default value: 8.0/3.0
|
||||
:param dt: Time differential for continuous time integration. Default value: 0.01
|
||||
:param initial_values: numpy array with the initial values of x,y and z. Default: [0.1, 0, 0]
|
||||
:param iterations: number of iterations. Default: 1000
|
||||
:return: Panda dataframe with the x, y and z values
|
||||
'''
|
||||
|
||||
x = [initial_values[0]]
|
||||
y = [initial_values[1]]
|
||||
z = [initial_values[2]]
|
||||
|
||||
for t in np.arange(0, iterations):
|
||||
dxdt = a * (y[t] - x[t])
|
||||
dydt = x[t] * (b - z[t]) - y[t]
|
||||
dzdt = x[t] * y[t] - c * z[t]
|
||||
x.append(x[t] + dt * dxdt)
|
||||
y.append(y[t] + dt * dydt)
|
||||
z.append(z[t] + dt * dzdt)
|
||||
|
||||
return pd.DataFrame({'x': x, 'y':y, 'z': z})
|
23
pyFTS/data/mackey_glass.py
Normal file
23
pyFTS/data/mackey_glass.py
Normal file
@ -0,0 +1,23 @@
|
||||
import numpy as np
|
||||
|
||||
|
||||
def get_data(b=0.1, c=0.2, tau=17, initial_values = np.linspace(0.5,1.5,18), iterations=1000):
|
||||
'''
|
||||
Mackey, M. C. and Glass, L. (1977). Oscillation and chaos in physiological control systems.
|
||||
Science, 197(4300):287-289.
|
||||
|
||||
dy/dt = -by(t)+ cy(t - tau) / 1+y(t-tau)^10
|
||||
|
||||
:param b: Equation coefficient
|
||||
:param c: Equation coefficient
|
||||
:param tau: Lag parameter, default: 17
|
||||
:param initial_values: numpy array with the initial values of y. Default: np.linspace(0.5,1.5,18)
|
||||
:param iterations: number of iterations. Default: 1000
|
||||
:return:
|
||||
'''
|
||||
y = initial_values.tolist()
|
||||
|
||||
for n in np.arange(len(y), iterations+100):
|
||||
y.append(y[n] - b * y[n] + c * y[n - tau] / (1 + y[n - tau] ** 10))
|
||||
|
||||
return y[100:]
|
40
pyFTS/data/rossler.py
Normal file
40
pyFTS/data/rossler.py
Normal file
@ -0,0 +1,40 @@
|
||||
import numpy as np
|
||||
import pandas as pd
|
||||
|
||||
|
||||
def get_data(var, a = 0.2, b = 0.2, c = 5.7, dt = 0.01,
|
||||
initial_values = [0.001, 0.001, 0.001], iterations=5000):
|
||||
return get_dataframe(a, b, c, dt, initial_values, iterations)[var].values
|
||||
|
||||
|
||||
def get_dataframe(a = 0.2, b = 0.2, c = 5.7, dt = 0.01,
|
||||
initial_values = [0.001, 0.001, 0.001], iterations=5000):
|
||||
'''
|
||||
O. E. Rössler, Phys. Lett. 57A, 397 (1976).
|
||||
|
||||
dx/dt = -z - y
|
||||
dy/dt = x + ay
|
||||
dz/dt = b + z( x - c )
|
||||
|
||||
:param a: Equation coefficient. Default value: 0.2
|
||||
:param b: Equation coefficient. Default value: 0.2
|
||||
:param c: Equation coefficient. Default value: 5.7
|
||||
:param dt: Time differential for continuous time integration. Default value: 0.01
|
||||
:param initial_values: numpy array with the initial values of x,y and z. Default: [0.001, 0.001, 0.001]
|
||||
:param iterations: number of iterations. Default: 5000
|
||||
:return: Panda dataframe with the x, y and z values
|
||||
'''
|
||||
|
||||
x = [initial_values[0]]
|
||||
y = [initial_values[1]]
|
||||
z = [initial_values[2]]
|
||||
|
||||
for t in np.arange(0, iterations):
|
||||
dxdt = - (y[t] + z[t])
|
||||
dydt = x[t] + a * y[t]
|
||||
dzdt = b + z[t] * x[t] - z[t] * c
|
||||
x.append(x[t] + dt * dxdt)
|
||||
y.append(y[t] + dt * dydt)
|
||||
z.append(z[t] + dt * dzdt)
|
||||
|
||||
return pd.DataFrame({'x': x, 'y':y, 'z': z})
|
20
pyFTS/index.rst
Normal file
20
pyFTS/index.rst
Normal file
@ -0,0 +1,20 @@
|
||||
.. pyFTS documentation master file, created by
|
||||
sphinx-quickstart on Thu Apr 12 17:13:04 2018.
|
||||
You can adapt this file completely to your liking, but it should at least
|
||||
contain the root `toctree` directive.
|
||||
|
||||
Welcome to pyFTS's documentation!
|
||||
=================================
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
:caption: Contents:
|
||||
|
||||
|
||||
|
||||
Indices and tables
|
||||
==================
|
||||
|
||||
* :ref:`genindex`
|
||||
* :ref:`modindex`
|
||||
* :ref:`search`
|
@ -53,6 +53,7 @@ partitions = {'CMIV': {'BoxCox(0)': 36, 'Differential(1)': 11, 'None': 8},
|
||||
|
||||
|
||||
tag = 'benchmarks'
|
||||
|
||||
'''
|
||||
for ds in datasets.keys():
|
||||
dataset = datasets[ds]
|
||||
@ -62,11 +63,11 @@ for ds in datasets.keys():
|
||||
|
||||
partitioning = partitions[ds][tf]
|
||||
|
||||
bchmk.sliding_window_benchmarks(dataset, 2000, train=0.2, inc=0.2,
|
||||
methods=[
|
||||
hwang.HighOrderFTS,
|
||||
hofts.HighOrderFTS,
|
||||
pwfts.ProbabilisticWeightedFTS],
|
||||
bchmk.sliding_window_benchmarks(dataset, 3000, train=0.1, inc=0.1,
|
||||
#methods=[
|
||||
# hwang.HighOrderFTS,
|
||||
# hofts.HighOrderFTS,
|
||||
# pwfts.ProbabilisticWeightedFTS],
|
||||
#orders = [3],
|
||||
benchmark_models=False,
|
||||
transformations=[transformation],
|
||||
@ -86,7 +87,9 @@ for ds in datasets.keys():
|
||||
train = dataset[:train_split]
|
||||
test = dataset[train_split:test_split]
|
||||
|
||||
fs = nspart.simplenonstationary_gridpartitioner_builder(data=train, npart=partitions[ds][tf], transformation=transformation)
|
||||
fs = nspart.simplenonstationary_gridpartitioner_builder(data=train,
|
||||
npart=partitions[ds][tf],
|
||||
transformation=transformation)
|
||||
print(fs)
|
||||
#cvfts1 = cvfts.ConditionalVarianceFTS(partitioner=fs)
|
||||
model = nsfts.NonStationaryFTS(partitioner=fs)
|
||||
@ -94,9 +97,9 @@ for ds in datasets.keys():
|
||||
print(model)
|
||||
|
||||
forecasts = model.predict(test)
|
||||
'''
|
||||
#print(forecasts)
|
||||
|
||||
#print(forecasts)
|
||||
'''
|
||||
partitioning = partitions[ds][tf]
|
||||
|
||||
bchmk.sliding_window_benchmarks(dataset, 2000, train=0.2, inc=0.2,
|
||||
|
Loading…
Reference in New Issue
Block a user