Compare commits
2 Commits
master
...
feature/so
Author | SHA1 | Date | |
---|---|---|---|
|
efda0cd115 | ||
|
bbf2e2ac67 |
57
.gitignore
vendored
57
.gitignore
vendored
@ -1,57 +0,0 @@
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
env/
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*,cover
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
target/
|
@ -62,7 +62,7 @@
|
||||
"name": "Hossein Javedani Sadaei"
|
||||
}
|
||||
],
|
||||
"version": "pkg1.7",
|
||||
"version": "pkg1.6",
|
||||
"upload_type": "software",
|
||||
"keywords": [
|
||||
"data science",
|
||||
|
10
CITATION.cff
10
CITATION.cff
@ -1,10 +0,0 @@
|
||||
cff-version: 1.1.0
|
||||
message: "If you use this software, please cite it as below."
|
||||
authors:
|
||||
- family-names: Silva
|
||||
given-names: Petrônio C. L.
|
||||
orcid: https://orcid.org/0000-0002-1202-2552/
|
||||
title: PYFTS/pyFTS: Stable version 1.7
|
||||
doi: 10.5281/zenodo.597359
|
||||
version: pkg1.7
|
||||
date-released: 2023-03-20
|
2
MANIFEST
2
MANIFEST
@ -104,7 +104,7 @@ pyFTS/models/seasonal/common.py
|
||||
pyFTS/models/seasonal/msfts.py
|
||||
pyFTS/models/seasonal/partitioner.py
|
||||
pyFTS/models/seasonal/sfts.py
|
||||
pyFTS/partitioners/KMeans.py
|
||||
pyFTS/partitioners/CMeans.py
|
||||
pyFTS/partitioners/Entropy.py
|
||||
pyFTS/partitioners/FCM.py
|
||||
pyFTS/partitioners/Grid.py
|
||||
|
@ -38,7 +38,7 @@ Fuzzy Time Series (FTS) are non parametric methods for time series forecasting b
|
||||
2. **Universe of Discourse Partitioning**: This is the most important step. Here, the range of values of the numerical time series *Y(t)* will be splited in overlapped intervals and for each interval will be created a Fuzzy Set. This step is performed by pyFTS.partition module and its classes (for instance GridPartitioner, EntropyPartitioner, etc). The main parameters are:
|
||||
- the number of intervals
|
||||
- which fuzzy membership function (on [pyFTS.common.Membership](https://github.com/PYFTS/pyFTS/blob/master/pyFTS/common/Membership.py))
|
||||
- partition scheme ([GridPartitioner](https://github.com/PYFTS/pyFTS/blob/master/pyFTS/partitioners/Grid.py), [EntropyPartitioner](https://github.com/PYFTS/pyFTS/blob/master/pyFTS/partitioners/Entropy.py)[3], [FCMPartitioner](https://github.com/PYFTS/pyFTS/blob/master/pyFTS/partitioners/FCM.py), [KMeansPartitioner](https://github.com/PYFTS/pyFTS/blob/master/pyFTS/partitioners/KMeans.py), [HuarngPartitioner](https://github.com/PYFTS/pyFTS/blob/master/pyFTS/partitioners/Huarng.py)[4])
|
||||
- partition scheme ([GridPartitioner](https://github.com/PYFTS/pyFTS/blob/master/pyFTS/partitioners/Grid.py), [EntropyPartitioner](https://github.com/PYFTS/pyFTS/blob/master/pyFTS/partitioners/Entropy.py)[3], [FCMPartitioner](https://github.com/PYFTS/pyFTS/blob/master/pyFTS/partitioners/FCM.py), [CMeansPartitioner](https://github.com/PYFTS/pyFTS/blob/master/pyFTS/partitioners/CMeans.py), [HuarngPartitioner](https://github.com/PYFTS/pyFTS/blob/master/pyFTS/partitioners/Huarng.py)[4])
|
||||
|
||||
Check out the jupyter notebook on [notebooks/Partitioners.ipynb](https://github.com/PYFTS/notebooks/blob/master/Partitioners.ipynb) for sample codes.
|
||||
|
||||
|
BIN
docs/build/doctrees/environment.pickle
vendored
BIN
docs/build/doctrees/environment.pickle
vendored
Binary file not shown.
BIN
docs/build/doctrees/index.doctree
vendored
BIN
docs/build/doctrees/index.doctree
vendored
Binary file not shown.
BIN
docs/build/doctrees/modules.doctree
vendored
BIN
docs/build/doctrees/modules.doctree
vendored
Binary file not shown.
BIN
docs/build/doctrees/pyFTS.benchmarks.doctree
vendored
BIN
docs/build/doctrees/pyFTS.benchmarks.doctree
vendored
Binary file not shown.
BIN
docs/build/doctrees/pyFTS.common.doctree
vendored
BIN
docs/build/doctrees/pyFTS.common.doctree
vendored
Binary file not shown.
Binary file not shown.
BIN
docs/build/doctrees/pyFTS.data.doctree
vendored
BIN
docs/build/doctrees/pyFTS.data.doctree
vendored
Binary file not shown.
BIN
docs/build/doctrees/pyFTS.distributed.doctree
vendored
BIN
docs/build/doctrees/pyFTS.distributed.doctree
vendored
Binary file not shown.
BIN
docs/build/doctrees/pyFTS.doctree
vendored
BIN
docs/build/doctrees/pyFTS.doctree
vendored
Binary file not shown.
BIN
docs/build/doctrees/pyFTS.hyperparam.doctree
vendored
BIN
docs/build/doctrees/pyFTS.hyperparam.doctree
vendored
Binary file not shown.
BIN
docs/build/doctrees/pyFTS.models.doctree
vendored
BIN
docs/build/doctrees/pyFTS.models.doctree
vendored
Binary file not shown.
BIN
docs/build/doctrees/pyFTS.models.ensemble.doctree
vendored
BIN
docs/build/doctrees/pyFTS.models.ensemble.doctree
vendored
Binary file not shown.
BIN
docs/build/doctrees/pyFTS.models.incremental.doctree
vendored
BIN
docs/build/doctrees/pyFTS.models.incremental.doctree
vendored
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
docs/build/doctrees/pyFTS.models.seasonal.doctree
vendored
BIN
docs/build/doctrees/pyFTS.models.seasonal.doctree
vendored
Binary file not shown.
BIN
docs/build/doctrees/pyFTS.partitioners.doctree
vendored
BIN
docs/build/doctrees/pyFTS.partitioners.doctree
vendored
Binary file not shown.
BIN
docs/build/doctrees/pyFTS.probabilistic.doctree
vendored
BIN
docs/build/doctrees/pyFTS.probabilistic.doctree
vendored
Binary file not shown.
BIN
docs/build/doctrees/quickstart.doctree
vendored
BIN
docs/build/doctrees/quickstart.doctree
vendored
Binary file not shown.
2
docs/build/html/.buildinfo
vendored
2
docs/build/html/.buildinfo
vendored
@ -1,4 +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: e1454eaeb1089d326a83742cdfb66db8
|
||||
config: b63d11eac6819505a39e742f563e774b
|
||||
tags: 645f666f9bcd5a90fca523b33c5a78b7
|
||||
|
94
docs/build/html/_modules/index.html
vendored
94
docs/build/html/_modules/index.html
vendored
@ -5,19 +5,31 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>Overview: module code — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../_static/bizstyle.css" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"><script type="text/javascript">
|
||||
|
||||
<script data-url_root="../" id="documentation_options" src="../_static/documentation_options.js"></script>
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-55120145-3']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
|
||||
(function() {
|
||||
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
</script>
|
||||
<title>Overview: module code — pyFTS 1.6 documentation</title>
|
||||
<link rel="stylesheet" href="../_static/bizstyle.css" type="text/css" />
|
||||
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
|
||||
|
||||
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
|
||||
<script src="../_static/jquery.js"></script>
|
||||
<script src="../_static/underscore.js"></script>
|
||||
<script src="../_static/doctools.js"></script>
|
||||
<script src="../_static/language_data.js"></script>
|
||||
<script src="../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../genindex.html" />
|
||||
<link rel="search" title="Search" href="../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0">
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
@ -31,7 +43,7 @@
|
||||
<li class="right" >
|
||||
<a href="../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-0"><a href="../index.html">pyFTS 1.6 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">Overview: module code</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
@ -42,21 +54,25 @@
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>All modules for which code is available</h1>
|
||||
<ul><li><a href="pyFTS/common/Activations.html">pyFTS.common.Activations</a></li>
|
||||
<ul><li><a href="pyFTS/benchmarks/BSTS.html">pyFTS.benchmarks.BSTS</a></li>
|
||||
<li><a href="pyFTS/benchmarks/Measures.html">pyFTS.benchmarks.Measures</a></li>
|
||||
<li><a href="pyFTS/benchmarks/ResidualAnalysis.html">pyFTS.benchmarks.ResidualAnalysis</a></li>
|
||||
<li><a href="pyFTS/benchmarks/Tests.html">pyFTS.benchmarks.Tests</a></li>
|
||||
<li><a href="pyFTS/benchmarks/Util.html">pyFTS.benchmarks.Util</a></li>
|
||||
<li><a href="pyFTS/benchmarks/arima.html">pyFTS.benchmarks.arima</a></li>
|
||||
<li><a href="pyFTS/benchmarks/benchmarks.html">pyFTS.benchmarks.benchmarks</a></li>
|
||||
<li><a href="pyFTS/benchmarks/knn.html">pyFTS.benchmarks.knn</a></li>
|
||||
<li><a href="pyFTS/benchmarks/naive.html">pyFTS.benchmarks.naive</a></li>
|
||||
<li><a href="pyFTS/benchmarks/quantreg.html">pyFTS.benchmarks.quantreg</a></li>
|
||||
<li><a href="pyFTS/common/Composite.html">pyFTS.common.Composite</a></li>
|
||||
<li><a href="pyFTS/common/FLR.html">pyFTS.common.FLR</a></li>
|
||||
<li><a href="pyFTS/common/FuzzySet.html">pyFTS.common.FuzzySet</a></li>
|
||||
<li><a href="pyFTS/common/Membership.html">pyFTS.common.Membership</a></li>
|
||||
<li><a href="pyFTS/common/SortedCollection.html">pyFTS.common.SortedCollection</a></li>
|
||||
<li><a href="pyFTS/common/Transformations.html">pyFTS.common.Transformations</a></li>
|
||||
<li><a href="pyFTS/common/Util.html">pyFTS.common.Util</a></li>
|
||||
<li><a href="pyFTS/common/flrg.html">pyFTS.common.flrg</a></li>
|
||||
<li><a href="pyFTS/common/transformations/boxcox.html">pyFTS.common.transformations.boxcox</a></li>
|
||||
<li><a href="pyFTS/common/transformations/differential.html">pyFTS.common.transformations.differential</a></li>
|
||||
<li><a href="pyFTS/common/transformations/normalization.html">pyFTS.common.transformations.normalization</a></li>
|
||||
<li><a href="pyFTS/common/transformations/roi.html">pyFTS.common.transformations.roi</a></li>
|
||||
<li><a href="pyFTS/common/transformations/scale.html">pyFTS.common.transformations.scale</a></li>
|
||||
<li><a href="pyFTS/common/transformations/smoothing.html">pyFTS.common.transformations.smoothing</a></li>
|
||||
<li><a href="pyFTS/common/transformations/som.html">pyFTS.common.transformations.som</a></li>
|
||||
<li><a href="pyFTS/common/transformations/transformation.html">pyFTS.common.transformations.transformation</a></li>
|
||||
<li><a href="pyFTS/common/fts.html">pyFTS.common.fts</a></li>
|
||||
<li><a href="pyFTS/common/tree.html">pyFTS.common.tree</a></li>
|
||||
<li><a href="pyFTS/data/AirPassengers.html">pyFTS.data.AirPassengers</a></li>
|
||||
<li><a href="pyFTS/data/Bitcoin.html">pyFTS.data.Bitcoin</a></li>
|
||||
@ -80,28 +96,61 @@
|
||||
<li><a href="pyFTS/data/mackey_glass.html">pyFTS.data.mackey_glass</a></li>
|
||||
<li><a href="pyFTS/data/rossler.html">pyFTS.data.rossler</a></li>
|
||||
<li><a href="pyFTS/data/sunspots.html">pyFTS.data.sunspots</a></li>
|
||||
<li><a href="pyFTS/distributed/dispy.html">pyFTS.distributed.dispy</a></li>
|
||||
<li><a href="pyFTS/hyperparam/Evolutionary.html">pyFTS.hyperparam.Evolutionary</a></li>
|
||||
<li><a href="pyFTS/hyperparam/GridSearch.html">pyFTS.hyperparam.GridSearch</a></li>
|
||||
<li><a href="pyFTS/hyperparam/Util.html">pyFTS.hyperparam.Util</a></li>
|
||||
<li><a href="pyFTS/models/chen.html">pyFTS.models.chen</a></li>
|
||||
<li><a href="pyFTS/models/cheng.html">pyFTS.models.cheng</a></li>
|
||||
<li><a href="pyFTS/models/ensemble/ensemble.html">pyFTS.models.ensemble.ensemble</a></li>
|
||||
<li><a href="pyFTS/models/ensemble/multiseasonal.html">pyFTS.models.ensemble.multiseasonal</a></li>
|
||||
<li><a href="pyFTS/models/hofts.html">pyFTS.models.hofts</a></li>
|
||||
<li><a href="pyFTS/models/hwang.html">pyFTS.models.hwang</a></li>
|
||||
<li><a href="pyFTS/models/ifts.html">pyFTS.models.ifts</a></li>
|
||||
<li><a href="pyFTS/models/incremental/IncrementalEnsemble.html">pyFTS.models.incremental.IncrementalEnsemble</a></li>
|
||||
<li><a href="pyFTS/models/incremental/TimeVariant.html">pyFTS.models.incremental.TimeVariant</a></li>
|
||||
<li><a href="pyFTS/models/ismailefendi.html">pyFTS.models.ismailefendi</a></li>
|
||||
<li><a href="pyFTS/models/multivariate/FLR.html">pyFTS.models.multivariate.FLR</a></li>
|
||||
<li><a href="pyFTS/models/multivariate/cmvfts.html">pyFTS.models.multivariate.cmvfts</a></li>
|
||||
<li><a href="pyFTS/models/multivariate/common.html">pyFTS.models.multivariate.common</a></li>
|
||||
<li><a href="pyFTS/models/multivariate/flrg.html">pyFTS.models.multivariate.flrg</a></li>
|
||||
<li><a href="pyFTS/models/multivariate/granular.html">pyFTS.models.multivariate.granular</a></li>
|
||||
<li><a href="pyFTS/models/multivariate/grid.html">pyFTS.models.multivariate.grid</a></li>
|
||||
<li><a href="pyFTS/models/multivariate/mvfts.html">pyFTS.models.multivariate.mvfts</a></li>
|
||||
<li><a href="pyFTS/models/multivariate/partitioner.html">pyFTS.models.multivariate.partitioner</a></li>
|
||||
<li><a href="pyFTS/models/multivariate/variable.html">pyFTS.models.multivariate.variable</a></li>
|
||||
<li><a href="pyFTS/models/multivariate/wmvfts.html">pyFTS.models.multivariate.wmvfts</a></li>
|
||||
<li><a href="pyFTS/models/nonstationary/common.html">pyFTS.models.nonstationary.common</a></li>
|
||||
<li><a href="pyFTS/models/nonstationary/cvfts.html">pyFTS.models.nonstationary.cvfts</a></li>
|
||||
<li><a href="pyFTS/models/nonstationary/flrg.html">pyFTS.models.nonstationary.flrg</a></li>
|
||||
<li><a href="pyFTS/models/nonstationary/honsfts.html">pyFTS.models.nonstationary.honsfts</a></li>
|
||||
<li><a href="pyFTS/models/nonstationary/nsfts.html">pyFTS.models.nonstationary.nsfts</a></li>
|
||||
<li><a href="pyFTS/models/nonstationary/partitioners.html">pyFTS.models.nonstationary.partitioners</a></li>
|
||||
<li><a href="pyFTS/models/nonstationary/perturbation.html">pyFTS.models.nonstationary.perturbation</a></li>
|
||||
<li><a href="pyFTS/models/nonstationary/util.html">pyFTS.models.nonstationary.util</a></li>
|
||||
<li><a href="pyFTS/models/pwfts.html">pyFTS.models.pwfts</a></li>
|
||||
<li><a href="pyFTS/models/sadaei.html">pyFTS.models.sadaei</a></li>
|
||||
<li><a href="pyFTS/models/seasonal/SeasonalIndexer.html">pyFTS.models.seasonal.SeasonalIndexer</a></li>
|
||||
<li><a href="pyFTS/models/seasonal/cmsfts.html">pyFTS.models.seasonal.cmsfts</a></li>
|
||||
<li><a href="pyFTS/models/seasonal/common.html">pyFTS.models.seasonal.common</a></li>
|
||||
<li><a href="pyFTS/models/seasonal/msfts.html">pyFTS.models.seasonal.msfts</a></li>
|
||||
<li><a href="pyFTS/models/seasonal/partitioner.html">pyFTS.models.seasonal.partitioner</a></li>
|
||||
<li><a href="pyFTS/models/seasonal/sfts.html">pyFTS.models.seasonal.sfts</a></li>
|
||||
<li><a href="pyFTS/models/song.html">pyFTS.models.song</a></li>
|
||||
<li><a href="pyFTS/models/yu.html">pyFTS.models.yu</a></li>
|
||||
<li><a href="pyFTS/partitioners/CMeans.html">pyFTS.partitioners.CMeans</a></li>
|
||||
<li><a href="pyFTS/partitioners/Class.html">pyFTS.partitioners.Class</a></li>
|
||||
<li><a href="pyFTS/partitioners/Entropy.html">pyFTS.partitioners.Entropy</a></li>
|
||||
<li><a href="pyFTS/partitioners/FCM.html">pyFTS.partitioners.FCM</a></li>
|
||||
<li><a href="pyFTS/partitioners/Grid.html">pyFTS.partitioners.Grid</a></li>
|
||||
<li><a href="pyFTS/partitioners/Huarng.html">pyFTS.partitioners.Huarng</a></li>
|
||||
<li><a href="pyFTS/partitioners/Simple.html">pyFTS.partitioners.Simple</a></li>
|
||||
<li><a href="pyFTS/partitioners/Singleton.html">pyFTS.partitioners.Singleton</a></li>
|
||||
<li><a href="pyFTS/partitioners/SubClust.html">pyFTS.partitioners.SubClust</a></li>
|
||||
<li><a href="pyFTS/partitioners/Util.html">pyFTS.partitioners.Util</a></li>
|
||||
<li><a href="pyFTS/partitioners/parallel_util.html">pyFTS.partitioners.parallel_util</a></li>
|
||||
<li><a href="pyFTS/partitioners/partitioner.html">pyFTS.partitioners.partitioner</a></li>
|
||||
<li><a href="pyFTS/probabilistic/ProbabilityDistribution.html">pyFTS.probabilistic.ProbabilityDistribution</a></li>
|
||||
<li><a href="pyFTS/probabilistic/kde.html">pyFTS.probabilistic.kde</a></li>
|
||||
</ul>
|
||||
|
||||
<div class="clearer"></div>
|
||||
@ -110,14 +159,11 @@
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../index.html">
|
||||
<img class="logo" src="../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" />
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
@ -136,13 +182,13 @@
|
||||
<li class="right" >
|
||||
<a href="../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-0"><a href="../index.html">pyFTS 1.6 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">Overview: module code</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
© Copyright 2018, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.1.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,109 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.common.Activations — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../_static/jquery.js"></script>
|
||||
<script src="../../../_static/underscore.js"></script>
|
||||
<script src="../../../_static/doctools.js"></script>
|
||||
<script src="../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.common.Activations</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.common.Activations</h1><div class="highlight"><pre>
|
||||
<span></span><span class="sd">"""</span>
|
||||
<span class="sd">Activation functions for Time Series Classification</span>
|
||||
<span class="sd">"""</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
<span class="kn">import</span> <span class="nn">math</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS</span> <span class="kn">import</span> <span class="o">*</span>
|
||||
|
||||
<div class="viewcode-block" id="scale"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.Activations.scale">[docs]</a><span class="k">def</span> <span class="nf">scale</span><span class="p">(</span><span class="n">dist</span> <span class="p">:</span> <span class="nb">dict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">dict</span><span class="p">:</span>
|
||||
<span class="n">norm</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">sum</span><span class="p">([</span><span class="n">v</span> <span class="k">for</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">dist</span><span class="o">.</span><span class="n">values</span><span class="p">()])</span>
|
||||
<span class="k">return</span> <span class="p">{</span><span class="n">k</span> <span class="p">:</span> <span class="p">(</span><span class="n">v</span> <span class="o">/</span> <span class="n">norm</span><span class="p">)</span> <span class="k">for</span> <span class="n">k</span><span class="p">,</span><span class="n">v</span> <span class="ow">in</span> <span class="n">dist</span><span class="o">.</span><span class="n">items</span><span class="p">()</span> <span class="p">}</span></div>
|
||||
|
||||
<div class="viewcode-block" id="softmax"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.Activations.softmax">[docs]</a><span class="k">def</span> <span class="nf">softmax</span><span class="p">(</span><span class="n">dist</span> <span class="p">:</span> <span class="nb">dict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">dict</span><span class="p">:</span>
|
||||
<span class="n">norm</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">sum</span><span class="p">([</span><span class="n">np</span><span class="o">.</span><span class="n">exp</span><span class="p">(</span><span class="n">v</span><span class="p">)</span> <span class="k">for</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">dist</span><span class="o">.</span><span class="n">values</span><span class="p">()])</span>
|
||||
<span class="k">return</span> <span class="p">{</span><span class="n">k</span> <span class="p">:</span> <span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">exp</span><span class="p">(</span><span class="n">v</span><span class="p">)</span> <span class="o">/</span> <span class="n">norm</span><span class="p">)</span> <span class="k">for</span> <span class="n">k</span><span class="p">,</span><span class="n">v</span> <span class="ow">in</span> <span class="n">dist</span><span class="o">.</span><span class="n">items</span><span class="p">()</span> <span class="p">}</span></div>
|
||||
|
||||
<div class="viewcode-block" id="argmax"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.Activations.argmax">[docs]</a><span class="k">def</span> <span class="nf">argmax</span><span class="p">(</span><span class="n">dist</span> <span class="p">:</span> <span class="nb">dict</span><span class="p">)</span> <span class="o">-></span> <span class="nb">str</span><span class="p">:</span>
|
||||
<span class="n">mx</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">max</span><span class="p">([</span><span class="n">v</span> <span class="k">for</span> <span class="n">v</span> <span class="ow">in</span> <span class="n">dist</span><span class="o">.</span><span class="n">values</span><span class="p">()])</span>
|
||||
<span class="k">return</span> <span class="p">[</span><span class="n">k</span> <span class="k">for</span> <span class="n">k</span><span class="p">,</span><span class="n">v</span> <span class="ow">in</span> <span class="n">dist</span><span class="o">.</span><span class="n">items</span><span class="p">()</span> <span class="k">if</span> <span class="n">v</span> <span class="o">==</span> <span class="n">mx</span> <span class="p">][</span><span class="mi">0</span><span class="p">]</span></div>
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../index.html">
|
||||
<img class="logo" src="../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.common.Activations</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
174
docs/build/html/_modules/pyFTS/common/Composite.html
vendored
174
docs/build/html/_modules/pyFTS/common/Composite.html
vendored
@ -1,174 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.common.Composite — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../_static/jquery.js"></script>
|
||||
<script src="../../../_static/underscore.js"></script>
|
||||
<script src="../../../_static/doctools.js"></script>
|
||||
<script src="../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.common.Composite</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.common.Composite</h1><div class="highlight"><pre>
|
||||
<span></span><span class="sd">"""</span>
|
||||
<span class="sd">Composite Fuzzy Sets</span>
|
||||
<span class="sd">"""</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS</span> <span class="kn">import</span> <span class="o">*</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.common</span> <span class="kn">import</span> <span class="n">Membership</span><span class="p">,</span> <span class="n">FuzzySet</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="FuzzySet"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.Composite.FuzzySet">[docs]</a><span class="k">class</span> <span class="nc">FuzzySet</span><span class="p">(</span><span class="n">FuzzySet</span><span class="o">.</span><span class="n">FuzzySet</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Composite Fuzzy Set</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">superset</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Create an empty composite fuzzy set</span>
|
||||
<span class="sd"> :param name: fuzzy set name</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">if</span> <span class="s1">'type'</span> <span class="ow">in</span> <span class="n">kwargs</span><span class="p">:</span>
|
||||
<span class="n">kwargs</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s1">'type'</span><span class="p">)</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">FuzzySet</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">,</span> <span class="kc">None</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="s1">'composite'</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">superset</span> <span class="o">=</span> <span class="n">superset</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">superset</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">sets</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">mf</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">parameters</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">lower</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">upper</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">centroid</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="FuzzySet.membership"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.Composite.FuzzySet.membership">[docs]</a> <span class="k">def</span> <span class="nf">membership</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">x</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Calculate the membership value of a given input</span>
|
||||
|
||||
<span class="sd"> :param x: input value</span>
|
||||
<span class="sd"> :return: membership value of x at this fuzzy set</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">superset</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="nb">max</span><span class="p">([</span><span class="n">s</span><span class="o">.</span><span class="n">membership</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="k">for</span> <span class="n">s</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">])</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="nb">min</span><span class="p">([</span><span class="bp">self</span><span class="o">.</span><span class="n">mf</span><span class="p">[</span><span class="n">ct</span><span class="p">](</span><span class="bp">self</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span><span class="n">x</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">parameters</span><span class="p">[</span><span class="n">ct</span><span class="p">])</span> <span class="k">for</span> <span class="n">ct</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">mf</span><span class="p">))])</span></div>
|
||||
|
||||
<div class="viewcode-block" id="FuzzySet.transform"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.Composite.FuzzySet.transform">[docs]</a> <span class="k">def</span> <span class="nf">transform</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">x</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span><span class="n">x</span><span class="p">)</span></div>
|
||||
|
||||
<div class="viewcode-block" id="FuzzySet.append"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.Composite.FuzzySet.append">[docs]</a> <span class="k">def</span> <span class="nf">append</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">mf</span><span class="p">,</span> <span class="n">parameters</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Adds a new function to composition</span>
|
||||
|
||||
<span class="sd"> :param mf:</span>
|
||||
<span class="sd"> :param parameters:</span>
|
||||
<span class="sd"> :return:</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">mf</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">mf</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">parameters</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">parameters</span><span class="p">)</span></div>
|
||||
|
||||
<div class="viewcode-block" id="FuzzySet.append_set"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.Composite.FuzzySet.append_set">[docs]</a> <span class="k">def</span> <span class="nf">append_set</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="nb">set</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Adds a new function to composition</span>
|
||||
|
||||
<span class="sd"> :param mf:</span>
|
||||
<span class="sd"> :param parameters:</span>
|
||||
<span class="sd"> :return:</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">set</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">lower</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">lower</span> <span class="o">></span> <span class="nb">set</span><span class="o">.</span><span class="n">lower</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">lower</span> <span class="o">=</span> <span class="nb">set</span><span class="o">.</span><span class="n">lower</span>
|
||||
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">upper</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">upper</span> <span class="o"><</span> <span class="nb">set</span><span class="o">.</span><span class="n">upper</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">upper</span> <span class="o">=</span> <span class="nb">set</span><span class="o">.</span><span class="n">upper</span>
|
||||
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">centroid</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">centroid</span> <span class="o"><</span> <span class="nb">set</span><span class="o">.</span><span class="n">centroid</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">centroid</span> <span class="o">=</span> <span class="nb">set</span><span class="o">.</span><span class="n">centroid</span></div>
|
||||
|
||||
|
||||
<span class="k">def</span> <span class="fm">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="nb">str</span><span class="p">([</span><span class="nb">str</span><span class="p">(</span><span class="n">k</span><span class="p">)</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">])</span>
|
||||
<span class="k">return</span> <span class="s2">"</span><span class="si">{}</span><span class="s2">: </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">tmp</span><span class="p">)</span></div>
|
||||
|
||||
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../index.html">
|
||||
<img class="logo" src="../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.common.Composite</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
210
docs/build/html/_modules/pyFTS/common/FLR.html
vendored
210
docs/build/html/_modules/pyFTS/common/FLR.html
vendored
@ -1,210 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.common.FLR — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../_static/jquery.js"></script>
|
||||
<script src="../../../_static/underscore.js"></script>
|
||||
<script src="../../../_static/doctools.js"></script>
|
||||
<script src="../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.common.FLR</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.common.FLR</h1><div class="highlight"><pre>
|
||||
<span></span><span class="sd">"""</span>
|
||||
<span class="sd">This module implements functions for Fuzzy Logical Relationship generation</span>
|
||||
<span class="sd">"""</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.common</span> <span class="kn">import</span> <span class="n">FuzzySet</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="FLR"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.FLR.FLR">[docs]</a><span class="k">class</span> <span class="nc">FLR</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Fuzzy Logical Relationship</span>
|
||||
|
||||
<span class="sd"> Represents a temporal transition of the fuzzy set LHS on time t for the fuzzy set RHS on time t+1.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">LHS</span><span class="p">,</span> <span class="n">RHS</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Creates a Fuzzy Logical Relationship</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">LHS</span> <span class="o">=</span> <span class="n">LHS</span>
|
||||
<span class="w"> </span><span class="sd">"""Left Hand Side fuzzy set"""</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">RHS</span> <span class="o">=</span> <span class="n">RHS</span>
|
||||
<span class="w"> </span><span class="sd">"""Right Hand Side fuzzy set"""</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">LHS</span><span class="p">)</span> <span class="o">+</span> <span class="s2">" -> "</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="p">)</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="IndexedFLR"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.FLR.IndexedFLR">[docs]</a><span class="k">class</span> <span class="nc">IndexedFLR</span><span class="p">(</span><span class="n">FLR</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""Season Indexed Fuzzy Logical Relationship"""</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">index</span><span class="p">,</span> <span class="n">LHS</span><span class="p">,</span> <span class="n">RHS</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Create a Season Indexed Fuzzy Logical Relationship</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">IndexedFLR</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">LHS</span><span class="p">,</span> <span class="n">RHS</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">index</span> <span class="o">=</span> <span class="n">index</span>
|
||||
<span class="w"> </span><span class="sd">"""seasonal index"""</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">index</span><span class="p">)</span> <span class="o">+</span> <span class="s2">": "</span><span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">LHS</span><span class="p">)</span> <span class="o">+</span> <span class="s2">" -> "</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="p">)</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="generate_high_order_recurrent_flr"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.FLR.generate_high_order_recurrent_flr">[docs]</a><span class="k">def</span> <span class="nf">generate_high_order_recurrent_flr</span><span class="p">(</span><span class="n">fuzzyData</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Create a ordered FLR set from a list of fuzzy sets with recurrence</span>
|
||||
|
||||
<span class="sd"> :param fuzzyData: ordered list of fuzzy sets</span>
|
||||
<span class="sd"> :return: ordered list of FLR</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">flrs</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="nb">len</span><span class="p">(</span><span class="n">fuzzyData</span><span class="p">)):</span>
|
||||
<span class="n">lhs</span> <span class="o">=</span> <span class="n">fuzzyData</span><span class="p">[</span><span class="n">i</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span>
|
||||
<span class="n">rhs</span> <span class="o">=</span> <span class="n">fuzzyData</span><span class="p">[</span><span class="n">i</span><span class="p">]</span>
|
||||
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">lhs</span><span class="p">,</span> <span class="nb">list</span><span class="p">)</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">rhs</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span>
|
||||
<span class="k">for</span> <span class="n">l</span> <span class="ow">in</span> <span class="n">lhs</span><span class="p">:</span>
|
||||
<span class="k">for</span> <span class="n">r</span> <span class="ow">in</span> <span class="n">rhs</span><span class="p">:</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">FLR</span><span class="p">(</span><span class="n">l</span><span class="p">,</span> <span class="n">r</span><span class="p">)</span>
|
||||
<span class="n">flrs</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">tmp</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">FLR</span><span class="p">(</span><span class="n">lhs</span><span class="p">,</span><span class="n">rhs</span><span class="p">)</span>
|
||||
<span class="n">flrs</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">tmp</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">flrs</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="generate_recurrent_flrs"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.FLR.generate_recurrent_flrs">[docs]</a><span class="k">def</span> <span class="nf">generate_recurrent_flrs</span><span class="p">(</span><span class="n">fuzzyData</span><span class="p">,</span> <span class="n">steps</span> <span class="o">=</span> <span class="mi">1</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Create a ordered FLR set from a list of fuzzy sets with recurrence</span>
|
||||
|
||||
<span class="sd"> :param fuzzyData: ordered list of fuzzy sets</span>
|
||||
<span class="sd"> :param steps: the number of steps ahead on the right side of FLR</span>
|
||||
<span class="sd"> :return: ordered list of FLR</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">_tmp_steps</span> <span class="o">=</span> <span class="n">steps</span> <span class="o">-</span> <span class="mi">1</span>
|
||||
<span class="n">flrs</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="nb">len</span><span class="p">(</span><span class="n">fuzzyData</span><span class="p">)</span> <span class="o">-</span> <span class="n">_tmp_steps</span><span class="p">):</span>
|
||||
<span class="n">lhs</span> <span class="o">=</span> <span class="p">[</span><span class="n">fuzzyData</span><span class="p">[</span><span class="n">i</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]]</span>
|
||||
<span class="n">rhs</span> <span class="o">=</span> <span class="p">[</span><span class="n">fuzzyData</span><span class="p">[</span><span class="n">i</span><span class="o">+</span><span class="n">_tmp_steps</span><span class="p">]]</span>
|
||||
<span class="k">for</span> <span class="n">l</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">lhs</span><span class="p">)</span><span class="o">.</span><span class="n">flatten</span><span class="p">():</span>
|
||||
<span class="k">for</span> <span class="n">r</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">rhs</span><span class="p">)</span><span class="o">.</span><span class="n">flatten</span><span class="p">():</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">FLR</span><span class="p">(</span><span class="n">l</span><span class="p">,</span> <span class="n">r</span><span class="p">)</span>
|
||||
<span class="n">flrs</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">tmp</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">flrs</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="generate_non_recurrent_flrs"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.FLR.generate_non_recurrent_flrs">[docs]</a><span class="k">def</span> <span class="nf">generate_non_recurrent_flrs</span><span class="p">(</span><span class="n">fuzzyData</span><span class="p">,</span> <span class="n">steps</span> <span class="o">=</span> <span class="mi">1</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Create a ordered FLR set from a list of fuzzy sets without recurrence</span>
|
||||
|
||||
<span class="sd"> :param fuzzyData: ordered list of fuzzy sets</span>
|
||||
<span class="sd"> :return: ordered list of FLR</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">flrs</span> <span class="o">=</span> <span class="n">generate_recurrent_flrs</span><span class="p">(</span><span class="n">fuzzyData</span><span class="p">,</span> <span class="n">steps</span><span class="o">=</span><span class="n">steps</span><span class="p">)</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="p">{}</span>
|
||||
<span class="k">for</span> <span class="n">flr</span> <span class="ow">in</span> <span class="n">flrs</span><span class="p">:</span> <span class="n">tmp</span><span class="p">[</span><span class="nb">str</span><span class="p">(</span><span class="n">flr</span><span class="p">)]</span> <span class="o">=</span> <span class="n">flr</span>
|
||||
<span class="n">ret</span> <span class="o">=</span> <span class="p">[</span><span class="n">value</span> <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">tmp</span><span class="o">.</span><span class="n">items</span><span class="p">()]</span>
|
||||
<span class="k">return</span> <span class="n">ret</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="generate_indexed_flrs"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.FLR.generate_indexed_flrs">[docs]</a><span class="k">def</span> <span class="nf">generate_indexed_flrs</span><span class="p">(</span><span class="n">sets</span><span class="p">,</span> <span class="n">indexer</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">transformation</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">alpha_cut</span><span class="o">=</span><span class="mf">0.0</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Create a season-indexed ordered FLR set from a list of fuzzy sets with recurrence</span>
|
||||
|
||||
<span class="sd"> :param sets: fuzzy sets</span>
|
||||
<span class="sd"> :param indexer: seasonality indexer </span>
|
||||
<span class="sd"> :param data: original data</span>
|
||||
<span class="sd"> :return: ordered list of FLR </span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">flrs</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="n">index</span> <span class="o">=</span> <span class="n">indexer</span><span class="o">.</span><span class="n">get_season_of_data</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
|
||||
<span class="n">ndata</span> <span class="o">=</span> <span class="n">indexer</span><span class="o">.</span><span class="n">get_data</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">transformation</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">ndata</span> <span class="o">=</span> <span class="n">transformation</span><span class="o">.</span><span class="n">apply</span><span class="p">(</span><span class="n">ndata</span><span class="p">)</span>
|
||||
<span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="nb">len</span><span class="p">(</span><span class="n">ndata</span><span class="p">)):</span>
|
||||
<span class="n">lhs</span> <span class="o">=</span> <span class="n">FuzzySet</span><span class="o">.</span><span class="n">fuzzyfy_series</span><span class="p">([</span><span class="n">ndata</span><span class="p">[</span><span class="n">k</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]],</span> <span class="n">sets</span><span class="p">,</span> <span class="n">method</span><span class="o">=</span><span class="s1">'fuzzy'</span><span class="p">,</span><span class="n">alpha_cut</span><span class="o">=</span><span class="n">alpha_cut</span><span class="p">)</span>
|
||||
<span class="n">rhs</span> <span class="o">=</span> <span class="n">FuzzySet</span><span class="o">.</span><span class="n">fuzzyfy_series</span><span class="p">([</span><span class="n">ndata</span><span class="p">[</span><span class="n">k</span><span class="p">]],</span> <span class="n">sets</span><span class="p">,</span> <span class="n">method</span><span class="o">=</span><span class="s1">'fuzzy'</span><span class="p">,</span><span class="n">alpha_cut</span><span class="o">=</span><span class="n">alpha_cut</span><span class="p">)</span>
|
||||
<span class="n">season</span> <span class="o">=</span> <span class="n">index</span><span class="p">[</span><span class="n">k</span><span class="p">]</span>
|
||||
<span class="k">for</span> <span class="n">_l</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">lhs</span><span class="p">)</span><span class="o">.</span><span class="n">flatten</span><span class="p">():</span>
|
||||
<span class="k">for</span> <span class="n">_r</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">rhs</span><span class="p">)</span><span class="o">.</span><span class="n">flatten</span><span class="p">():</span>
|
||||
<span class="n">flr</span> <span class="o">=</span> <span class="n">IndexedFLR</span><span class="p">(</span><span class="n">season</span><span class="p">,</span><span class="n">_l</span><span class="p">,</span><span class="n">_r</span><span class="p">)</span>
|
||||
<span class="n">flrs</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">flr</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">flrs</span></div>
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../index.html">
|
||||
<img class="logo" src="../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.common.FLR</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
401
docs/build/html/_modules/pyFTS/common/FuzzySet.html
vendored
401
docs/build/html/_modules/pyFTS/common/FuzzySet.html
vendored
@ -1,401 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.common.FuzzySet — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../_static/jquery.js"></script>
|
||||
<script src="../../../_static/underscore.js"></script>
|
||||
<script src="../../../_static/doctools.js"></script>
|
||||
<script src="../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.common.FuzzySet</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.common.FuzzySet</h1><div class="highlight"><pre>
|
||||
<span></span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS</span> <span class="kn">import</span> <span class="o">*</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.common</span> <span class="kn">import</span> <span class="n">Membership</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="FuzzySet"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.FuzzySet.FuzzySet">[docs]</a><span class="k">class</span> <span class="nc">FuzzySet</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Fuzzy Set</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span> <span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">mf</span><span class="p">,</span> <span class="n">parameters</span> <span class="p">:</span> <span class="nb">list</span><span class="p">,</span> <span class="n">centroid</span> <span class="p">:</span> <span class="nb">float</span><span class="p">,</span> <span class="n">alpha</span> <span class="p">:</span> <span class="nb">float</span><span class="o">=</span><span class="mf">1.0</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Create a Fuzzy Set</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="n">name</span>
|
||||
<span class="w"> </span><span class="sd">"""The fuzzy set name"""</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">mf</span> <span class="o">=</span> <span class="n">mf</span>
|
||||
<span class="w"> </span><span class="sd">"""The membership function"""</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">parameters</span> <span class="p">:</span> <span class="nb">list</span> <span class="o">=</span> <span class="n">parameters</span>
|
||||
<span class="w"> </span><span class="sd">"""The parameters of the membership function"""</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">centroid</span> <span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="n">centroid</span>
|
||||
<span class="w"> </span><span class="sd">"""The fuzzy set center of mass (or midpoint)"""</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">alpha</span> <span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="n">alpha</span>
|
||||
<span class="w"> </span><span class="sd">"""The alpha cut value"""</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">type</span> <span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'type'</span><span class="p">,</span> <span class="s1">'common'</span><span class="p">)</span>
|
||||
<span class="w"> </span><span class="sd">"""The fuzzy set type (common, composite, nonstationary, etc)"""</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">variable</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'variable'</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
|
||||
<span class="w"> </span><span class="sd">"""In multivariate time series, indicate for which variable this fuzzy set belogs"""</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">Z</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
<span class="w"> </span><span class="sd">"""Partition function in respect to the membership function"""</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">parameters</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">mf</span> <span class="o">==</span> <span class="n">Membership</span><span class="o">.</span><span class="n">gaussmf</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">lower</span> <span class="o">=</span> <span class="n">parameters</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">-</span> <span class="n">parameters</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">*</span> <span class="mi">3</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">upper</span> <span class="o">=</span> <span class="n">parameters</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">+</span> <span class="n">parameters</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">*</span> <span class="mi">3</span>
|
||||
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">mf</span> <span class="o">==</span> <span class="n">Membership</span><span class="o">.</span><span class="n">sigmf</span><span class="p">:</span>
|
||||
<span class="n">k</span> <span class="o">=</span> <span class="p">(</span><span class="n">parameters</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">/</span> <span class="p">(</span><span class="mi">2</span> <span class="o">*</span> <span class="n">parameters</span><span class="p">[</span><span class="mi">0</span><span class="p">]))</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">lower</span> <span class="o">=</span> <span class="n">parameters</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">-</span> <span class="n">k</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">upper</span> <span class="o">=</span> <span class="n">parameters</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="n">k</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">lower</span> <span class="o">=</span> <span class="nb">min</span><span class="p">(</span><span class="n">parameters</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">upper</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="n">parameters</span><span class="p">)</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">metadata</span> <span class="o">=</span> <span class="p">{}</span>
|
||||
|
||||
<div class="viewcode-block" id="FuzzySet.transform"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.FuzzySet.FuzzySet.transform">[docs]</a> <span class="k">def</span> <span class="nf">transform</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">x</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Preprocess the data point for non native types</span>
|
||||
|
||||
<span class="sd"> :param x:</span>
|
||||
<span class="sd"> :return: return a native type value for the structured type</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">x</span></div>
|
||||
|
||||
<div class="viewcode-block" id="FuzzySet.membership"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.FuzzySet.FuzzySet.membership">[docs]</a> <span class="k">def</span> <span class="nf">membership</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">x</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Calculate the membership value of a given input</span>
|
||||
|
||||
<span class="sd"> :param x: input value </span>
|
||||
<span class="sd"> :return: membership value of x at this fuzzy set</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">mf</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span><span class="n">x</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">parameters</span><span class="p">)</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">alpha</span></div>
|
||||
|
||||
<div class="viewcode-block" id="FuzzySet.partition_function"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.FuzzySet.FuzzySet.partition_function">[docs]</a> <span class="k">def</span> <span class="nf">partition_function</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">uod</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">nbins</span><span class="o">=</span><span class="mi">100</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Calculate the partition function over the membership function.</span>
|
||||
|
||||
<span class="sd"> :param uod:</span>
|
||||
<span class="sd"> :param nbins:</span>
|
||||
<span class="sd"> :return:</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">Z</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">and</span> <span class="n">uod</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">Z</span> <span class="o">=</span> <span class="mf">0.0</span>
|
||||
<span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">linspace</span><span class="p">(</span><span class="n">uod</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">uod</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">nbins</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">Z</span> <span class="o">+=</span> <span class="bp">self</span><span class="o">.</span><span class="n">membership</span><span class="p">(</span><span class="n">k</span><span class="p">)</span>
|
||||
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">Z</span></div>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">+</span> <span class="s2">": "</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">mf</span><span class="o">.</span><span class="vm">__name__</span><span class="p">)</span> <span class="o">+</span> <span class="s2">"("</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">parameters</span><span class="p">)</span> <span class="o">+</span> <span class="s2">")"</span></div>
|
||||
|
||||
|
||||
<span class="k">def</span> <span class="nf">__binary_search</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">fuzzy_sets</span><span class="p">,</span> <span class="n">ordered_sets</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Search for elegible fuzzy sets to fuzzyfy x</span>
|
||||
|
||||
<span class="sd"> :param x: input value to be fuzzyfied</span>
|
||||
<span class="sd"> :param fuzzy_sets: a dictionary where the key is the fuzzy set name and the value is the fuzzy set object.</span>
|
||||
<span class="sd"> :param ordered_sets: a list with the fuzzy sets names ordered by their centroids.</span>
|
||||
<span class="sd"> :return: A list with the best fuzzy sets that may contain x</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">max_len</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">fuzzy_sets</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span>
|
||||
<span class="n">first</span> <span class="o">=</span> <span class="mi">0</span>
|
||||
<span class="n">last</span> <span class="o">=</span> <span class="n">max_len</span>
|
||||
|
||||
<span class="k">while</span> <span class="n">first</span> <span class="o"><=</span> <span class="n">last</span><span class="p">:</span>
|
||||
<span class="n">midpoint</span> <span class="o">=</span> <span class="p">(</span><span class="n">first</span> <span class="o">+</span> <span class="n">last</span><span class="p">)</span> <span class="o">//</span> <span class="mi">2</span>
|
||||
|
||||
<span class="n">fs</span> <span class="o">=</span> <span class="n">ordered_sets</span><span class="p">[</span><span class="n">midpoint</span><span class="p">]</span>
|
||||
<span class="n">fs1</span> <span class="o">=</span> <span class="n">ordered_sets</span><span class="p">[</span><span class="n">midpoint</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span> <span class="k">if</span> <span class="n">midpoint</span> <span class="o">></span> <span class="mi">0</span> <span class="k">else</span> <span class="n">ordered_sets</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
|
||||
<span class="n">fs2</span> <span class="o">=</span> <span class="n">ordered_sets</span><span class="p">[</span><span class="n">midpoint</span> <span class="o">+</span> <span class="mi">1</span><span class="p">]</span> <span class="k">if</span> <span class="n">midpoint</span> <span class="o"><</span> <span class="n">max_len</span> <span class="k">else</span> <span class="n">ordered_sets</span><span class="p">[</span><span class="n">max_len</span><span class="p">]</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">fuzzy_sets</span><span class="p">[</span><span class="n">fs1</span><span class="p">]</span><span class="o">.</span><span class="n">centroid</span> <span class="o"><=</span> <span class="n">fuzzy_sets</span><span class="p">[</span><span class="n">fs</span><span class="p">]</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="o"><=</span> <span class="n">fuzzy_sets</span><span class="p">[</span><span class="n">fs2</span><span class="p">]</span><span class="o">.</span><span class="n">centroid</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="p">(</span><span class="n">midpoint</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="n">midpoint</span><span class="p">,</span> <span class="n">midpoint</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span>
|
||||
<span class="k">elif</span> <span class="n">midpoint</span> <span class="o"><=</span> <span class="mi">1</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="p">[</span><span class="mi">0</span><span class="p">]</span>
|
||||
<span class="k">elif</span> <span class="n">midpoint</span> <span class="o">>=</span> <span class="n">max_len</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="p">[</span><span class="n">max_len</span><span class="p">]</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="n">fuzzy_sets</span><span class="p">[</span><span class="n">fs</span><span class="p">]</span><span class="o">.</span><span class="n">transform</span><span class="p">(</span><span class="n">x</span><span class="p">)</span> <span class="o"><</span> <span class="n">fuzzy_sets</span><span class="p">[</span><span class="n">fs</span><span class="p">]</span><span class="o">.</span><span class="n">centroid</span><span class="p">:</span>
|
||||
<span class="n">last</span> <span class="o">=</span> <span class="n">midpoint</span> <span class="o">-</span> <span class="mi">1</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">first</span> <span class="o">=</span> <span class="n">midpoint</span> <span class="o">+</span> <span class="mi">1</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="fuzzyfy"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.FuzzySet.fuzzyfy">[docs]</a><span class="k">def</span> <span class="nf">fuzzyfy</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">partitioner</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> A general method for fuzzyfication.</span>
|
||||
|
||||
<span class="sd"> :param data: input value to be fuzzyfied</span>
|
||||
<span class="sd"> :param partitioner: a trained pyFTS.partitioners.Partitioner object</span>
|
||||
<span class="sd"> :param kwargs: dict, optional arguments</span>
|
||||
<span class="sd"> :keyword alpha_cut: the minimal membership value to be considered on fuzzyfication (only for mode='sets')</span>
|
||||
<span class="sd"> :keyword method: the fuzzyfication method (fuzzy: all fuzzy memberships, maximum: only the maximum membership)</span>
|
||||
<span class="sd"> :keyword mode: the fuzzyfication mode (sets: return the fuzzy sets names, vector: return a vector with the membership</span>
|
||||
<span class="sd"> values for all fuzzy sets, both: return a list with tuples (fuzzy set, membership value) )</span>
|
||||
<span class="sd"> </span>
|
||||
<span class="sd"> :returns a list with the fuzzyfied values, depending on the mode</span>
|
||||
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">alpha_cut</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'alpha_cut'</span><span class="p">,</span> <span class="mf">0.</span><span class="p">)</span>
|
||||
<span class="n">mode</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'mode'</span><span class="p">,</span> <span class="s1">'sets'</span><span class="p">)</span>
|
||||
<span class="n">method</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'method'</span><span class="p">,</span> <span class="s1">'fuzzy'</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="p">(</span><span class="nb">list</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">)):</span>
|
||||
<span class="k">if</span> <span class="n">mode</span> <span class="o">==</span> <span class="s1">'vector'</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">fuzzyfy_instances</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">partitioner</span><span class="o">.</span><span class="n">sets</span><span class="p">,</span> <span class="n">partitioner</span><span class="o">.</span><span class="n">ordered_sets</span><span class="p">)</span>
|
||||
<span class="k">elif</span> <span class="n">mode</span> <span class="o">==</span> <span class="s1">'both'</span><span class="p">:</span>
|
||||
<span class="n">mvs</span> <span class="o">=</span> <span class="n">fuzzyfy_instances</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">partitioner</span><span class="o">.</span><span class="n">sets</span><span class="p">,</span> <span class="n">partitioner</span><span class="o">.</span><span class="n">ordered_sets</span><span class="p">)</span>
|
||||
<span class="n">fs</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">mv</span> <span class="ow">in</span> <span class="n">mvs</span><span class="p">:</span>
|
||||
<span class="n">fsets</span> <span class="o">=</span> <span class="p">[(</span><span class="n">partitioner</span><span class="o">.</span><span class="n">ordered_sets</span><span class="p">[</span><span class="n">ix</span><span class="p">],</span> <span class="n">mv</span><span class="p">[</span><span class="n">ix</span><span class="p">])</span>
|
||||
<span class="k">for</span> <span class="n">ix</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">mv</span><span class="p">))</span>
|
||||
<span class="k">if</span> <span class="n">mv</span><span class="p">[</span><span class="n">ix</span><span class="p">]</span> <span class="o">>=</span> <span class="n">alpha_cut</span><span class="p">]</span>
|
||||
<span class="n">fs</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">fsets</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">fs</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">fuzzyfy_series</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">partitioner</span><span class="o">.</span><span class="n">sets</span><span class="p">,</span> <span class="n">method</span><span class="p">,</span> <span class="n">alpha_cut</span><span class="p">,</span> <span class="n">partitioner</span><span class="o">.</span><span class="n">ordered_sets</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="n">mode</span> <span class="o">==</span> <span class="s1">'vector'</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">fuzzyfy_instance</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">partitioner</span><span class="o">.</span><span class="n">sets</span><span class="p">,</span> <span class="n">partitioner</span><span class="o">.</span><span class="n">ordered_sets</span><span class="p">)</span>
|
||||
<span class="k">elif</span> <span class="n">mode</span> <span class="o">==</span> <span class="s1">'both'</span><span class="p">:</span>
|
||||
<span class="n">mv</span> <span class="o">=</span> <span class="n">fuzzyfy_instance</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">partitioner</span><span class="o">.</span><span class="n">sets</span><span class="p">,</span> <span class="n">partitioner</span><span class="o">.</span><span class="n">ordered_sets</span><span class="p">)</span>
|
||||
<span class="n">fsets</span> <span class="o">=</span> <span class="p">[(</span><span class="n">partitioner</span><span class="o">.</span><span class="n">ordered_sets</span><span class="p">[</span><span class="n">ix</span><span class="p">],</span> <span class="n">mv</span><span class="p">[</span><span class="n">ix</span><span class="p">])</span>
|
||||
<span class="k">for</span> <span class="n">ix</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">mv</span><span class="p">))</span>
|
||||
<span class="k">if</span> <span class="n">mv</span><span class="p">[</span><span class="n">ix</span><span class="p">]</span> <span class="o">>=</span> <span class="n">alpha_cut</span><span class="p">]</span>
|
||||
<span class="k">return</span> <span class="n">fsets</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">get_fuzzysets</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">partitioner</span><span class="o">.</span><span class="n">sets</span><span class="p">,</span> <span class="n">partitioner</span><span class="o">.</span><span class="n">ordered_sets</span><span class="p">,</span> <span class="n">alpha_cut</span><span class="p">)</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="set_ordered"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.FuzzySet.set_ordered">[docs]</a><span class="k">def</span> <span class="nf">set_ordered</span><span class="p">(</span><span class="n">fuzzy_sets</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Order a fuzzy set list by their centroids</span>
|
||||
|
||||
<span class="sd"> :param fuzzy_sets: a dictionary where the key is the fuzzy set name and the value is the fuzzy set object.</span>
|
||||
<span class="sd"> :return: a list with the fuzzy sets names ordered by their centroids.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">fuzzy_sets</span><span class="p">)</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span>
|
||||
<span class="n">tmp1</span> <span class="o">=</span> <span class="p">[</span><span class="n">fuzzy_sets</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">fuzzy_sets</span><span class="o">.</span><span class="n">keys</span><span class="p">()]</span>
|
||||
<span class="k">return</span> <span class="p">[</span><span class="n">k</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">tmp1</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="n">x</span><span class="o">.</span><span class="n">centroid</span><span class="p">)]</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="fuzzyfy_instance"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.FuzzySet.fuzzyfy_instance">[docs]</a><span class="k">def</span> <span class="nf">fuzzyfy_instance</span><span class="p">(</span><span class="n">inst</span><span class="p">,</span> <span class="n">fuzzy_sets</span> <span class="p">:</span> <span class="nb">dict</span> <span class="p">,</span> <span class="n">ordered_sets</span> <span class="p">:</span> <span class="nb">list</span> <span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Calculate the membership values for a data point given fuzzy sets</span>
|
||||
|
||||
<span class="sd"> :param inst: data point</span>
|
||||
<span class="sd"> :param fuzzy_sets: a dictionary where the key is the fuzzy set name and the value is the fuzzy set object.</span>
|
||||
<span class="sd"> :param ordered_sets: a list with the fuzzy sets names ordered by their centroids.</span>
|
||||
<span class="sd"> :return: array of membership values</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">ordered_sets</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">ordered_sets</span> <span class="o">=</span> <span class="n">set_ordered</span><span class="p">(</span><span class="n">fuzzy_sets</span><span class="p">)</span>
|
||||
|
||||
<span class="n">mv</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">fuzzy_sets</span><span class="p">))</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">ix</span> <span class="ow">in</span> <span class="n">__binary_search</span><span class="p">(</span><span class="n">inst</span><span class="p">,</span> <span class="n">fuzzy_sets</span><span class="p">,</span> <span class="n">ordered_sets</span><span class="p">):</span>
|
||||
<span class="n">mv</span><span class="p">[</span><span class="n">ix</span><span class="p">]</span> <span class="o">=</span> <span class="n">fuzzy_sets</span><span class="p">[</span><span class="n">ordered_sets</span><span class="p">[</span><span class="n">ix</span><span class="p">]]</span><span class="o">.</span><span class="n">membership</span><span class="p">(</span><span class="n">inst</span><span class="p">)</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">mv</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="fuzzyfy_instances"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.FuzzySet.fuzzyfy_instances">[docs]</a><span class="k">def</span> <span class="nf">fuzzyfy_instances</span><span class="p">(</span><span class="n">data</span> <span class="p">:</span> <span class="nb">list</span><span class="p">,</span> <span class="n">fuzzy_sets</span> <span class="p">:</span> <span class="nb">dict</span><span class="p">,</span> <span class="n">ordered_sets</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="nb">list</span><span class="p">:</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Calculate the membership values for a data point given fuzzy sets</span>
|
||||
|
||||
<span class="sd"> :param inst: data point</span>
|
||||
<span class="sd"> :param fuzzy_sets: a dictionary where the key is the fuzzy set name and the value is the fuzzy set object.</span>
|
||||
<span class="sd"> :param ordered_sets: a list with the fuzzy sets names ordered by their centroids.</span>
|
||||
<span class="sd"> :return: array of membership values</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">ret</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">if</span> <span class="n">ordered_sets</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">ordered_sets</span> <span class="o">=</span> <span class="n">set_ordered</span><span class="p">(</span><span class="n">fuzzy_sets</span><span class="p">)</span>
|
||||
<span class="k">for</span> <span class="n">inst</span> <span class="ow">in</span> <span class="n">data</span><span class="p">:</span>
|
||||
<span class="n">mv</span> <span class="o">=</span> <span class="n">fuzzyfy_instance</span><span class="p">(</span><span class="n">inst</span><span class="p">,</span> <span class="n">fuzzy_sets</span><span class="p">,</span> <span class="n">ordered_sets</span><span class="p">)</span>
|
||||
<span class="n">ret</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">mv</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">ret</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="get_fuzzysets"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.FuzzySet.get_fuzzysets">[docs]</a><span class="k">def</span> <span class="nf">get_fuzzysets</span><span class="p">(</span><span class="n">inst</span><span class="p">,</span> <span class="n">fuzzy_sets</span> <span class="p">:</span> <span class="nb">dict</span><span class="p">,</span> <span class="n">ordered_sets</span> <span class="p">:</span> <span class="nb">list</span> <span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">alpha_cut</span> <span class="p">:</span> <span class="nb">float</span> <span class="o">=</span><span class="mf">0.0</span><span class="p">)</span> <span class="o">-></span> <span class="nb">list</span><span class="p">:</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Return the fuzzy sets which membership value for a inst is greater than the alpha_cut</span>
|
||||
|
||||
<span class="sd"> :param inst: data point</span>
|
||||
<span class="sd"> :param fuzzy_sets: a dictionary where the key is the fuzzy set name and the value is the fuzzy set object.</span>
|
||||
<span class="sd"> :param ordered_sets: a list with the fuzzy sets names ordered by their centroids.</span>
|
||||
<span class="sd"> :param alpha_cut: Minimal membership to be considered on fuzzyfication process</span>
|
||||
<span class="sd"> :return: array of membership values</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">ordered_sets</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">ordered_sets</span> <span class="o">=</span> <span class="n">set_ordered</span><span class="p">(</span><span class="n">fuzzy_sets</span><span class="p">)</span>
|
||||
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="n">fs</span> <span class="o">=</span> <span class="p">[</span><span class="n">ordered_sets</span><span class="p">[</span><span class="n">ix</span><span class="p">]</span>
|
||||
<span class="k">for</span> <span class="n">ix</span> <span class="ow">in</span> <span class="n">__binary_search</span><span class="p">(</span><span class="n">inst</span><span class="p">,</span> <span class="n">fuzzy_sets</span><span class="p">,</span> <span class="n">ordered_sets</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">fuzzy_sets</span><span class="p">[</span><span class="n">ordered_sets</span><span class="p">[</span><span class="n">ix</span><span class="p">]]</span><span class="o">.</span><span class="n">membership</span><span class="p">(</span><span class="n">inst</span><span class="p">)</span> <span class="o">></span> <span class="n">alpha_cut</span><span class="p">]</span>
|
||||
<span class="k">return</span> <span class="n">fs</span>
|
||||
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">ex</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="n">ex</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="get_maximum_membership_fuzzyset"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.FuzzySet.get_maximum_membership_fuzzyset">[docs]</a><span class="k">def</span> <span class="nf">get_maximum_membership_fuzzyset</span><span class="p">(</span><span class="n">inst</span><span class="p">,</span> <span class="n">fuzzy_sets</span><span class="p">,</span> <span class="n">ordered_sets</span><span class="o">=</span><span class="kc">None</span><span class="p">)</span> <span class="o">-></span> <span class="n">FuzzySet</span><span class="p">:</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Fuzzify a data point, returning the fuzzy set with maximum membership value</span>
|
||||
|
||||
<span class="sd"> :param inst: data point</span>
|
||||
<span class="sd"> :param fuzzy_sets: a dictionary where the key is the fuzzy set name and the value is the fuzzy set object.</span>
|
||||
<span class="sd"> :param ordered_sets: a list with the fuzzy sets names ordered by their centroids.</span>
|
||||
<span class="sd"> :return: fuzzy set with maximum membership</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">if</span> <span class="n">ordered_sets</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">ordered_sets</span> <span class="o">=</span> <span class="n">set_ordered</span><span class="p">(</span><span class="n">fuzzy_sets</span><span class="p">)</span>
|
||||
<span class="n">mv</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="n">fuzzy_sets</span><span class="p">[</span><span class="n">key</span><span class="p">]</span><span class="o">.</span><span class="n">membership</span><span class="p">(</span><span class="n">inst</span><span class="p">)</span> <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">ordered_sets</span><span class="p">])</span>
|
||||
<span class="n">key</span> <span class="o">=</span> <span class="n">ordered_sets</span><span class="p">[</span><span class="n">np</span><span class="o">.</span><span class="n">argwhere</span><span class="p">(</span><span class="n">mv</span> <span class="o">==</span> <span class="nb">max</span><span class="p">(</span><span class="n">mv</span><span class="p">))[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">]]</span>
|
||||
<span class="k">return</span> <span class="n">fuzzy_sets</span><span class="p">[</span><span class="n">key</span><span class="p">]</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="get_maximum_membership_fuzzyset_index"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.FuzzySet.get_maximum_membership_fuzzyset_index">[docs]</a><span class="k">def</span> <span class="nf">get_maximum_membership_fuzzyset_index</span><span class="p">(</span><span class="n">inst</span><span class="p">,</span> <span class="n">fuzzy_sets</span><span class="p">)</span> <span class="o">-></span> <span class="nb">int</span><span class="p">:</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Fuzzify a data point, returning the fuzzy set with maximum membership value</span>
|
||||
|
||||
<span class="sd"> :param inst: data point</span>
|
||||
<span class="sd"> :param fuzzy_sets: dict of fuzzy sets</span>
|
||||
<span class="sd"> :return: fuzzy set with maximum membership</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">mv</span> <span class="o">=</span> <span class="n">fuzzyfy_instance</span><span class="p">(</span><span class="n">inst</span><span class="p">,</span> <span class="n">fuzzy_sets</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">argwhere</span><span class="p">(</span><span class="n">mv</span> <span class="o">==</span> <span class="nb">max</span><span class="p">(</span><span class="n">mv</span><span class="p">))[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">]</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="fuzzyfy_series_old"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.FuzzySet.fuzzyfy_series_old">[docs]</a><span class="k">def</span> <span class="nf">fuzzyfy_series_old</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">fuzzy_sets</span><span class="p">,</span> <span class="n">method</span><span class="o">=</span><span class="s1">'maximum'</span><span class="p">):</span>
|
||||
<span class="n">fts</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">data</span><span class="p">:</span>
|
||||
<span class="n">fts</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">get_maximum_membership_fuzzyset</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="n">fuzzy_sets</span><span class="p">)</span><span class="o">.</span><span class="n">name</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">fts</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="fuzzyfy_series"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.FuzzySet.fuzzyfy_series">[docs]</a><span class="k">def</span> <span class="nf">fuzzyfy_series</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">fuzzy_sets</span><span class="p">,</span> <span class="n">method</span><span class="o">=</span><span class="s1">'maximum'</span><span class="p">,</span> <span class="n">alpha_cut</span><span class="o">=</span><span class="mf">0.0</span><span class="p">,</span> <span class="n">ordered_sets</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="n">fts</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">if</span> <span class="n">ordered_sets</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">ordered_sets</span> <span class="o">=</span> <span class="n">set_ordered</span><span class="p">(</span><span class="n">fuzzy_sets</span><span class="p">)</span>
|
||||
<span class="k">for</span> <span class="n">t</span><span class="p">,</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">data</span><span class="p">):</span>
|
||||
<span class="n">mv</span> <span class="o">=</span> <span class="n">fuzzyfy_instance</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">fuzzy_sets</span><span class="p">,</span> <span class="n">ordered_sets</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">mv</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
|
||||
<span class="n">sets</span> <span class="o">=</span> <span class="n">check_bounds</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">fuzzy_sets</span><span class="o">.</span><span class="n">items</span><span class="p">(),</span> <span class="n">ordered_sets</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="n">method</span> <span class="o">==</span> <span class="s1">'fuzzy'</span><span class="p">:</span>
|
||||
<span class="n">ix</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">ravel</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">argwhere</span><span class="p">(</span><span class="n">mv</span> <span class="o">></span> <span class="n">alpha_cut</span><span class="p">))</span>
|
||||
<span class="n">sets</span> <span class="o">=</span> <span class="p">[</span><span class="n">fuzzy_sets</span><span class="p">[</span><span class="n">ordered_sets</span><span class="p">[</span><span class="n">i</span><span class="p">]]</span><span class="o">.</span><span class="n">name</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">ix</span><span class="p">]</span>
|
||||
<span class="k">elif</span> <span class="n">method</span> <span class="o">==</span> <span class="s1">'maximum'</span><span class="p">:</span>
|
||||
<span class="n">mx</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="n">mv</span><span class="p">)</span>
|
||||
<span class="n">ix</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">ravel</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">argwhere</span><span class="p">(</span><span class="n">mv</span> <span class="o">==</span> <span class="n">mx</span><span class="p">))</span>
|
||||
<span class="n">sets</span> <span class="o">=</span> <span class="n">fuzzy_sets</span><span class="p">[</span><span class="n">ordered_sets</span><span class="p">[</span><span class="n">ix</span><span class="p">[</span><span class="mi">0</span><span class="p">]]]</span><span class="o">.</span><span class="n">name</span>
|
||||
<span class="n">fts</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">sets</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">fts</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="grant_bounds"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.FuzzySet.grant_bounds">[docs]</a><span class="k">def</span> <span class="nf">grant_bounds</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">fuzzy_sets</span><span class="p">,</span> <span class="n">ordered_sets</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="n">data</span> <span class="o"><</span> <span class="n">fuzzy_sets</span><span class="p">[</span><span class="n">ordered_sets</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span><span class="o">.</span><span class="n">lower</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">fuzzy_sets</span><span class="p">[</span><span class="n">ordered_sets</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span><span class="o">.</span><span class="n">lower</span>
|
||||
<span class="k">elif</span> <span class="n">data</span> <span class="o">></span> <span class="n">fuzzy_sets</span><span class="p">[</span><span class="n">ordered_sets</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]]</span><span class="o">.</span><span class="n">upper</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">fuzzy_sets</span><span class="p">[</span><span class="n">ordered_sets</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]]</span><span class="o">.</span><span class="n">upper</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">data</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="check_bounds"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.FuzzySet.check_bounds">[docs]</a><span class="k">def</span> <span class="nf">check_bounds</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">fuzzy_sets</span><span class="p">,</span> <span class="n">ordered_sets</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="n">data</span> <span class="o"><</span> <span class="n">fuzzy_sets</span><span class="p">[</span><span class="n">ordered_sets</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span><span class="o">.</span><span class="n">lower</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">fuzzy_sets</span><span class="p">[</span><span class="n">ordered_sets</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span>
|
||||
<span class="k">elif</span> <span class="n">data</span> <span class="o">></span> <span class="n">fuzzy_sets</span><span class="p">[</span><span class="n">ordered_sets</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]]</span><span class="o">.</span><span class="n">upper</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">fuzzy_sets</span><span class="p">[</span><span class="n">ordered_sets</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]]</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="check_bounds_index"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.FuzzySet.check_bounds_index">[docs]</a><span class="k">def</span> <span class="nf">check_bounds_index</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">fuzzy_sets</span><span class="p">,</span> <span class="n">ordered_sets</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="n">data</span> <span class="o"><</span> <span class="n">fuzzy_sets</span><span class="p">[</span><span class="n">ordered_sets</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span><span class="o">.</span><span class="n">get_lower</span><span class="p">():</span>
|
||||
<span class="k">return</span> <span class="mi">0</span>
|
||||
<span class="k">elif</span> <span class="n">data</span> <span class="o">></span> <span class="n">fuzzy_sets</span><span class="p">[</span><span class="n">ordered_sets</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]]</span><span class="o">.</span><span class="n">get_upper</span><span class="p">():</span>
|
||||
<span class="k">return</span> <span class="nb">len</span><span class="p">(</span><span class="n">fuzzy_sets</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span></div>
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../index.html">
|
||||
<img class="logo" src="../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.common.FuzzySet</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,184 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.common.Membership — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../_static/jquery.js"></script>
|
||||
<script src="../../../_static/underscore.js"></script>
|
||||
<script src="../../../_static/doctools.js"></script>
|
||||
<script src="../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.common.Membership</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.common.Membership</h1><div class="highlight"><pre>
|
||||
<span></span><span class="sd">"""</span>
|
||||
<span class="sd">Membership functions for Fuzzy Sets</span>
|
||||
<span class="sd">"""</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
<span class="kn">import</span> <span class="nn">math</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS</span> <span class="kn">import</span> <span class="o">*</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="trimf"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.Membership.trimf">[docs]</a><span class="k">def</span> <span class="nf">trimf</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">parameters</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Triangular fuzzy membership function</span>
|
||||
|
||||
<span class="sd"> :param x: data point</span>
|
||||
<span class="sd"> :param parameters: a list with 3 real values</span>
|
||||
<span class="sd"> :return: the membership value of x given the parameters</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="n">xx</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">round</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">xx</span> <span class="o"><</span> <span class="n">parameters</span><span class="p">[</span><span class="mi">0</span><span class="p">]:</span>
|
||||
<span class="k">return</span> <span class="mi">0</span>
|
||||
<span class="k">elif</span> <span class="n">parameters</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o"><=</span> <span class="n">xx</span> <span class="o"><</span> <span class="n">parameters</span><span class="p">[</span><span class="mi">1</span><span class="p">]:</span>
|
||||
<span class="k">return</span> <span class="p">(</span><span class="n">x</span> <span class="o">-</span> <span class="n">parameters</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="o">/</span> <span class="p">(</span><span class="n">parameters</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">-</span> <span class="n">parameters</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
|
||||
<span class="k">elif</span> <span class="n">parameters</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o"><=</span> <span class="n">xx</span> <span class="o"><=</span> <span class="n">parameters</span><span class="p">[</span><span class="mi">2</span><span class="p">]:</span>
|
||||
<span class="k">return</span> <span class="p">(</span><span class="n">parameters</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">-</span> <span class="n">xx</span><span class="p">)</span> <span class="o">/</span> <span class="p">(</span><span class="n">parameters</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">-</span> <span class="n">parameters</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="mi">0</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="trapmf"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.Membership.trapmf">[docs]</a><span class="k">def</span> <span class="nf">trapmf</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">parameters</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Trapezoidal fuzzy membership function</span>
|
||||
|
||||
<span class="sd"> :param x: data point</span>
|
||||
<span class="sd"> :param parameters: a list with 4 real values</span>
|
||||
<span class="sd"> :return: the membership value of x given the parameters</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">x</span> <span class="o"><</span> <span class="n">parameters</span><span class="p">[</span><span class="mi">0</span><span class="p">]:</span>
|
||||
<span class="k">return</span> <span class="mi">0</span>
|
||||
<span class="k">elif</span> <span class="n">parameters</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o"><=</span> <span class="n">x</span> <span class="o"><</span> <span class="n">parameters</span><span class="p">[</span><span class="mi">1</span><span class="p">]:</span>
|
||||
<span class="k">return</span> <span class="p">(</span><span class="n">x</span> <span class="o">-</span> <span class="n">parameters</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="o">/</span> <span class="p">(</span><span class="n">parameters</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">-</span> <span class="n">parameters</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
|
||||
<span class="k">elif</span> <span class="n">parameters</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o"><=</span> <span class="n">x</span> <span class="o"><=</span> <span class="n">parameters</span><span class="p">[</span><span class="mi">2</span><span class="p">]:</span>
|
||||
<span class="k">return</span> <span class="mi">1</span>
|
||||
<span class="k">elif</span> <span class="n">parameters</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o"><=</span> <span class="n">x</span> <span class="o"><=</span> <span class="n">parameters</span><span class="p">[</span><span class="mi">3</span><span class="p">]:</span>
|
||||
<span class="k">return</span> <span class="p">(</span><span class="n">parameters</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span> <span class="o">-</span> <span class="n">x</span><span class="p">)</span> <span class="o">/</span> <span class="p">(</span><span class="n">parameters</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span> <span class="o">-</span> <span class="n">parameters</span><span class="p">[</span><span class="mi">2</span><span class="p">])</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="mi">0</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="gaussmf"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.Membership.gaussmf">[docs]</a><span class="k">def</span> <span class="nf">gaussmf</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">parameters</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Gaussian fuzzy membership function</span>
|
||||
|
||||
<span class="sd"> :param x: data point</span>
|
||||
<span class="sd"> :param parameters: a list with 2 real values (mean and variance)</span>
|
||||
<span class="sd"> :return: the membership value of x given the parameters</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">math</span><span class="o">.</span><span class="n">exp</span><span class="p">((</span><span class="o">-</span><span class="p">(</span><span class="n">x</span> <span class="o">-</span> <span class="n">parameters</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span><span class="o">**</span><span class="mi">2</span><span class="p">)</span><span class="o">/</span><span class="p">(</span><span class="mi">2</span> <span class="o">*</span> <span class="n">parameters</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">**</span><span class="mi">2</span><span class="p">))</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="bellmf"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.Membership.bellmf">[docs]</a><span class="k">def</span> <span class="nf">bellmf</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">parameters</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Bell shaped membership function</span>
|
||||
|
||||
<span class="sd"> :param x:</span>
|
||||
<span class="sd"> :param parameters:</span>
|
||||
<span class="sd"> :return:</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="k">return</span> <span class="mi">1</span> <span class="o">/</span> <span class="p">(</span><span class="mi">1</span> <span class="o">+</span> <span class="nb">abs</span><span class="p">((</span><span class="n">x</span> <span class="o">-</span> <span class="n">parameters</span><span class="p">[</span><span class="mi">2</span><span class="p">])</span> <span class="o">/</span> <span class="n">parameters</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="o">**</span> <span class="p">(</span><span class="mi">2</span> <span class="o">*</span> <span class="n">parameters</span><span class="p">[</span><span class="mi">1</span><span class="p">]))</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="sigmf"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.Membership.sigmf">[docs]</a><span class="k">def</span> <span class="nf">sigmf</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">parameters</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Sigmoid / Logistic membership function</span>
|
||||
|
||||
<span class="sd"> :param x:</span>
|
||||
<span class="sd"> :param parameters: an list with 2 real values (smoothness and midpoint)</span>
|
||||
<span class="sd"> :return</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">return</span> <span class="mi">1</span> <span class="o">/</span> <span class="p">(</span><span class="mi">1</span> <span class="o">+</span> <span class="n">math</span><span class="o">.</span><span class="n">exp</span><span class="p">(</span><span class="o">-</span><span class="n">parameters</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">*</span> <span class="p">(</span><span class="n">x</span> <span class="o">-</span> <span class="n">parameters</span><span class="p">[</span><span class="mi">1</span><span class="p">])))</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="singleton"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.Membership.singleton">[docs]</a><span class="k">def</span> <span class="nf">singleton</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">parameters</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Singleton membership function, a single value fuzzy function</span>
|
||||
|
||||
<span class="sd"> :param x:</span>
|
||||
<span class="sd"> :param parameters: a list with one real value</span>
|
||||
<span class="sd"> :returns</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">return</span> <span class="mi">1</span> <span class="k">if</span> <span class="n">x</span> <span class="o">==</span> <span class="n">parameters</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="k">else</span> <span class="mi">0</span></div>
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../index.html">
|
||||
<img class="logo" src="../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.common.Membership</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,317 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.common.SortedCollection — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../_static/jquery.js"></script>
|
||||
<script src="../../../_static/underscore.js"></script>
|
||||
<script src="../../../_static/doctools.js"></script>
|
||||
<script src="../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.common.SortedCollection</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.common.SortedCollection</h1><div class="highlight"><pre>
|
||||
<span></span><span class="kn">from</span> <span class="nn">bisect</span> <span class="kn">import</span> <span class="n">bisect_left</span><span class="p">,</span> <span class="n">bisect_right</span>
|
||||
|
||||
<span class="c1">#</span>
|
||||
<span class="c1"># Original Source Code: https://code.activestate.com/recipes/577197-sortedcollection/</span>
|
||||
<span class="c1"># Author: RAYMOND HETTINGER</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="SortedCollection"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.SortedCollection.SortedCollection">[docs]</a><span class="k">class</span> <span class="nc">SortedCollection</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">'''Sequence sorted by a key function.</span>
|
||||
|
||||
<span class="sd"> SortedCollection() is much easier to work with than using bisect() directly.</span>
|
||||
<span class="sd"> It supports key functions like those use in sorted(), min(), and max().</span>
|
||||
<span class="sd"> The result of the key function call is saved so that keys can be searched</span>
|
||||
<span class="sd"> efficiently.</span>
|
||||
|
||||
<span class="sd"> Instead of returning an insertion-point which can be hard to interpret, the</span>
|
||||
<span class="sd"> five find-methods return a specific item in the sequence. They can scan for</span>
|
||||
<span class="sd"> exact matches, the last item less-than-or-equal to a key, or the first item</span>
|
||||
<span class="sd"> greater-than-or-equal to a key.</span>
|
||||
|
||||
<span class="sd"> Once found, an item's ordinal position can be located with the index() method.</span>
|
||||
<span class="sd"> New items can be added with the insert() and insert_right() methods.</span>
|
||||
<span class="sd"> Old items can be deleted with the remove() method.</span>
|
||||
|
||||
<span class="sd"> The usual sequence methods are provided to support indexing, slicing,</span>
|
||||
<span class="sd"> length lookup, clearing, copying, forward and reverse iteration, contains</span>
|
||||
<span class="sd"> checking, item counts, item removal, and a nice looking repr.</span>
|
||||
|
||||
<span class="sd"> Finding and indexing are O(log n) operations while iteration and insertion</span>
|
||||
<span class="sd"> are O(n). The initial sort is O(n log n).</span>
|
||||
|
||||
<span class="sd"> The key function is stored in the 'key' attibute for easy introspection or</span>
|
||||
<span class="sd"> so that you can assign a new key function (triggering an automatic re-sort).</span>
|
||||
|
||||
<span class="sd"> In short, the class was designed to handle all of the common use cases for</span>
|
||||
<span class="sd"> bisect but with a simpler API and support for key functions.</span>
|
||||
|
||||
<span class="sd"> >>> from pprint import pprint</span>
|
||||
<span class="sd"> >>> from operator import itemgetter</span>
|
||||
|
||||
<span class="sd"> >>> s = SortedCollection(key=itemgetter(2))</span>
|
||||
<span class="sd"> >>> for record in [</span>
|
||||
<span class="sd"> ... ('roger', 'young', 30),</span>
|
||||
<span class="sd"> ... ('angela', 'jones', 28),</span>
|
||||
<span class="sd"> ... ('bill', 'smith', 22),</span>
|
||||
<span class="sd"> ... ('david', 'thomas', 32)]:</span>
|
||||
<span class="sd"> ... s.insert(record)</span>
|
||||
|
||||
<span class="sd"> >>> pprint(list(s)) # show records sorted by age</span>
|
||||
<span class="sd"> [('bill', 'smith', 22),</span>
|
||||
<span class="sd"> ('angela', 'jones', 28),</span>
|
||||
<span class="sd"> ('roger', 'young', 30),</span>
|
||||
<span class="sd"> ('david', 'thomas', 32)]</span>
|
||||
|
||||
<span class="sd"> >>> s.find_le(29) # find oldest person aged 29 or younger</span>
|
||||
<span class="sd"> ('angela', 'jones', 28)</span>
|
||||
<span class="sd"> >>> s.find_lt(28) # find oldest person under 28</span>
|
||||
<span class="sd"> ('bill', 'smith', 22)</span>
|
||||
<span class="sd"> >>> s.find_gt(28) # find youngest person over 28</span>
|
||||
<span class="sd"> ('roger', 'young', 30)</span>
|
||||
|
||||
<span class="sd"> >>> r = s.find_ge(32) # find youngest person aged 32 or older</span>
|
||||
<span class="sd"> >>> s.index(r) # get the index of their record</span>
|
||||
<span class="sd"> 3</span>
|
||||
<span class="sd"> >>> s[3] # fetch the record at that index</span>
|
||||
<span class="sd"> ('david', 'thomas', 32)</span>
|
||||
|
||||
<span class="sd"> >>> s.key = itemgetter(0) # now sort by first name</span>
|
||||
<span class="sd"> >>> pprint(list(s))</span>
|
||||
<span class="sd"> [('angela', 'jones', 28),</span>
|
||||
<span class="sd"> ('bill', 'smith', 22),</span>
|
||||
<span class="sd"> ('david', 'thomas', 32),</span>
|
||||
<span class="sd"> ('roger', 'young', 30)]</span>
|
||||
|
||||
<span class="sd"> '''</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">iterable</span><span class="o">=</span><span class="p">(),</span> <span class="n">key</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_given_key</span> <span class="o">=</span> <span class="n">key</span>
|
||||
<span class="n">key</span> <span class="o">=</span> <span class="p">(</span><span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="n">x</span><span class="p">)</span> <span class="k">if</span> <span class="n">key</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">key</span>
|
||||
<span class="n">decorated</span> <span class="o">=</span> <span class="nb">sorted</span><span class="p">((</span><span class="n">key</span><span class="p">(</span><span class="n">item</span><span class="p">),</span> <span class="n">item</span><span class="p">)</span> <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">iterable</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_keys</span> <span class="o">=</span> <span class="p">[</span><span class="n">k</span> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">decorated</span><span class="p">]</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_items</span> <span class="o">=</span> <span class="p">[</span><span class="n">item</span> <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">decorated</span><span class="p">]</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_key</span> <span class="o">=</span> <span class="n">key</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_getkey</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_key</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_setkey</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">key</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="n">key</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_key</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_items</span><span class="p">,</span> <span class="n">key</span><span class="o">=</span><span class="n">key</span><span class="p">)</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">_delkey</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_setkey</span><span class="p">(</span><span class="kc">None</span><span class="p">)</span>
|
||||
|
||||
<span class="n">key</span> <span class="o">=</span> <span class="nb">property</span><span class="p">(</span><span class="n">_getkey</span><span class="p">,</span> <span class="n">_setkey</span><span class="p">,</span> <span class="n">_delkey</span><span class="p">,</span> <span class="s1">'key function'</span><span class="p">)</span>
|
||||
|
||||
<div class="viewcode-block" id="SortedCollection.clear"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.SortedCollection.SortedCollection.clear">[docs]</a> <span class="k">def</span> <span class="nf">clear</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="fm">__init__</span><span class="p">([],</span> <span class="bp">self</span><span class="o">.</span><span class="n">_key</span><span class="p">)</span></div>
|
||||
|
||||
<div class="viewcode-block" id="SortedCollection.copy"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.SortedCollection.SortedCollection.copy">[docs]</a> <span class="k">def</span> <span class="nf">copy</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_key</span><span class="p">)</span></div>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__len__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_items</span><span class="p">)</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__getitem__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">i</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_items</span><span class="p">[</span><span class="n">i</span><span class="p">]</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__iter__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="nb">iter</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_items</span><span class="p">)</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__reversed__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="nb">reversed</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_items</span><span class="p">)</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="s1">'</span><span class="si">%s</span><span class="s1">(</span><span class="si">%r</span><span class="s1">, key=</span><span class="si">%s</span><span class="s1">)'</span> <span class="o">%</span> <span class="p">(</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="o">.</span><span class="vm">__name__</span><span class="p">,</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_items</span><span class="p">,</span>
|
||||
<span class="nb">getattr</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_given_key</span><span class="p">,</span> <span class="s1">'__name__'</span><span class="p">,</span> <span class="nb">repr</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_given_key</span><span class="p">))</span>
|
||||
<span class="p">)</span>
|
||||
|
||||
<span class="k">def</span> <span class="nf">__reduce__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="vm">__class__</span><span class="p">,</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_items</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_given_key</span><span class="p">)</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__contains__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">item</span><span class="p">):</span>
|
||||
<span class="n">k</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_key</span><span class="p">(</span><span class="n">item</span><span class="p">)</span>
|
||||
<span class="n">i</span> <span class="o">=</span> <span class="n">bisect_left</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_keys</span><span class="p">,</span> <span class="n">k</span><span class="p">)</span>
|
||||
<span class="n">j</span> <span class="o">=</span> <span class="n">bisect_right</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_keys</span><span class="p">,</span> <span class="n">k</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">item</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_items</span><span class="p">[</span><span class="n">i</span><span class="p">:</span><span class="n">j</span><span class="p">]</span>
|
||||
|
||||
<div class="viewcode-block" id="SortedCollection.index"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.SortedCollection.SortedCollection.index">[docs]</a> <span class="k">def</span> <span class="nf">index</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">item</span><span class="p">):</span>
|
||||
<span class="s1">'Find the position of an item. Raise ValueError if not found.'</span>
|
||||
<span class="n">k</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_key</span><span class="p">(</span><span class="n">item</span><span class="p">)</span>
|
||||
<span class="n">i</span> <span class="o">=</span> <span class="n">bisect_left</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_keys</span><span class="p">,</span> <span class="n">k</span><span class="p">)</span>
|
||||
<span class="n">j</span> <span class="o">=</span> <span class="n">bisect_right</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_keys</span><span class="p">,</span> <span class="n">k</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_items</span><span class="p">[</span><span class="n">i</span><span class="p">:</span><span class="n">j</span><span class="p">]</span><span class="o">.</span><span class="n">index</span><span class="p">(</span><span class="n">item</span><span class="p">)</span> <span class="o">+</span> <span class="n">i</span></div>
|
||||
|
||||
<div class="viewcode-block" id="SortedCollection.count"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.SortedCollection.SortedCollection.count">[docs]</a> <span class="k">def</span> <span class="nf">count</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">item</span><span class="p">):</span>
|
||||
<span class="s1">'Return number of occurrences of item'</span>
|
||||
<span class="n">k</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_key</span><span class="p">(</span><span class="n">item</span><span class="p">)</span>
|
||||
<span class="n">i</span> <span class="o">=</span> <span class="n">bisect_left</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_keys</span><span class="p">,</span> <span class="n">k</span><span class="p">)</span>
|
||||
<span class="n">j</span> <span class="o">=</span> <span class="n">bisect_right</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_keys</span><span class="p">,</span> <span class="n">k</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_items</span><span class="p">[</span><span class="n">i</span><span class="p">:</span><span class="n">j</span><span class="p">]</span><span class="o">.</span><span class="n">count</span><span class="p">(</span><span class="n">item</span><span class="p">)</span></div>
|
||||
|
||||
<div class="viewcode-block" id="SortedCollection.insert"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.SortedCollection.SortedCollection.insert">[docs]</a> <span class="k">def</span> <span class="nf">insert</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">item</span><span class="p">):</span>
|
||||
<span class="s1">'Insert a new item. If equal keys are found, add to the left'</span>
|
||||
<span class="n">k</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_key</span><span class="p">(</span><span class="n">item</span><span class="p">)</span>
|
||||
<span class="n">i</span> <span class="o">=</span> <span class="n">bisect_left</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_keys</span><span class="p">,</span> <span class="n">k</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_keys</span><span class="o">.</span><span class="n">insert</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">k</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_items</span><span class="o">.</span><span class="n">insert</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">item</span><span class="p">)</span></div>
|
||||
|
||||
<div class="viewcode-block" id="SortedCollection.insert_right"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.SortedCollection.SortedCollection.insert_right">[docs]</a> <span class="k">def</span> <span class="nf">insert_right</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">item</span><span class="p">):</span>
|
||||
<span class="s1">'Insert a new item. If equal keys are found, add to the right'</span>
|
||||
<span class="n">k</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_key</span><span class="p">(</span><span class="n">item</span><span class="p">)</span>
|
||||
<span class="n">i</span> <span class="o">=</span> <span class="n">bisect_right</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_keys</span><span class="p">,</span> <span class="n">k</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_keys</span><span class="o">.</span><span class="n">insert</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">k</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">_items</span><span class="o">.</span><span class="n">insert</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">item</span><span class="p">)</span></div>
|
||||
|
||||
<div class="viewcode-block" id="SortedCollection.remove"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.SortedCollection.SortedCollection.remove">[docs]</a> <span class="k">def</span> <span class="nf">remove</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">item</span><span class="p">):</span>
|
||||
<span class="s1">'Remove first occurence of item. Raise ValueError if not found'</span>
|
||||
<span class="n">i</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">index</span><span class="p">(</span><span class="n">item</span><span class="p">)</span>
|
||||
<span class="k">del</span> <span class="bp">self</span><span class="o">.</span><span class="n">_keys</span><span class="p">[</span><span class="n">i</span><span class="p">]</span>
|
||||
<span class="k">del</span> <span class="bp">self</span><span class="o">.</span><span class="n">_items</span><span class="p">[</span><span class="n">i</span><span class="p">]</span></div>
|
||||
|
||||
<div class="viewcode-block" id="SortedCollection.find"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.SortedCollection.SortedCollection.find">[docs]</a> <span class="k">def</span> <span class="nf">find</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">k</span><span class="p">):</span>
|
||||
<span class="s1">'Return first item with a key == k. Raise ValueError if not found.'</span>
|
||||
<span class="n">i</span> <span class="o">=</span> <span class="n">bisect_left</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_keys</span><span class="p">,</span> <span class="n">k</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">i</span> <span class="o">!=</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_keys</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">==</span> <span class="n">k</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_items</span><span class="p">[</span><span class="n">i</span><span class="p">]</span>
|
||||
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">'No item found with key equal to: </span><span class="si">%r</span><span class="s1">'</span> <span class="o">%</span> <span class="p">(</span><span class="n">k</span><span class="p">,))</span></div>
|
||||
|
||||
<div class="viewcode-block" id="SortedCollection.find_le"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.SortedCollection.SortedCollection.find_le">[docs]</a> <span class="k">def</span> <span class="nf">find_le</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">k</span><span class="p">):</span>
|
||||
<span class="s1">'Return last item with a key <= k. Raise ValueError if not found.'</span>
|
||||
<span class="n">i</span> <span class="o">=</span> <span class="n">bisect_right</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_keys</span><span class="p">,</span> <span class="n">k</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">i</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_items</span><span class="p">[</span><span class="n">i</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
|
||||
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">'No item found with key at or below: </span><span class="si">%r</span><span class="s1">'</span> <span class="o">%</span> <span class="p">(</span><span class="n">k</span><span class="p">,))</span></div>
|
||||
|
||||
<div class="viewcode-block" id="SortedCollection.find_lt"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.SortedCollection.SortedCollection.find_lt">[docs]</a> <span class="k">def</span> <span class="nf">find_lt</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">k</span><span class="p">):</span>
|
||||
<span class="s1">'Return last item with a key < k. Raise ValueError if not found.'</span>
|
||||
<span class="n">i</span> <span class="o">=</span> <span class="n">bisect_left</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_keys</span><span class="p">,</span> <span class="n">k</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">i</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_items</span><span class="p">[</span><span class="n">i</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
|
||||
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">'No item found with key below: </span><span class="si">%r</span><span class="s1">'</span> <span class="o">%</span> <span class="p">(</span><span class="n">k</span><span class="p">,))</span></div>
|
||||
|
||||
<div class="viewcode-block" id="SortedCollection.find_ge"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.SortedCollection.SortedCollection.find_ge">[docs]</a> <span class="k">def</span> <span class="nf">find_ge</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">k</span><span class="p">):</span>
|
||||
<span class="s1">'Return first item with a key >= equal to k. Raise ValueError if not found'</span>
|
||||
<span class="n">i</span> <span class="o">=</span> <span class="n">bisect_left</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_keys</span><span class="p">,</span> <span class="n">k</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">i</span> <span class="o">!=</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_items</span><span class="p">[</span><span class="n">i</span><span class="p">]</span>
|
||||
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">'No item found with key at or above: </span><span class="si">%r</span><span class="s1">'</span> <span class="o">%</span> <span class="p">(</span><span class="n">k</span><span class="p">,))</span></div>
|
||||
|
||||
<div class="viewcode-block" id="SortedCollection.find_gt"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.SortedCollection.SortedCollection.find_gt">[docs]</a> <span class="k">def</span> <span class="nf">find_gt</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">k</span><span class="p">):</span>
|
||||
<span class="s1">'Return first item with a key > k. Raise ValueError if not found'</span>
|
||||
<span class="n">i</span> <span class="o">=</span> <span class="n">bisect_right</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_keys</span><span class="p">,</span> <span class="n">k</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">i</span> <span class="o">!=</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_items</span><span class="p">[</span><span class="n">i</span><span class="p">]</span>
|
||||
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">'No item found with key above: </span><span class="si">%r</span><span class="s1">'</span> <span class="o">%</span> <span class="p">(</span><span class="n">k</span><span class="p">,))</span></div>
|
||||
|
||||
<div class="viewcode-block" id="SortedCollection.between"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.SortedCollection.SortedCollection.between">[docs]</a> <span class="k">def</span> <span class="nf">between</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ge</span><span class="p">,</span> <span class="n">le</span><span class="p">):</span>
|
||||
<span class="n">g</span> <span class="o">=</span> <span class="n">bisect_left</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_keys</span><span class="p">,</span> <span class="n">ge</span><span class="p">)</span>
|
||||
<span class="n">l</span> <span class="o">=</span> <span class="n">bisect_right</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_keys</span><span class="p">,</span> <span class="n">le</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">g</span> <span class="o">!=</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="ow">and</span> <span class="n">l</span> <span class="o">!=</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_items</span><span class="p">[</span><span class="n">g</span> <span class="p">:</span> <span class="n">l</span><span class="p">]</span>
|
||||
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">'No item found between keys : </span><span class="si">%r</span><span class="s1">,</span><span class="si">%r</span><span class="s1">'</span> <span class="o">%</span> <span class="p">(</span><span class="n">ge</span><span class="p">,</span><span class="n">le</span><span class="p">))</span></div>
|
||||
|
||||
<div class="viewcode-block" id="SortedCollection.inside"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.SortedCollection.SortedCollection.inside">[docs]</a> <span class="k">def</span> <span class="nf">inside</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ge</span><span class="p">,</span> <span class="n">le</span><span class="p">):</span>
|
||||
<span class="n">l</span> <span class="o">=</span> <span class="n">bisect_right</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_keys</span><span class="p">,</span> <span class="n">le</span><span class="p">)</span>
|
||||
<span class="n">g</span> <span class="o">=</span> <span class="n">bisect_left</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_keys</span><span class="p">,</span> <span class="n">ge</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">g</span> <span class="o">!=</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="ow">and</span> <span class="n">l</span> <span class="o">!=</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="ow">and</span> <span class="n">g</span> <span class="o">!=</span> <span class="n">l</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_items</span><span class="p">[</span><span class="n">g</span> <span class="p">:</span> <span class="n">l</span><span class="p">]</span>
|
||||
<span class="k">elif</span> <span class="n">g</span> <span class="o">!=</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="ow">and</span> <span class="n">l</span> <span class="o">!=</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="ow">and</span> <span class="n">g</span> <span class="o">==</span> <span class="n">l</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="p">[</span> <span class="bp">self</span><span class="o">.</span><span class="n">_items</span><span class="p">[</span><span class="n">g</span><span class="p">]</span> <span class="p">]</span>
|
||||
<span class="k">elif</span> <span class="n">g</span> <span class="o">!=</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_items</span><span class="p">[</span><span class="n">g</span><span class="o">-</span><span class="mi">1</span><span class="p">:</span> <span class="n">l</span><span class="p">]</span>
|
||||
<span class="k">elif</span> <span class="n">l</span> <span class="o">!=</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_items</span><span class="p">[</span><span class="n">g</span><span class="p">:</span> <span class="n">l</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_items</span><span class="p">[</span><span class="n">g</span> <span class="o">-</span> <span class="mi">1</span><span class="p">:</span> <span class="n">l</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span>
|
||||
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">'No item found inside keys: </span><span class="si">%r</span><span class="s1">,</span><span class="si">%r</span><span class="s1">'</span> <span class="o">%</span> <span class="p">(</span><span class="n">ge</span><span class="p">,</span><span class="n">le</span><span class="p">))</span></div>
|
||||
|
||||
<div class="viewcode-block" id="SortedCollection.around"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.SortedCollection.SortedCollection.around">[docs]</a> <span class="k">def</span> <span class="nf">around</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">k</span><span class="p">):</span>
|
||||
<span class="n">g</span> <span class="o">=</span> <span class="n">bisect_right</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_keys</span><span class="p">,</span> <span class="n">k</span><span class="p">)</span>
|
||||
<span class="n">l</span> <span class="o">=</span> <span class="n">bisect_left</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_keys</span><span class="p">,</span> <span class="n">k</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">g</span> <span class="o">!=</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="ow">and</span> <span class="n">l</span> <span class="o">!=</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_items</span><span class="p">[</span><span class="n">g</span> <span class="p">:</span> <span class="n">l</span><span class="p">]</span>
|
||||
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">'No item found around key : </span><span class="si">%r</span><span class="s1">'</span> <span class="o">%</span> <span class="p">(</span><span class="n">k</span><span class="p">,))</span></div></div>
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../index.html">
|
||||
<img class="logo" src="../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.common.SortedCollection</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
204
docs/build/html/_modules/pyFTS/common/flrg.html
vendored
204
docs/build/html/_modules/pyFTS/common/flrg.html
vendored
@ -1,204 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.common.flrg — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../_static/jquery.js"></script>
|
||||
<script src="../../../_static/underscore.js"></script>
|
||||
<script src="../../../_static/doctools.js"></script>
|
||||
<script src="../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.common.flrg</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.common.flrg</h1><div class="highlight"><pre>
|
||||
<span></span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="FLRG"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.flrg.FLRG">[docs]</a><span class="k">class</span> <span class="nc">FLRG</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Fuzzy Logical Relationship Group</span>
|
||||
|
||||
<span class="sd"> Group a set of FLR's with the same LHS. Represents the temporal patterns for time t+1 (the RHS fuzzy sets)</span>
|
||||
<span class="sd"> when the LHS pattern is identified on time t.</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">order</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">LHS</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
<span class="w"> </span><span class="sd">"""Left Hand Side of the rule"""</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">RHS</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
<span class="w"> </span><span class="sd">"""Right Hand Side of the rule"""</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">order</span> <span class="o">=</span> <span class="n">order</span>
|
||||
<span class="w"> </span><span class="sd">"""Number of lags on LHS"""</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">midpoint</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">lower</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">upper</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">key</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
|
||||
<div class="viewcode-block" id="FLRG.append_rhs"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.flrg.FLRG.append_rhs">[docs]</a> <span class="k">def</span> <span class="nf">append_rhs</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="nb">set</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="k">pass</span></div>
|
||||
|
||||
<div class="viewcode-block" id="FLRG.get_key"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.flrg.FLRG.get_key">[docs]</a> <span class="k">def</span> <span class="nf">get_key</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""Returns a unique identifier for this FLRG"""</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">key</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">LHS</span><span class="p">,</span> <span class="p">(</span><span class="nb">list</span><span class="p">,</span> <span class="nb">set</span><span class="p">)):</span>
|
||||
<span class="n">names</span> <span class="o">=</span> <span class="p">[</span><span class="n">c</span> <span class="k">for</span> <span class="n">c</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">LHS</span><span class="p">]</span>
|
||||
<span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">LHS</span><span class="p">,</span> <span class="nb">dict</span><span class="p">):</span>
|
||||
<span class="n">names</span> <span class="o">=</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">LHS</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">LHS</span><span class="o">.</span><span class="n">keys</span><span class="p">()]</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">names</span> <span class="o">=</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">LHS</span><span class="p">]</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">key</span> <span class="o">=</span> <span class="s2">""</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">n</span> <span class="ow">in</span> <span class="n">names</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">key</span><span class="p">)</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">key</span> <span class="o">+=</span> <span class="s2">","</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">key</span> <span class="o">+=</span> <span class="n">n</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">key</span></div>
|
||||
|
||||
<div class="viewcode-block" id="FLRG.get_membership"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.flrg.FLRG.get_membership">[docs]</a> <span class="k">def</span> <span class="nf">get_membership</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">sets</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Returns the membership value of the FLRG for the input data</span>
|
||||
|
||||
<span class="sd"> :param data: input data</span>
|
||||
<span class="sd"> :param sets: fuzzy sets</span>
|
||||
<span class="sd"> :return: the membership value</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">ret</span> <span class="o">=</span> <span class="mf">0.0</span>
|
||||
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">LHS</span><span class="p">,</span> <span class="p">(</span><span class="nb">list</span><span class="p">,</span> <span class="nb">set</span><span class="p">)):</span>
|
||||
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">LHS</span><span class="p">)</span> <span class="o">==</span> <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">):</span>
|
||||
<span class="n">ret</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">nanmin</span><span class="p">([</span><span class="n">sets</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">LHS</span><span class="p">[</span><span class="n">ct</span><span class="p">]]</span><span class="o">.</span><span class="n">membership</span><span class="p">(</span><span class="n">dat</span><span class="p">)</span> <span class="k">for</span> <span class="n">ct</span><span class="p">,</span> <span class="n">dat</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">data</span><span class="p">)])</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">ret</span> <span class="o">=</span> <span class="n">sets</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">LHS</span><span class="p">]</span><span class="o">.</span><span class="n">membership</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">ret</span></div>
|
||||
|
||||
<div class="viewcode-block" id="FLRG.get_midpoint"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.flrg.FLRG.get_midpoint">[docs]</a> <span class="k">def</span> <span class="nf">get_midpoint</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sets</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Returns the midpoint value for the RHS fuzzy sets</span>
|
||||
|
||||
<span class="sd"> :param sets: fuzzy sets</span>
|
||||
<span class="sd"> :return: the midpoint value</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">midpoint</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">midpoint</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">nanmean</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">get_midpoints</span><span class="p">(</span><span class="n">sets</span><span class="p">))</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">midpoint</span></div>
|
||||
|
||||
<div class="viewcode-block" id="FLRG.get_midpoints"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.flrg.FLRG.get_midpoints">[docs]</a> <span class="k">def</span> <span class="nf">get_midpoints</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sets</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="p">,</span> <span class="p">(</span><span class="nb">list</span><span class="p">,</span> <span class="nb">set</span><span class="p">)):</span>
|
||||
<span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="n">sets</span><span class="p">[</span><span class="n">s</span><span class="p">]</span><span class="o">.</span><span class="n">centroid</span> <span class="k">for</span> <span class="n">s</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="p">])</span>
|
||||
<span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="p">,</span> <span class="nb">dict</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="n">sets</span><span class="p">[</span><span class="n">s</span><span class="p">]</span><span class="o">.</span><span class="n">centroid</span> <span class="k">for</span> <span class="n">s</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="o">.</span><span class="n">keys</span><span class="p">()])</span></div>
|
||||
|
||||
<div class="viewcode-block" id="FLRG.get_lower"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.flrg.FLRG.get_lower">[docs]</a> <span class="k">def</span> <span class="nf">get_lower</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sets</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Returns the lower bound value for the RHS fuzzy sets</span>
|
||||
|
||||
<span class="sd"> :param sets: fuzzy sets</span>
|
||||
<span class="sd"> :return: lower bound value</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">lower</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">lower</span> <span class="o">=</span> <span class="nb">min</span><span class="p">([</span><span class="n">sets</span><span class="p">[</span><span class="n">rhs</span><span class="p">]</span><span class="o">.</span><span class="n">lower</span> <span class="k">for</span> <span class="n">rhs</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="p">])</span>
|
||||
<span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="p">,</span> <span class="nb">dict</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">lower</span> <span class="o">=</span> <span class="nb">min</span><span class="p">([</span><span class="n">sets</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="p">[</span><span class="n">s</span><span class="p">]]</span><span class="o">.</span><span class="n">lower</span> <span class="k">for</span> <span class="n">s</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="o">.</span><span class="n">keys</span><span class="p">()])</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">lower</span></div>
|
||||
|
||||
<div class="viewcode-block" id="FLRG.get_upper"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.flrg.FLRG.get_upper">[docs]</a> <span class="k">def</span> <span class="nf">get_upper</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sets</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Returns the upper bound value for the RHS fuzzy sets</span>
|
||||
|
||||
<span class="sd"> :param sets: fuzzy sets</span>
|
||||
<span class="sd"> :return: upper bound value</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">upper</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">upper</span> <span class="o">=</span> <span class="nb">max</span><span class="p">([</span><span class="n">sets</span><span class="p">[</span><span class="n">rhs</span><span class="p">]</span><span class="o">.</span><span class="n">upper</span> <span class="k">for</span> <span class="n">rhs</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="p">])</span>
|
||||
<span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="p">,</span> <span class="nb">dict</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">upper</span> <span class="o">=</span> <span class="nb">max</span><span class="p">([</span><span class="n">sets</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="p">[</span><span class="n">s</span><span class="p">]]</span><span class="o">.</span><span class="n">upper</span> <span class="k">for</span> <span class="n">s</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="o">.</span><span class="n">keys</span><span class="p">()])</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">upper</span></div>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__len__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="p">)</span>
|
||||
|
||||
<div class="viewcode-block" id="FLRG.reset_calculated_values"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.flrg.FLRG.reset_calculated_values">[docs]</a> <span class="k">def</span> <span class="nf">reset_calculated_values</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">midpoint</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">upper</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">lower</span> <span class="o">=</span> <span class="kc">None</span></div></div>
|
||||
|
||||
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../index.html">
|
||||
<img class="logo" src="../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.common.flrg</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,122 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.common.transformations.boxcox — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../../" id="documentation_options" src="../../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../../_static/jquery.js"></script>
|
||||
<script src="../../../../_static/underscore.js"></script>
|
||||
<script src="../../../../_static/doctools.js"></script>
|
||||
<script src="../../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.common.transformations.boxcox</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.common.transformations.boxcox</h1><div class="highlight"><pre>
|
||||
<span></span><span class="kn">from</span> <span class="nn">pyFTS.common.transformations.transformation</span> <span class="kn">import</span> <span class="n">Transformation</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="BoxCox"><a class="viewcode-back" href="../../../../pyFTS.common.transformations.html#pyFTS.common.transformations.boxcox.BoxCox">[docs]</a><span class="k">class</span> <span class="nc">BoxCox</span><span class="p">(</span><span class="n">Transformation</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Box-Cox power transformation</span>
|
||||
|
||||
<span class="sd"> y'(t) = log( y(t) )</span>
|
||||
<span class="sd"> y(t) = exp( y'(t) )</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">plambda</span><span class="p">):</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">BoxCox</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">()</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">plambda</span> <span class="o">=</span> <span class="n">plambda</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="s1">'BoxCox'</span>
|
||||
|
||||
<span class="nd">@property</span>
|
||||
<span class="k">def</span> <span class="nf">parameters</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">plambda</span>
|
||||
|
||||
<div class="viewcode-block" id="BoxCox.apply"><a class="viewcode-back" href="../../../../pyFTS.common.transformations.html#pyFTS.common.transformations.boxcox.BoxCox.apply">[docs]</a> <span class="k">def</span> <span class="nf">apply</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">param</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">plambda</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">:</span>
|
||||
<span class="n">modified</span> <span class="o">=</span> <span class="p">[(</span><span class="n">dat</span> <span class="o">**</span> <span class="bp">self</span><span class="o">.</span><span class="n">plambda</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> <span class="o">/</span> <span class="bp">self</span><span class="o">.</span><span class="n">plambda</span> <span class="k">for</span> <span class="n">dat</span> <span class="ow">in</span> <span class="n">data</span><span class="p">]</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">modified</span> <span class="o">=</span> <span class="p">[</span><span class="n">np</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">dat</span><span class="p">)</span> <span class="k">for</span> <span class="n">dat</span> <span class="ow">in</span> <span class="n">data</span><span class="p">]</span>
|
||||
<span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">modified</span><span class="p">)</span></div>
|
||||
|
||||
<div class="viewcode-block" id="BoxCox.inverse"><a class="viewcode-back" href="../../../../pyFTS.common.transformations.html#pyFTS.common.transformations.boxcox.BoxCox.inverse">[docs]</a> <span class="k">def</span> <span class="nf">inverse</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">param</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">plambda</span> <span class="o">!=</span> <span class="mi">0</span><span class="p">:</span>
|
||||
<span class="n">modified</span> <span class="o">=</span> <span class="p">[</span><span class="n">np</span><span class="o">.</span><span class="n">exp</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">dat</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">plambda</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span> <span class="p">)</span> <span class="o">/</span> <span class="bp">self</span><span class="o">.</span><span class="n">plambda</span> <span class="k">for</span> <span class="n">dat</span> <span class="ow">in</span> <span class="n">data</span><span class="p">]</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">modified</span> <span class="o">=</span> <span class="p">[</span><span class="n">np</span><span class="o">.</span><span class="n">exp</span><span class="p">(</span><span class="n">dat</span><span class="p">)</span> <span class="k">for</span> <span class="n">dat</span> <span class="ow">in</span> <span class="n">data</span><span class="p">]</span>
|
||||
<span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">modified</span><span class="p">)</span></div></div>
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../../index.html">
|
||||
<img class="logo" src="../../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.common.transformations.boxcox</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,171 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.common.transformations.differential — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../../" id="documentation_options" src="../../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../../_static/jquery.js"></script>
|
||||
<script src="../../../../_static/underscore.js"></script>
|
||||
<script src="../../../../_static/doctools.js"></script>
|
||||
<script src="../../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.common.transformations.differential</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.common.transformations.differential</h1><div class="highlight"><pre>
|
||||
<span></span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.common.transformations.transformation</span> <span class="kn">import</span> <span class="n">Transformation</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="Differential"><a class="viewcode-back" href="../../../../pyFTS.common.transformations.html#pyFTS.common.transformations.differential.Differential">[docs]</a><span class="k">class</span> <span class="nc">Differential</span><span class="p">(</span><span class="n">Transformation</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Differentiation data transform</span>
|
||||
|
||||
<span class="sd"> y'(t) = y(t) - y(t-1)</span>
|
||||
<span class="sd"> y(t) = y(t-1) + y'(t)</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">lag</span><span class="p">):</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">Differential</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">()</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">lag</span> <span class="o">=</span> <span class="n">lag</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">minimal_length</span> <span class="o">=</span> <span class="mi">2</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="s1">'Diff'</span>
|
||||
|
||||
<span class="nd">@property</span>
|
||||
<span class="k">def</span> <span class="nf">parameters</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">lag</span>
|
||||
|
||||
<div class="viewcode-block" id="Differential.apply"><a class="viewcode-back" href="../../../../pyFTS.common.transformations.html#pyFTS.common.transformations.differential.Differential.apply">[docs]</a> <span class="k">def</span> <span class="nf">apply</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">param</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="n">param</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">lag</span> <span class="o">=</span> <span class="n">param</span>
|
||||
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="p">(</span><span class="nb">list</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">generic</span><span class="p">)):</span>
|
||||
<span class="n">data</span> <span class="o">=</span> <span class="p">[</span><span class="n">data</span><span class="p">]</span>
|
||||
|
||||
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">generic</span><span class="p">)):</span>
|
||||
<span class="n">data</span> <span class="o">=</span> <span class="n">data</span><span class="o">.</span><span class="n">tolist</span><span class="p">()</span>
|
||||
|
||||
<span class="n">n</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
|
||||
<span class="n">diff</span> <span class="o">=</span> <span class="p">[</span><span class="n">data</span><span class="p">[</span><span class="n">t</span><span class="p">]</span> <span class="o">-</span> <span class="n">data</span><span class="p">[</span><span class="n">t</span> <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">lag</span><span class="p">]</span> <span class="k">for</span> <span class="n">t</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">lag</span><span class="p">,</span> <span class="n">n</span><span class="p">)]</span>
|
||||
<span class="k">for</span> <span class="n">t</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">lag</span><span class="p">):</span> <span class="n">diff</span><span class="o">.</span><span class="n">insert</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">diff</span></div>
|
||||
|
||||
<div class="viewcode-block" id="Differential.inverse"><a class="viewcode-back" href="../../../../pyFTS.common.transformations.html#pyFTS.common.transformations.differential.Differential.inverse">[docs]</a> <span class="k">def</span> <span class="nf">inverse</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">param</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
|
||||
<span class="nb">type</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"type"</span><span class="p">,</span><span class="s2">"point"</span><span class="p">)</span>
|
||||
<span class="n">steps_ahead</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"steps_ahead"</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">generic</span><span class="p">)):</span>
|
||||
<span class="n">data</span> <span class="o">=</span> <span class="n">data</span><span class="o">.</span><span class="n">tolist</span><span class="p">()</span>
|
||||
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span>
|
||||
<span class="n">data</span> <span class="o">=</span> <span class="p">[</span><span class="n">data</span><span class="p">]</span>
|
||||
|
||||
<span class="n">n</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># print(n)</span>
|
||||
<span class="c1"># print(len(param))</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">steps_ahead</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="nb">type</span> <span class="o">==</span> <span class="s2">"point"</span><span class="p">:</span>
|
||||
<span class="n">inc</span> <span class="o">=</span> <span class="p">[</span><span class="n">data</span><span class="p">[</span><span class="n">t</span><span class="p">]</span> <span class="o">+</span> <span class="n">param</span><span class="p">[</span><span class="n">t</span><span class="p">]</span> <span class="k">for</span> <span class="n">t</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">n</span><span class="p">)]</span>
|
||||
<span class="k">elif</span> <span class="nb">type</span> <span class="o">==</span> <span class="s2">"interval"</span><span class="p">:</span>
|
||||
<span class="n">inc</span> <span class="o">=</span> <span class="p">[[</span><span class="n">data</span><span class="p">[</span><span class="n">t</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">+</span> <span class="n">param</span><span class="p">[</span><span class="n">t</span><span class="p">],</span> <span class="n">data</span><span class="p">[</span><span class="n">t</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="n">param</span><span class="p">[</span><span class="n">t</span><span class="p">]]</span> <span class="k">for</span> <span class="n">t</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">n</span><span class="p">)]</span>
|
||||
<span class="k">elif</span> <span class="nb">type</span> <span class="o">==</span> <span class="s2">"distribution"</span><span class="p">:</span>
|
||||
<span class="k">for</span> <span class="n">t</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">n</span><span class="p">):</span>
|
||||
<span class="n">data</span><span class="p">[</span><span class="n">t</span><span class="p">]</span><span class="o">.</span><span class="n">differential_offset</span><span class="p">(</span><span class="n">param</span><span class="p">[</span><span class="n">t</span><span class="p">])</span>
|
||||
<span class="n">inc</span> <span class="o">=</span> <span class="n">data</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="nb">type</span> <span class="o">==</span> <span class="s2">"point"</span><span class="p">:</span>
|
||||
<span class="n">inc</span> <span class="o">=</span> <span class="p">[</span><span class="n">data</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">+</span> <span class="n">param</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span>
|
||||
<span class="k">for</span> <span class="n">t</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="n">steps_ahead</span><span class="p">):</span>
|
||||
<span class="n">inc</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="n">t</span><span class="p">]</span> <span class="o">+</span> <span class="n">inc</span><span class="p">[</span><span class="n">t</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span>
|
||||
<span class="k">elif</span> <span class="nb">type</span> <span class="o">==</span> <span class="s2">"interval"</span><span class="p">:</span>
|
||||
<span class="n">inc</span> <span class="o">=</span> <span class="p">[[</span><span class="n">data</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">+</span> <span class="n">param</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">data</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="n">param</span><span class="p">[</span><span class="mi">0</span><span class="p">]]]</span>
|
||||
<span class="k">for</span> <span class="n">t</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="n">steps_ahead</span><span class="p">):</span>
|
||||
<span class="n">inc</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">data</span><span class="p">[</span><span class="n">t</span><span class="p">][</span><span class="mi">0</span><span class="p">]</span> <span class="o">+</span> <span class="n">np</span><span class="o">.</span><span class="n">nanmean</span><span class="p">(</span><span class="n">inc</span><span class="p">[</span><span class="n">t</span><span class="o">-</span><span class="mi">1</span><span class="p">]),</span> <span class="n">data</span><span class="p">[</span><span class="n">t</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="n">np</span><span class="o">.</span><span class="n">nanmean</span><span class="p">(</span><span class="n">inc</span><span class="p">[</span><span class="n">t</span><span class="o">-</span><span class="mi">1</span><span class="p">])])</span>
|
||||
<span class="k">elif</span> <span class="nb">type</span> <span class="o">==</span> <span class="s2">"distribution"</span><span class="p">:</span>
|
||||
<span class="n">data</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">differential_offset</span><span class="p">(</span><span class="n">param</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
|
||||
<span class="k">for</span> <span class="n">t</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="n">steps_ahead</span><span class="p">):</span>
|
||||
<span class="n">ex</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="n">t</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">expected_value</span><span class="p">()</span>
|
||||
<span class="n">data</span><span class="p">[</span><span class="n">t</span><span class="p">]</span><span class="o">.</span><span class="n">differential_offset</span><span class="p">(</span><span class="n">ex</span><span class="p">)</span>
|
||||
<span class="n">inc</span> <span class="o">=</span> <span class="n">data</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">n</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">inc</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">inc</span></div></div>
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../../index.html">
|
||||
<img class="logo" src="../../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.common.transformations.differential</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,113 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.common.transformations.normalization — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../../" id="documentation_options" src="../../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../../_static/jquery.js"></script>
|
||||
<script src="../../../../_static/underscore.js"></script>
|
||||
<script src="../../../../_static/doctools.js"></script>
|
||||
<script src="../../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.common.transformations.normalization</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.common.transformations.normalization</h1><div class="highlight"><pre>
|
||||
<span></span><span class="kn">from</span> <span class="nn">pyFTS.common.transformations.transformation</span> <span class="kn">import</span> <span class="n">Transformation</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="Normalization"><a class="viewcode-back" href="../../../../pyFTS.common.transformations.html#pyFTS.common.transformations.normalization.Normalization">[docs]</a><span class="k">class</span> <span class="nc">Normalization</span><span class="p">(</span><span class="n">Transformation</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">Normalization</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">()</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="s1">'Normalization'</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">mu</span> <span class="o">=</span> <span class="mi">0</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">sigma</span> <span class="o">=</span> <span class="mi">0</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="Normalization.train"><a class="viewcode-back" href="../../../../pyFTS.common.transformations.html#pyFTS.common.transformations.normalization.Normalization.train">[docs]</a> <span class="k">def</span> <span class="nf">train</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">mu</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">mean</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">sigma</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">std</span><span class="p">(</span><span class="n">data</span><span class="p">)</span></div>
|
||||
|
||||
<div class="viewcode-block" id="Normalization.apply"><a class="viewcode-back" href="../../../../pyFTS.common.transformations.html#pyFTS.common.transformations.normalization.Normalization.apply">[docs]</a> <span class="k">def</span> <span class="nf">apply</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">param</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="n">modified</span> <span class="o">=</span> <span class="p">(</span><span class="n">data</span> <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">mu</span><span class="p">)</span> <span class="o">/</span> <span class="bp">self</span><span class="o">.</span><span class="n">sigma</span>
|
||||
<span class="k">return</span> <span class="n">modified</span></div>
|
||||
|
||||
<div class="viewcode-block" id="Normalization.inverse"><a class="viewcode-back" href="../../../../pyFTS.common.transformations.html#pyFTS.common.transformations.normalization.Normalization.inverse">[docs]</a> <span class="k">def</span> <span class="nf">inverse</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">param</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="n">modified</span> <span class="o">=</span> <span class="p">(</span><span class="n">data</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">sigma</span><span class="p">)</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">mu</span>
|
||||
<span class="k">return</span> <span class="n">modified</span></div></div>
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../../index.html">
|
||||
<img class="logo" src="../../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.common.transformations.normalization</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,114 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.common.transformations.roi — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../../" id="documentation_options" src="../../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../../_static/jquery.js"></script>
|
||||
<script src="../../../../_static/underscore.js"></script>
|
||||
<script src="../../../../_static/doctools.js"></script>
|
||||
<script src="../../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.common.transformations.roi</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.common.transformations.roi</h1><div class="highlight"><pre>
|
||||
<span></span><span class="kn">from</span> <span class="nn">pyFTS.common.transformations.transformation</span> <span class="kn">import</span> <span class="n">Transformation</span>
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="ROI"><a class="viewcode-back" href="../../../../pyFTS.common.transformations.html#pyFTS.common.transformations.roi.ROI">[docs]</a><span class="k">class</span> <span class="nc">ROI</span><span class="p">(</span><span class="n">Transformation</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Return of Investment (ROI) transformation. Retrieved from Sadaei and Lee (2014) - Multilayer Stock</span>
|
||||
<span class="sd"> Forecasting Model Using Fuzzy Time Series</span>
|
||||
|
||||
<span class="sd"> y'(t) = ( y(t) - y(t-1) ) / y(t-1)</span>
|
||||
<span class="sd"> y(t) = ( y(t-1) * y'(t) ) + y(t-1)</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">ROI</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">()</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="s1">'ROI'</span>
|
||||
|
||||
<div class="viewcode-block" id="ROI.apply"><a class="viewcode-back" href="../../../../pyFTS.common.transformations.html#pyFTS.common.transformations.roi.ROI.apply">[docs]</a> <span class="k">def</span> <span class="nf">apply</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">param</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="n">modified</span> <span class="o">=</span> <span class="p">[(</span><span class="n">data</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">-</span> <span class="n">data</span><span class="p">[</span><span class="n">i</span> <span class="o">-</span> <span class="mi">1</span><span class="p">])</span> <span class="o">/</span> <span class="n">data</span><span class="p">[</span><span class="n">i</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">))]</span>
|
||||
<span class="n">modified</span><span class="o">.</span><span class="n">insert</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mf">.0</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">modified</span></div>
|
||||
|
||||
<div class="viewcode-block" id="ROI.inverse"><a class="viewcode-back" href="../../../../pyFTS.common.transformations.html#pyFTS.common.transformations.roi.ROI.inverse">[docs]</a> <span class="k">def</span> <span class="nf">inverse</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">param</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="n">modified</span> <span class="o">=</span> <span class="p">[(</span><span class="n">param</span><span class="p">[</span><span class="n">i</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span> <span class="o">*</span> <span class="n">data</span><span class="p">[</span><span class="n">i</span><span class="p">])</span> <span class="o">+</span> <span class="n">param</span><span class="p">[</span><span class="n">i</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">))]</span>
|
||||
<span class="k">return</span> <span class="n">modified</span></div></div>
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../../index.html">
|
||||
<img class="logo" src="../../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.common.transformations.roi</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,136 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.common.transformations.scale — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../../" id="documentation_options" src="../../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../../_static/jquery.js"></script>
|
||||
<script src="../../../../_static/underscore.js"></script>
|
||||
<script src="../../../../_static/doctools.js"></script>
|
||||
<script src="../../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.common.transformations.scale</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.common.transformations.scale</h1><div class="highlight"><pre>
|
||||
<span></span><span class="kn">from</span> <span class="nn">pyFTS.common.transformations.transformation</span> <span class="kn">import</span> <span class="n">Transformation</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="Scale"><a class="viewcode-back" href="../../../../pyFTS.common.transformations.html#pyFTS.common.transformations.scale.Scale">[docs]</a><span class="k">class</span> <span class="nc">Scale</span><span class="p">(</span><span class="n">Transformation</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Scale data inside a interval [min, max]</span>
|
||||
|
||||
<span class="sd"> </span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="nb">min</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="nb">max</span><span class="o">=</span><span class="mi">1</span><span class="p">):</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">Scale</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">()</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">data_max</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">data_min</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">transf_max</span> <span class="o">=</span> <span class="nb">max</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">transf_min</span> <span class="o">=</span> <span class="nb">min</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="s1">'Scale'</span>
|
||||
|
||||
<span class="nd">@property</span>
|
||||
<span class="k">def</span> <span class="nf">parameters</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">transf_max</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">transf_min</span><span class="p">]</span>
|
||||
|
||||
<div class="viewcode-block" id="Scale.apply"><a class="viewcode-back" href="../../../../pyFTS.common.transformations.html#pyFTS.common.transformations.scale.Scale.apply">[docs]</a> <span class="k">def</span> <span class="nf">apply</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">param</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span><span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">data_max</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">data_max</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">nanmax</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">data_min</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">nanmin</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
|
||||
<span class="n">data_range</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">data_max</span> <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">data_min</span>
|
||||
<span class="n">transf_range</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">transf_max</span> <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">transf_min</span>
|
||||
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="p">[(</span><span class="n">k</span> <span class="o">+</span> <span class="p">(</span><span class="o">-</span><span class="mi">1</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">data_min</span><span class="p">))</span> <span class="o">/</span> <span class="n">data_range</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">data</span><span class="p">]</span>
|
||||
<span class="n">tmp2</span> <span class="o">=</span> <span class="p">[</span> <span class="p">(</span><span class="n">k</span> <span class="o">*</span> <span class="n">transf_range</span><span class="p">)</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">transf_min</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">tmp</span><span class="p">]</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="p">(</span><span class="n">data</span> <span class="o">+</span> <span class="p">(</span><span class="o">-</span><span class="mi">1</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">data_min</span><span class="p">))</span> <span class="o">/</span> <span class="n">data_range</span>
|
||||
<span class="n">tmp2</span> <span class="o">=</span> <span class="p">(</span><span class="n">tmp</span> <span class="o">*</span> <span class="n">transf_range</span><span class="p">)</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">transf_min</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">tmp2</span></div>
|
||||
|
||||
<div class="viewcode-block" id="Scale.inverse"><a class="viewcode-back" href="../../../../pyFTS.common.transformations.html#pyFTS.common.transformations.scale.Scale.inverse">[docs]</a> <span class="k">def</span> <span class="nf">inverse</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">param</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="n">data_range</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">data_max</span> <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">data_min</span>
|
||||
<span class="n">transf_range</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">transf_max</span> <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">transf_min</span>
|
||||
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span>
|
||||
<span class="n">tmp2</span> <span class="o">=</span> <span class="p">[(</span><span class="n">k</span> <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">transf_min</span><span class="p">)</span> <span class="o">/</span> <span class="n">transf_range</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">data</span><span class="p">]</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="p">[(</span><span class="n">k</span> <span class="o">*</span> <span class="n">data_range</span><span class="p">)</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">data_min</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">tmp2</span><span class="p">]</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">tmp2</span> <span class="o">=</span> <span class="p">(</span><span class="n">data</span> <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">transf_min</span><span class="p">)</span> <span class="o">/</span> <span class="n">transf_range</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="p">(</span><span class="n">tmp2</span> <span class="o">*</span> <span class="n">data_range</span><span class="p">)</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">data_min</span>
|
||||
<span class="k">return</span> <span class="n">tmp</span></div></div>
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../../index.html">
|
||||
<img class="logo" src="../../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.common.transformations.scale</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,180 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.common.transformations.smoothing — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../../" id="documentation_options" src="../../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../../_static/jquery.js"></script>
|
||||
<script src="../../../../_static/underscore.js"></script>
|
||||
<script src="../../../../_static/doctools.js"></script>
|
||||
<script src="../../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.common.transformations.smoothing</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.common.transformations.smoothing</h1><div class="highlight"><pre>
|
||||
<span></span><span class="kn">from</span> <span class="nn">pyFTS.common.transformations.transformation</span> <span class="kn">import</span> <span class="n">Transformation</span>
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
|
||||
<div class="viewcode-block" id="MovingAverage"><a class="viewcode-back" href="../../../../pyFTS.common.transformations.html#pyFTS.common.transformations.smoothing.MovingAverage">[docs]</a><span class="k">class</span> <span class="nc">MovingAverage</span><span class="p">(</span><span class="n">Transformation</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">MovingAverage</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="s1">'Moving Average Smoothing'</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">steps</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'steps'</span><span class="p">,</span><span class="mi">2</span><span class="p">)</span>
|
||||
|
||||
<div class="viewcode-block" id="MovingAverage.apply"><a class="viewcode-back" href="../../../../pyFTS.common.transformations.html#pyFTS.common.transformations.smoothing.MovingAverage.apply">[docs]</a> <span class="k">def</span> <span class="nf">apply</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">param</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="n">steps</span> <span class="o">=</span> <span class="n">param</span> <span class="k">if</span> <span class="n">param</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">steps</span>
|
||||
<span class="n">ma</span> <span class="o">=</span> <span class="p">[</span><span class="n">k</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">data</span><span class="p">[:</span><span class="n">steps</span><span class="p">]]</span>
|
||||
<span class="n">ma</span><span class="o">.</span><span class="n">extend</span><span class="p">([</span><span class="n">np</span><span class="o">.</span><span class="n">mean</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="n">k</span><span class="o">-</span><span class="n">steps</span><span class="p">:</span><span class="n">k</span><span class="p">])</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">steps</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">))])</span>
|
||||
<span class="k">return</span> <span class="n">ma</span></div>
|
||||
|
||||
<div class="viewcode-block" id="MovingAverage.inverse"><a class="viewcode-back" href="../../../../pyFTS.common.transformations.html#pyFTS.common.transformations.smoothing.MovingAverage.inverse">[docs]</a> <span class="k">def</span> <span class="nf">inverse</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">param</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="n">data</span></div></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="ExponentialSmoothing"><a class="viewcode-back" href="../../../../pyFTS.common.transformations.html#pyFTS.common.transformations.smoothing.ExponentialSmoothing">[docs]</a><span class="k">class</span> <span class="nc">ExponentialSmoothing</span><span class="p">(</span><span class="n">Transformation</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">ExponentialSmoothing</span><span class="p">,</span><span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="s1">'Exponential Moving Average Smoothing'</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">steps</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'steps'</span><span class="p">,</span><span class="mi">2</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">beta</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'beta'</span><span class="p">,</span><span class="mf">.5</span><span class="p">)</span>
|
||||
|
||||
<div class="viewcode-block" id="ExponentialSmoothing.apply"><a class="viewcode-back" href="../../../../pyFTS.common.transformations.html#pyFTS.common.transformations.smoothing.ExponentialSmoothing.apply">[docs]</a> <span class="k">def</span> <span class="nf">apply</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">param</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="n">steps</span> <span class="o">=</span> <span class="n">param</span> <span class="k">if</span> <span class="n">param</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">steps</span>
|
||||
<span class="n">beta</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'beta'</span><span class="p">,</span><span class="kc">None</span><span class="p">)</span>
|
||||
<span class="n">beta</span> <span class="o">=</span> <span class="n">beta</span> <span class="k">if</span> <span class="n">beta</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">beta</span>
|
||||
<span class="n">mm</span> <span class="o">=</span> <span class="p">[</span><span class="n">k</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">data</span><span class="p">[:</span><span class="n">steps</span><span class="p">]]</span>
|
||||
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">steps</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">)):</span>
|
||||
<span class="n">ret</span> <span class="o">=</span> <span class="mi">0</span>
|
||||
<span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="n">steps</span><span class="p">):</span>
|
||||
<span class="n">ret</span> <span class="o">+=</span> <span class="p">(</span> <span class="n">beta</span> <span class="o">*</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">beta</span><span class="p">)</span> <span class="o">**</span> <span class="n">k</span> <span class="p">)</span> <span class="o">*</span> <span class="n">data</span><span class="p">[</span><span class="n">i</span> <span class="o">-</span> <span class="n">k</span><span class="p">]</span>
|
||||
<span class="n">mm</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">ret</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">mm</span></div>
|
||||
|
||||
<div class="viewcode-block" id="ExponentialSmoothing.inverse"><a class="viewcode-back" href="../../../../pyFTS.common.transformations.html#pyFTS.common.transformations.smoothing.ExponentialSmoothing.inverse">[docs]</a> <span class="k">def</span> <span class="nf">inverse</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">param</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="n">data</span></div></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="AveragePooling"><a class="viewcode-back" href="../../../../pyFTS.common.transformations.html#pyFTS.common.transformations.smoothing.AveragePooling">[docs]</a><span class="k">class</span> <span class="nc">AveragePooling</span><span class="p">(</span><span class="n">Transformation</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">AveragePooling</span><span class="p">,</span><span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="s1">'Exponential Average Smoothing'</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">kernel</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'kernel'</span><span class="p">,</span><span class="mi">5</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">stride</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'stride'</span><span class="p">,</span><span class="mi">1</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">padding</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'padding'</span><span class="p">,</span><span class="s1">'same'</span><span class="p">)</span>
|
||||
|
||||
<div class="viewcode-block" id="AveragePooling.apply"><a class="viewcode-back" href="../../../../pyFTS.common.transformations.html#pyFTS.common.transformations.smoothing.AveragePooling.apply">[docs]</a> <span class="k">def</span> <span class="nf">apply</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
|
||||
<span class="n">result</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">padding</span> <span class="o">==</span> <span class="s1">'same'</span><span class="p">:</span>
|
||||
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">kernel</span><span class="o">/</span><span class="mi">2</span><span class="p">),</span> <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">)</span><span class="o">+</span><span class="nb">int</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">kernel</span><span class="o">/</span><span class="mi">2</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">stride</span><span class="p">):</span>
|
||||
<span class="n">result</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">mean</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="n">np</span><span class="o">.</span><span class="n">max</span><span class="p">([</span><span class="mi">0</span><span class="p">,</span><span class="n">i</span><span class="o">-</span><span class="bp">self</span><span class="o">.</span><span class="n">kernel</span><span class="p">]):</span><span class="n">np</span><span class="o">.</span><span class="n">min</span><span class="p">([</span><span class="n">i</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">)])]))</span>
|
||||
|
||||
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">padding</span> <span class="o">==</span> <span class="s1">'valid'</span><span class="p">:</span>
|
||||
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">kernel</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">stride</span><span class="p">):</span>
|
||||
<span class="n">result</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">mean</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="n">i</span><span class="o">-</span><span class="bp">self</span><span class="o">.</span><span class="n">kernel</span><span class="p">:</span><span class="n">i</span><span class="p">]))</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">'Invalid padding schema'</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">result</span></div>
|
||||
|
||||
<div class="viewcode-block" id="AveragePooling.inverse"><a class="viewcode-back" href="../../../../pyFTS.common.transformations.html#pyFTS.common.transformations.smoothing.AveragePooling.inverse">[docs]</a> <span class="k">def</span> <span class="nf">inverse</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">param</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="n">data</span></div></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="MaxPooling"><a class="viewcode-back" href="../../../../pyFTS.common.transformations.html#pyFTS.common.transformations.smoothing.MaxPooling">[docs]</a><span class="k">class</span> <span class="nc">MaxPooling</span><span class="p">(</span><span class="n">Transformation</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">MaxPooling</span><span class="p">,</span><span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="s1">'Exponential Average Smoothing'</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">kernel</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'kernel'</span><span class="p">,</span><span class="mi">5</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">stride</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'stride'</span><span class="p">,</span><span class="mi">1</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">padding</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'padding'</span><span class="p">,</span><span class="s1">'same'</span><span class="p">)</span>
|
||||
|
||||
<div class="viewcode-block" id="MaxPooling.apply"><a class="viewcode-back" href="../../../../pyFTS.common.transformations.html#pyFTS.common.transformations.smoothing.MaxPooling.apply">[docs]</a> <span class="k">def</span> <span class="nf">apply</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
|
||||
<span class="n">result</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">padding</span> <span class="o">==</span> <span class="s1">'same'</span><span class="p">:</span>
|
||||
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">kernel</span><span class="o">/</span><span class="mi">2</span><span class="p">),</span> <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">)</span><span class="o">+</span><span class="nb">int</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">kernel</span><span class="o">/</span><span class="mi">2</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">stride</span><span class="p">):</span>
|
||||
<span class="n">result</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">max</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="n">np</span><span class="o">.</span><span class="n">max</span><span class="p">([</span><span class="mi">0</span><span class="p">,</span><span class="n">i</span><span class="o">-</span><span class="bp">self</span><span class="o">.</span><span class="n">kernel</span><span class="p">]):</span><span class="n">np</span><span class="o">.</span><span class="n">min</span><span class="p">([</span><span class="n">i</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">)])]))</span>
|
||||
|
||||
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">padding</span> <span class="o">==</span> <span class="s1">'valid'</span><span class="p">:</span>
|
||||
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">kernel</span> <span class="o">-</span> <span class="mi">1</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">stride</span><span class="p">):</span>
|
||||
<span class="n">result</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">max</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="n">i</span><span class="o">-</span><span class="bp">self</span><span class="o">.</span><span class="n">kernel</span><span class="p">:</span><span class="n">i</span><span class="p">]))</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s1">'Invalid padding schema'</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">result</span></div>
|
||||
|
||||
<div class="viewcode-block" id="MaxPooling.inverse"><a class="viewcode-back" href="../../../../pyFTS.common.transformations.html#pyFTS.common.transformations.smoothing.MaxPooling.inverse">[docs]</a> <span class="k">def</span> <span class="nf">inverse</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">param</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="n">data</span></div></div>
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../../index.html">
|
||||
<img class="logo" src="../../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.common.transformations.smoothing</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,196 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.common.transformations.som — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../../" id="documentation_options" src="../../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../../_static/jquery.js"></script>
|
||||
<script src="../../../../_static/underscore.js"></script>
|
||||
<script src="../../../../_static/doctools.js"></script>
|
||||
<script src="../../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.common.transformations.som</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.common.transformations.som</h1><div class="highlight"><pre>
|
||||
<span></span><span class="sd">"""</span>
|
||||
<span class="sd">Kohonen Self Organizing Maps for Fuzzy Time Series</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span>
|
||||
<span class="c1">#from pyFTS.models.multivariate import wmvfts</span>
|
||||
<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Tuple</span>
|
||||
<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">List</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.common.transformations.transformation</span> <span class="kn">import</span> <span class="n">Transformation</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="SOMTransformation"><a class="viewcode-back" href="../../../../pyFTS.common.transformations.html#pyFTS.common.transformations.som.SOMTransformation">[docs]</a><span class="k">class</span> <span class="nc">SOMTransformation</span><span class="p">(</span><span class="n">Transformation</span><span class="p">):</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span>
|
||||
<span class="n">grid_dimension</span><span class="p">:</span> <span class="n">Tuple</span><span class="p">,</span>
|
||||
<span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">SimpSOM</span> <span class="k">as</span> <span class="nn">sps</span>
|
||||
|
||||
<span class="c1"># SOM attributes</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">load_file</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'loadFile'</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">net</span><span class="p">:</span> <span class="n">sps</span><span class="o">.</span><span class="n">somNet</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">:</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">grid_dimension</span><span class="p">:</span> <span class="n">Tuple</span> <span class="o">=</span> <span class="n">grid_dimension</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">pbc</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'PBC'</span><span class="p">,</span> <span class="kc">True</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">is_multivariate</span> <span class="o">=</span> <span class="kc">True</span>
|
||||
|
||||
<span class="c1"># debug attributes</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="s1">'Kohonen Self Organizing Maps FTS'</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">shortname</span> <span class="o">=</span> <span class="s1">'SOM-FTS'</span>
|
||||
|
||||
<div class="viewcode-block" id="SOMTransformation.apply"><a class="viewcode-back" href="../../../../pyFTS.common.transformations.html#pyFTS.common.transformations.som.SOMTransformation.apply">[docs]</a> <span class="k">def</span> <span class="nf">apply</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span>
|
||||
<span class="n">data</span><span class="p">:</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">,</span>
|
||||
<span class="n">param</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
|
||||
<span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Transform a M-dimensional dataset into a 3-dimensional dataset, where one dimension is the endogen variable</span>
|
||||
<span class="sd"> If endogen_variable = None, the last column will be the endogen_variable.</span>
|
||||
|
||||
<span class="sd"> Args:</span>
|
||||
<span class="sd"> data (pd.DataFrame): M-Dimensional dataset</span>
|
||||
<span class="sd"> endogen_variable (str): column of dataset</span>
|
||||
<span class="sd"> names (Tuple): names for new columns created by SOM Transformation.</span>
|
||||
<span class="sd"> param:</span>
|
||||
<span class="sd"> **kwargs: params of SOM's train process</span>
|
||||
<span class="sd"> percentage_train (float). Percentage of dataset that will be used for train SOM network. default: 0.7</span>
|
||||
<span class="sd"> leaning_rate (float): leaning rate of SOM network. default: 0.01</span>
|
||||
<span class="sd"> epochs: epochs of SOM network. default: 10000</span>
|
||||
<span class="sd"> </span>
|
||||
<span class="sd"> Returns:</span>
|
||||
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="n">endogen_variable</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'endogen_variable'</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
|
||||
<span class="n">names</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'names'</span><span class="p">,</span> <span class="p">(</span><span class="s1">'x'</span><span class="p">,</span> <span class="s1">'y'</span><span class="p">))</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">endogen_variable</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">data</span><span class="o">.</span><span class="n">columns</span><span class="p">:</span>
|
||||
<span class="n">endogen_variable</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
<span class="n">cols</span> <span class="o">=</span> <span class="n">data</span><span class="o">.</span><span class="n">columns</span><span class="p">[:</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span> <span class="k">if</span> <span class="n">endogen_variable</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="p">[</span><span class="n">col</span> <span class="k">for</span> <span class="n">col</span> <span class="ow">in</span> <span class="n">data</span><span class="o">.</span><span class="n">columns</span> <span class="k">if</span>
|
||||
<span class="n">col</span> <span class="o">!=</span> <span class="n">endogen_variable</span><span class="p">]</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">net</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">train</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="n">cols</span><span class="p">]</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">train</span><span class="p">(</span><span class="n">data</span><span class="o">=</span><span class="n">train</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
<span class="n">new_data</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">net</span><span class="o">.</span><span class="n">project</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="n">cols</span><span class="p">]</span><span class="o">.</span><span class="n">values</span><span class="p">)</span>
|
||||
<span class="n">new_data</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">(</span><span class="n">new_data</span><span class="p">,</span> <span class="n">columns</span><span class="o">=</span><span class="n">names</span><span class="p">)</span>
|
||||
<span class="n">endogen</span> <span class="o">=</span> <span class="n">endogen_variable</span> <span class="k">if</span> <span class="n">endogen_variable</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">data</span><span class="o">.</span><span class="n">columns</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
|
||||
<span class="n">new_data</span><span class="p">[</span><span class="n">endogen</span><span class="p">]</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="n">endogen</span><span class="p">]</span><span class="o">.</span><span class="n">values</span>
|
||||
<span class="k">return</span> <span class="n">new_data</span></div>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="n">status</span> <span class="o">=</span> <span class="s2">"is trained"</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">net</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="k">else</span> <span class="s2">"not trained"</span>
|
||||
<span class="k">return</span> <span class="sa">f</span><span class="s1">'</span><span class="si">{</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="si">}</span><span class="s1">-</span><span class="si">{</span><span class="n">status</span><span class="si">}</span><span class="s1">'</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__del__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">del</span> <span class="bp">self</span><span class="o">.</span><span class="n">net</span>
|
||||
|
||||
<div class="viewcode-block" id="SOMTransformation.train"><a class="viewcode-back" href="../../../../pyFTS.common.transformations.html#pyFTS.common.transformations.som.SOMTransformation.train">[docs]</a> <span class="k">def</span> <span class="nf">train</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span>
|
||||
<span class="n">data</span><span class="p">:</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">,</span>
|
||||
<span class="n">percentage_train</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mf">.7</span><span class="p">,</span>
|
||||
<span class="n">leaning_rate</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mf">0.01</span><span class="p">,</span>
|
||||
<span class="n">epochs</span><span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="mi">10000</span><span class="p">):</span>
|
||||
<span class="n">data</span> <span class="o">=</span> <span class="n">data</span><span class="o">.</span><span class="n">dropna</span><span class="p">()</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">data</span> <span class="o">=</span> <span class="n">data</span><span class="o">.</span><span class="n">values</span>
|
||||
<span class="n">limit</span> <span class="o">=</span> <span class="nb">round</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">)</span> <span class="o">*</span> <span class="n">percentage_train</span><span class="p">)</span>
|
||||
<span class="n">train</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">data</span><span class="p">[:</span><span class="n">limit</span><span class="p">]</span>
|
||||
<span class="n">x</span><span class="p">,</span> <span class="n">y</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">grid_dimension</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">net</span> <span class="o">=</span> <span class="n">sps</span><span class="o">.</span><span class="n">somNet</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">train</span><span class="p">,</span> <span class="n">PBC</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">pbc</span><span class="p">,</span>
|
||||
<span class="n">loadFile</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">load_file</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">net</span><span class="o">.</span><span class="n">train</span><span class="p">(</span><span class="n">startLearnRate</span><span class="o">=</span><span class="n">leaning_rate</span><span class="p">,</span>
|
||||
<span class="n">epochs</span><span class="o">=</span><span class="n">epochs</span><span class="p">)</span></div>
|
||||
|
||||
<div class="viewcode-block" id="SOMTransformation.save_net"><a class="viewcode-back" href="../../../../pyFTS.common.transformations.html#pyFTS.common.transformations.som.SOMTransformation.save_net">[docs]</a> <span class="k">def</span> <span class="nf">save_net</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span>
|
||||
<span class="n">filename</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">"SomNet trained"</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">net</span><span class="o">.</span><span class="n">save</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">load_file</span> <span class="o">=</span> <span class="n">filename</span></div>
|
||||
|
||||
<div class="viewcode-block" id="SOMTransformation.show_grid"><a class="viewcode-back" href="../../../../pyFTS.common.transformations.html#pyFTS.common.transformations.som.SOMTransformation.show_grid">[docs]</a> <span class="k">def</span> <span class="nf">show_grid</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span>
|
||||
<span class="n">graph_type</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s1">'nodes_graph'</span><span class="p">,</span>
|
||||
<span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="n">graph_type</span> <span class="o">==</span> <span class="s1">'nodes_graph'</span><span class="p">:</span>
|
||||
<span class="n">colnum</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'colnum'</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">net</span><span class="o">.</span><span class="n">nodes_graph</span><span class="p">(</span><span class="n">colnum</span><span class="o">=</span><span class="n">colnum</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">net</span><span class="o">.</span><span class="n">diff_graph</span><span class="p">()</span></div></div>
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../../index.html">
|
||||
<img class="logo" src="../../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.common.transformations.som</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,126 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.common.transformations.transformation — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../../" id="documentation_options" src="../../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../../_static/jquery.js"></script>
|
||||
<script src="../../../../_static/underscore.js"></script>
|
||||
<script src="../../../../_static/doctools.js"></script>
|
||||
<script src="../../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.common.transformations.transformation</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.common.transformations.transformation</h1><div class="highlight"><pre>
|
||||
<span></span>
|
||||
<div class="viewcode-block" id="Transformation"><a class="viewcode-back" href="../../../../pyFTS.common.transformations.html#pyFTS.common.transformations.transformation.Transformation">[docs]</a><span class="k">class</span> <span class="nc">Transformation</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Data transformation used on pre and post processing of the FTS</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">is_invertible</span> <span class="o">=</span> <span class="kc">True</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">is_multivariate</span> <span class="o">=</span> <span class="kc">False</span>
|
||||
<span class="w"> </span><span class="sd">"""detemine if this transformation can be applied to multivariate data"""</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">minimal_length</span> <span class="o">=</span> <span class="mi">1</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="s1">''</span>
|
||||
|
||||
<div class="viewcode-block" id="Transformation.apply"><a class="viewcode-back" href="../../../../pyFTS.common.transformations.html#pyFTS.common.transformations.transformation.Transformation.apply">[docs]</a> <span class="k">def</span> <span class="nf">apply</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">param</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Apply the transformation on input data</span>
|
||||
|
||||
<span class="sd"> :param data: input data</span>
|
||||
<span class="sd"> :param param:</span>
|
||||
<span class="sd"> :param kwargs:</span>
|
||||
<span class="sd"> :return: numpy array with transformed data</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">pass</span></div>
|
||||
|
||||
<div class="viewcode-block" id="Transformation.inverse"><a class="viewcode-back" href="../../../../pyFTS.common.transformations.html#pyFTS.common.transformations.transformation.Transformation.inverse">[docs]</a> <span class="k">def</span> <span class="nf">inverse</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">data</span><span class="p">,</span> <span class="n">param</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
|
||||
<span class="sd"> :param data: transformed data</span>
|
||||
<span class="sd"> :param param:</span>
|
||||
<span class="sd"> :param kwargs:</span>
|
||||
<span class="sd"> :return: numpy array with inverse transformed data</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">pass</span></div>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span></div>
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../../index.html">
|
||||
<img class="logo" src="../../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.common.transformations.transformation</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
163
docs/build/html/_modules/pyFTS/common/tree.html
vendored
163
docs/build/html/_modules/pyFTS/common/tree.html
vendored
@ -1,163 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.common.tree — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../_static/jquery.js"></script>
|
||||
<script src="../../../_static/underscore.js"></script>
|
||||
<script src="../../../_static/doctools.js"></script>
|
||||
<script src="../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.common.tree</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.common.tree</h1><div class="highlight"><pre>
|
||||
<span></span><span class="sd">"""</span>
|
||||
<span class="sd">Tree data structure</span>
|
||||
<span class="sd">"""</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">pyFTS</span> <span class="kn">import</span> <span class="o">*</span>
|
||||
<span class="kn">from</span> <span class="nn">functools</span> <span class="kn">import</span> <span class="n">reduce</span>
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="FLRGTreeNode"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.tree.FLRGTreeNode">[docs]</a><span class="k">class</span> <span class="nc">FLRGTreeNode</span><span class="p">:</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Tree node for</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">isRoot</span> <span class="o">=</span> <span class="kc">False</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">children</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">value</span> <span class="o">=</span> <span class="n">value</span>
|
||||
|
||||
<div class="viewcode-block" id="FLRGTreeNode.appendChild"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.tree.FLRGTreeNode.appendChild">[docs]</a> <span class="k">def</span> <span class="nf">appendChild</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">child</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">children</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">child</span><span class="p">)</span></div>
|
||||
|
||||
<div class="viewcode-block" id="FLRGTreeNode.getChildren"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.tree.FLRGTreeNode.getChildren">[docs]</a> <span class="k">def</span> <span class="nf">getChildren</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">for</span> <span class="n">child</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">children</span><span class="p">:</span>
|
||||
<span class="k">yield</span> <span class="n">child</span></div>
|
||||
|
||||
<div class="viewcode-block" id="FLRGTreeNode.paths"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.tree.FLRGTreeNode.paths">[docs]</a> <span class="k">def</span> <span class="nf">paths</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">acc</span><span class="o">=</span><span class="p">[]):</span>
|
||||
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">children</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
|
||||
<span class="k">yield</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">value</span><span class="p">]</span> <span class="o">+</span> <span class="n">acc</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">child</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">children</span><span class="p">:</span>
|
||||
<span class="k">for</span> <span class="n">leaf_path</span> <span class="ow">in</span> <span class="n">child</span><span class="o">.</span><span class="n">paths</span><span class="p">([</span><span class="bp">self</span><span class="o">.</span><span class="n">value</span><span class="p">]</span> <span class="o">+</span> <span class="n">acc</span><span class="p">):</span> <span class="c1"># these two</span>
|
||||
<span class="k">yield</span> <span class="n">leaf_path</span></div>
|
||||
|
||||
<div class="viewcode-block" id="FLRGTreeNode.getStr"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.tree.FLRGTreeNode.getStr">[docs]</a> <span class="k">def</span> <span class="nf">getStr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">k</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">isRoot</span><span class="p">:</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">value</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="s2">"</span><span class="se">\\</span><span class="s2">"</span> <span class="o">+</span> <span class="p">(</span><span class="s2">"-"</span> <span class="o">*</span> <span class="n">k</span><span class="p">)</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">value</span><span class="p">)</span>
|
||||
<span class="k">for</span> <span class="n">child</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">getChildren</span><span class="p">():</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">tmp</span> <span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span> <span class="o">+</span> <span class="n">child</span><span class="o">.</span><span class="n">getStr</span><span class="p">(</span><span class="n">k</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">tmp</span></div>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">getStr</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="FLRGTree"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.tree.FLRGTree">[docs]</a><span class="k">class</span> <span class="nc">FLRGTree</span><span class="p">:</span>
|
||||
<span class="w"> </span><span class="sd">"""Represents a FLRG set with a tree structure"""</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">root</span> <span class="o">=</span> <span class="n">FLRGTreeNode</span><span class="p">(</span><span class="kc">None</span><span class="p">)</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="flat"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.tree.flat">[docs]</a><span class="k">def</span> <span class="nf">flat</span><span class="p">(</span><span class="n">dados</span><span class="p">):</span>
|
||||
<span class="k">for</span> <span class="n">inst</span> <span class="ow">in</span> <span class="n">dados</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">inst</span><span class="p">,</span> <span class="p">(</span><span class="nb">list</span><span class="p">,</span> <span class="nb">tuple</span><span class="p">)):</span>
|
||||
<span class="n">x</span> <span class="o">=</span> <span class="n">flat</span><span class="p">(</span><span class="n">inst</span><span class="p">)</span>
|
||||
<span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">x</span><span class="p">:</span>
|
||||
<span class="k">yield</span> <span class="n">k</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="k">yield</span> <span class="n">inst</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="build_tree_without_order"><a class="viewcode-back" href="../../../pyFTS.common.html#pyFTS.common.tree.build_tree_without_order">[docs]</a><span class="k">def</span> <span class="nf">build_tree_without_order</span><span class="p">(</span><span class="n">node</span><span class="p">,</span> <span class="n">lags</span><span class="p">,</span> <span class="n">level</span><span class="p">):</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">level</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">lags</span><span class="p">:</span>
|
||||
<span class="k">return</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">s</span> <span class="ow">in</span> <span class="n">lags</span><span class="p">[</span><span class="n">level</span><span class="p">]:</span>
|
||||
<span class="n">node</span><span class="o">.</span><span class="n">appendChild</span><span class="p">(</span><span class="n">FLRGTreeNode</span><span class="p">(</span><span class="n">s</span><span class="p">))</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">child</span> <span class="ow">in</span> <span class="n">node</span><span class="o">.</span><span class="n">getChildren</span><span class="p">():</span>
|
||||
<span class="n">build_tree_without_order</span><span class="p">(</span><span class="n">child</span><span class="p">,</span> <span class="n">lags</span><span class="p">,</span> <span class="n">level</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)</span></div>
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../index.html">
|
||||
<img class="logo" src="../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.common.tree</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,122 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.data.AirPassengers — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../_static/jquery.js"></script>
|
||||
<script src="../../../_static/underscore.js"></script>
|
||||
<script src="../../../_static/doctools.js"></script>
|
||||
<script src="../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.data.AirPassengers</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.data.AirPassengers</h1><div class="highlight"><pre>
|
||||
<span></span><span class="sd">"""</span>
|
||||
<span class="sd">Monthly totals of a airline passengers from USA, from January 1949 through December 1960.</span>
|
||||
|
||||
<span class="sd">Source: Hyndman, R.J., Time Series Data Library, http://www-personal.buseco.monash.edu.au/~hyndman/TSDL/.</span>
|
||||
<span class="sd">"""</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.data</span> <span class="kn">import</span> <span class="n">common</span>
|
||||
<span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span>
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="get_data"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.AirPassengers.get_data">[docs]</a><span class="k">def</span> <span class="nf">get_data</span><span class="p">()</span> <span class="o">-></span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">:</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Get a simple univariate time series data.</span>
|
||||
|
||||
<span class="sd"> :return: numpy array</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">dat</span> <span class="o">=</span> <span class="n">get_dataframe</span><span class="p">()</span>
|
||||
<span class="n">dat</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">dat</span><span class="p">[</span><span class="s2">"Passengers"</span><span class="p">])</span>
|
||||
<span class="k">return</span> <span class="n">dat</span></div>
|
||||
|
||||
<div class="viewcode-block" id="get_dataframe"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.AirPassengers.get_dataframe">[docs]</a><span class="k">def</span> <span class="nf">get_dataframe</span><span class="p">()</span> <span class="o">-></span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">:</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Get the complete multivariate time series data.</span>
|
||||
|
||||
<span class="sd"> :return: Pandas DataFrame</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">dat</span> <span class="o">=</span> <span class="n">common</span><span class="o">.</span><span class="n">get_dataframe</span><span class="p">(</span><span class="s1">'AirPassengers.csv'</span><span class="p">,</span>
|
||||
<span class="s1">'https://github.com/petroniocandido/pyFTS/raw/8f20f3634aa6a8f58083bdcd1bbf93795e6ed767/pyFTS/data/AirPassengers.csv'</span><span class="p">,</span>
|
||||
<span class="n">sep</span><span class="o">=</span><span class="s2">","</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">dat</span></div>
|
||||
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../index.html">
|
||||
<img class="logo" src="../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.data.AirPassengers</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
126
docs/build/html/_modules/pyFTS/data/Bitcoin.html
vendored
126
docs/build/html/_modules/pyFTS/data/Bitcoin.html
vendored
@ -1,126 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.data.Bitcoin — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../_static/jquery.js"></script>
|
||||
<script src="../../../_static/underscore.js"></script>
|
||||
<script src="../../../_static/doctools.js"></script>
|
||||
<script src="../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.data.Bitcoin</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.data.Bitcoin</h1><div class="highlight"><pre>
|
||||
<span></span><span class="sd">"""</span>
|
||||
<span class="sd">Bitcoin to USD quotations</span>
|
||||
|
||||
<span class="sd">Daily averaged index, by business day, from 2010 to 2018.</span>
|
||||
|
||||
<span class="sd">Source: https://finance.yahoo.com/quote/BTC-USD?p=BTC-USD</span>
|
||||
<span class="sd">"""</span>
|
||||
|
||||
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.data</span> <span class="kn">import</span> <span class="n">common</span>
|
||||
<span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span>
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="get_data"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.Bitcoin.get_data">[docs]</a><span class="k">def</span> <span class="nf">get_data</span><span class="p">(</span><span class="n">field</span><span class="p">:</span><span class="nb">str</span><span class="o">=</span><span class="s1">'AVG'</span><span class="p">)</span> <span class="o">-></span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">:</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Get the univariate time series data.</span>
|
||||
|
||||
<span class="sd"> :param field: dataset field to load</span>
|
||||
<span class="sd"> :return: numpy array</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">dat</span> <span class="o">=</span> <span class="n">get_dataframe</span><span class="p">()</span>
|
||||
<span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">dat</span><span class="p">[</span><span class="n">field</span><span class="p">])</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="get_dataframe"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.Bitcoin.get_dataframe">[docs]</a><span class="k">def</span> <span class="nf">get_dataframe</span><span class="p">()</span> <span class="o">-></span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">:</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Get the complete multivariate time series data.</span>
|
||||
|
||||
<span class="sd"> :return: Pandas DataFrame</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">df</span> <span class="o">=</span> <span class="n">common</span><span class="o">.</span><span class="n">get_dataframe</span><span class="p">(</span><span class="s2">"BTCUSD.csv"</span><span class="p">,</span> <span class="s2">"https://query.data.world/s/72gews5w3c7oaf7by5vp7evsasluia"</span><span class="p">,</span>
|
||||
<span class="n">sep</span><span class="o">=</span><span class="s2">","</span><span class="p">)</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">df</span></div>
|
||||
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../index.html">
|
||||
<img class="logo" src="../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.data.Bitcoin</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
126
docs/build/html/_modules/pyFTS/data/DowJones.html
vendored
126
docs/build/html/_modules/pyFTS/data/DowJones.html
vendored
@ -1,126 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.data.DowJones — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../_static/jquery.js"></script>
|
||||
<script src="../../../_static/underscore.js"></script>
|
||||
<script src="../../../_static/doctools.js"></script>
|
||||
<script src="../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.data.DowJones</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.data.DowJones</h1><div class="highlight"><pre>
|
||||
<span></span><span class="sd">"""</span>
|
||||
<span class="sd">DJI - Dow Jones</span>
|
||||
|
||||
<span class="sd">Daily averaged index, by business day, from 1985 to 2017.</span>
|
||||
|
||||
<span class="sd">Source: https://finance.yahoo.com/quote/%5EGSPC/history?p=%5EGSPC</span>
|
||||
<span class="sd">"""</span>
|
||||
|
||||
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.data</span> <span class="kn">import</span> <span class="n">common</span>
|
||||
<span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span>
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="get_data"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.DowJones.get_data">[docs]</a><span class="k">def</span> <span class="nf">get_data</span><span class="p">(</span><span class="n">field</span><span class="p">:</span><span class="nb">str</span><span class="o">=</span><span class="s1">'AVG'</span><span class="p">)</span> <span class="o">-></span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">:</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Get the univariate time series data.</span>
|
||||
|
||||
<span class="sd"> :param field: dataset field to load</span>
|
||||
<span class="sd"> :return: numpy array</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">dat</span> <span class="o">=</span> <span class="n">get_dataframe</span><span class="p">()</span>
|
||||
<span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">dat</span><span class="p">[</span><span class="n">field</span><span class="p">])</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="get_dataframe"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.DowJones.get_dataframe">[docs]</a><span class="k">def</span> <span class="nf">get_dataframe</span><span class="p">()</span> <span class="o">-></span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">:</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Get the complete multivariate time series data.</span>
|
||||
|
||||
<span class="sd"> :return: Pandas DataFrame</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">df</span> <span class="o">=</span> <span class="n">common</span><span class="o">.</span><span class="n">get_dataframe</span><span class="p">(</span><span class="s2">"DowJones.csv"</span><span class="p">,</span> <span class="s2">"https://query.data.world/s/d4hfir3xrelkx33o3bfs5dbhyiztml"</span><span class="p">,</span>
|
||||
<span class="n">sep</span><span class="o">=</span><span class="s2">","</span><span class="p">)</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">df</span></div>
|
||||
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../index.html">
|
||||
<img class="logo" src="../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.data.DowJones</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
124
docs/build/html/_modules/pyFTS/data/EURGBP.html
vendored
124
docs/build/html/_modules/pyFTS/data/EURGBP.html
vendored
@ -1,124 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.data.EURGBP — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../_static/jquery.js"></script>
|
||||
<script src="../../../_static/underscore.js"></script>
|
||||
<script src="../../../_static/doctools.js"></script>
|
||||
<script src="../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.data.EURGBP</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.data.EURGBP</h1><div class="highlight"><pre>
|
||||
<span></span><span class="sd">"""</span>
|
||||
<span class="sd">FOREX market EUR-GBP pair.</span>
|
||||
|
||||
<span class="sd">Daily averaged quotations, by business day, from 2016 to 2018.</span>
|
||||
<span class="sd">"""</span>
|
||||
|
||||
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.data</span> <span class="kn">import</span> <span class="n">common</span>
|
||||
<span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span>
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="get_data"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.EURGBP.get_data">[docs]</a><span class="k">def</span> <span class="nf">get_data</span><span class="p">(</span><span class="n">field</span><span class="p">:</span><span class="nb">str</span><span class="o">=</span><span class="s1">'avg'</span><span class="p">)</span> <span class="o">-></span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">:</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Get the univariate time series data.</span>
|
||||
|
||||
<span class="sd"> :param field: dataset field to load</span>
|
||||
<span class="sd"> :return: numpy array</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">dat</span> <span class="o">=</span> <span class="n">get_dataframe</span><span class="p">()</span>
|
||||
<span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">dat</span><span class="p">[</span><span class="n">field</span><span class="p">])</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="get_dataframe"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.EURGBP.get_dataframe">[docs]</a><span class="k">def</span> <span class="nf">get_dataframe</span><span class="p">()</span> <span class="o">-></span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">:</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Get the complete multivariate time series data.</span>
|
||||
|
||||
<span class="sd"> :return: Pandas DataFrame</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">df</span> <span class="o">=</span> <span class="n">common</span><span class="o">.</span><span class="n">get_dataframe</span><span class="p">(</span><span class="s2">"EURGBP.csv"</span><span class="p">,</span> <span class="s2">"https://query.data.world/s/gvsaeruthnxjkwzl7z4ki7u5rduah3"</span><span class="p">,</span>
|
||||
<span class="n">sep</span><span class="o">=</span><span class="s2">","</span><span class="p">)</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">df</span></div>
|
||||
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../index.html">
|
||||
<img class="logo" src="../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.data.EURGBP</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
124
docs/build/html/_modules/pyFTS/data/EURUSD.html
vendored
124
docs/build/html/_modules/pyFTS/data/EURUSD.html
vendored
@ -1,124 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.data.EURUSD — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../_static/jquery.js"></script>
|
||||
<script src="../../../_static/underscore.js"></script>
|
||||
<script src="../../../_static/doctools.js"></script>
|
||||
<script src="../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.data.EURUSD</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.data.EURUSD</h1><div class="highlight"><pre>
|
||||
<span></span><span class="sd">"""</span>
|
||||
<span class="sd">FOREX market EUR-USD pair.</span>
|
||||
|
||||
<span class="sd">Daily averaged quotations, by business day, from 2016 to 2018.</span>
|
||||
<span class="sd">"""</span>
|
||||
|
||||
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.data</span> <span class="kn">import</span> <span class="n">common</span>
|
||||
<span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span>
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="get_data"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.EURUSD.get_data">[docs]</a><span class="k">def</span> <span class="nf">get_data</span><span class="p">(</span><span class="n">field</span><span class="p">:</span> <span class="nb">str</span><span class="o">=</span><span class="s1">'avg'</span><span class="p">)</span> <span class="o">-></span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">:</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Get the univariate time series data.</span>
|
||||
|
||||
<span class="sd"> :param field: dataset field to load</span>
|
||||
<span class="sd"> :return: numpy array</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">dat</span> <span class="o">=</span> <span class="n">get_dataframe</span><span class="p">()</span>
|
||||
<span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">dat</span><span class="p">[</span><span class="n">field</span><span class="p">])</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="get_dataframe"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.EURUSD.get_dataframe">[docs]</a><span class="k">def</span> <span class="nf">get_dataframe</span><span class="p">()</span> <span class="o">-></span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">:</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Get the complete multivariate time series data.</span>
|
||||
|
||||
<span class="sd"> :return: Pandas DataFrame</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">df</span> <span class="o">=</span> <span class="n">common</span><span class="o">.</span><span class="n">get_dataframe</span><span class="p">(</span><span class="s2">"EURUSD.csv"</span><span class="p">,</span> <span class="s2">"https://query.data.world/s/od4eojioz4w6o5bbwxjfn6j5zoqtos"</span><span class="p">,</span>
|
||||
<span class="n">sep</span><span class="o">=</span><span class="s2">","</span><span class="p">)</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">df</span></div>
|
||||
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../index.html">
|
||||
<img class="logo" src="../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.data.EURUSD</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
115
docs/build/html/_modules/pyFTS/data/Enrollments.html
vendored
115
docs/build/html/_modules/pyFTS/data/Enrollments.html
vendored
@ -1,115 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.data.Enrollments — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../_static/jquery.js"></script>
|
||||
<script src="../../../_static/underscore.js"></script>
|
||||
<script src="../../../_static/doctools.js"></script>
|
||||
<script src="../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.data.Enrollments</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.data.Enrollments</h1><div class="highlight"><pre>
|
||||
<span></span><span class="sd">"""</span>
|
||||
<span class="sd">Yearly University of Alabama enrollments from 1971 to 1992.</span>
|
||||
<span class="sd">"""</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.data</span> <span class="kn">import</span> <span class="n">common</span>
|
||||
<span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span>
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="get_data"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.Enrollments.get_data">[docs]</a><span class="k">def</span> <span class="nf">get_data</span><span class="p">()</span> <span class="o">-></span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">:</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Get a simple univariate time series data.</span>
|
||||
|
||||
<span class="sd"> :return: numpy array</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">dat</span> <span class="o">=</span> <span class="n">get_dataframe</span><span class="p">()</span>
|
||||
<span class="n">dat</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">dat</span><span class="p">[</span><span class="s2">"Enrollments"</span><span class="p">])</span>
|
||||
<span class="k">return</span> <span class="n">dat</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="get_dataframe"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.Enrollments.get_dataframe">[docs]</a><span class="k">def</span> <span class="nf">get_dataframe</span><span class="p">()</span> <span class="o">-></span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">:</span>
|
||||
<span class="n">dat</span> <span class="o">=</span> <span class="n">common</span><span class="o">.</span><span class="n">get_dataframe</span><span class="p">(</span><span class="s1">'Enrollments.csv'</span><span class="p">,</span>
|
||||
<span class="s1">'https://github.com/petroniocandido/pyFTS/raw/8f20f3634aa6a8f58083bdcd1bbf93795e6ed767/pyFTS/data/Enrollments.csv'</span><span class="p">,</span>
|
||||
<span class="n">sep</span><span class="o">=</span><span class="s2">";"</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">dat</span></div>
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../index.html">
|
||||
<img class="logo" src="../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.data.Enrollments</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
126
docs/build/html/_modules/pyFTS/data/Ethereum.html
vendored
126
docs/build/html/_modules/pyFTS/data/Ethereum.html
vendored
@ -1,126 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.data.Ethereum — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../_static/jquery.js"></script>
|
||||
<script src="../../../_static/underscore.js"></script>
|
||||
<script src="../../../_static/doctools.js"></script>
|
||||
<script src="../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.data.Ethereum</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.data.Ethereum</h1><div class="highlight"><pre>
|
||||
<span></span><span class="sd">"""</span>
|
||||
<span class="sd">Ethereum to USD quotations</span>
|
||||
|
||||
<span class="sd">Daily averaged index, by business day, from 2016 to 2018.</span>
|
||||
|
||||
<span class="sd">Source: https://finance.yahoo.com/quote/ETH-USD?p=ETH-USD</span>
|
||||
<span class="sd">"""</span>
|
||||
|
||||
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.data</span> <span class="kn">import</span> <span class="n">common</span>
|
||||
<span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span>
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="get_data"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.Ethereum.get_data">[docs]</a><span class="k">def</span> <span class="nf">get_data</span><span class="p">(</span><span class="n">field</span><span class="p">:</span> <span class="nb">str</span><span class="o">=</span><span class="s1">'AVG'</span><span class="p">)</span> <span class="o">-></span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">:</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Get the univariate time series data.</span>
|
||||
|
||||
<span class="sd"> :param field: dataset field to load</span>
|
||||
<span class="sd"> :return: numpy array</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">dat</span> <span class="o">=</span> <span class="n">get_dataframe</span><span class="p">()</span>
|
||||
<span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">dat</span><span class="p">[</span><span class="n">field</span><span class="p">])</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="get_dataframe"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.Ethereum.get_dataframe">[docs]</a><span class="k">def</span> <span class="nf">get_dataframe</span><span class="p">()</span> <span class="o">-></span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">:</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Get the complete multivariate time series data.</span>
|
||||
|
||||
<span class="sd"> :return: Pandas DataFrame</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">df</span> <span class="o">=</span> <span class="n">common</span><span class="o">.</span><span class="n">get_dataframe</span><span class="p">(</span><span class="s2">"ETHUSD.csv"</span><span class="p">,</span> <span class="s2">"https://query.data.world/s/qj4ly7o4rl7oq527xzy4v76wkr3hws"</span><span class="p">,</span>
|
||||
<span class="n">sep</span><span class="o">=</span><span class="s2">","</span><span class="p">)</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">df</span></div>
|
||||
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../index.html">
|
||||
<img class="logo" src="../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.data.Ethereum</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
124
docs/build/html/_modules/pyFTS/data/GBPUSD.html
vendored
124
docs/build/html/_modules/pyFTS/data/GBPUSD.html
vendored
@ -1,124 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.data.GBPUSD — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../_static/jquery.js"></script>
|
||||
<script src="../../../_static/underscore.js"></script>
|
||||
<script src="../../../_static/doctools.js"></script>
|
||||
<script src="../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.data.GBPUSD</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.data.GBPUSD</h1><div class="highlight"><pre>
|
||||
<span></span><span class="sd">"""</span>
|
||||
<span class="sd">FOREX market GBP-USD pair.</span>
|
||||
|
||||
<span class="sd">Daily averaged quotations, by business day, from 2016 to 2018.</span>
|
||||
<span class="sd">"""</span>
|
||||
|
||||
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.data</span> <span class="kn">import</span> <span class="n">common</span>
|
||||
<span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span>
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="get_data"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.GBPUSD.get_data">[docs]</a><span class="k">def</span> <span class="nf">get_data</span><span class="p">(</span><span class="n">field</span><span class="p">:</span> <span class="nb">str</span><span class="o">=</span><span class="s1">'avg'</span><span class="p">)</span> <span class="o">-></span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">:</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Get the univariate time series data.</span>
|
||||
|
||||
<span class="sd"> :param field: dataset field to load</span>
|
||||
<span class="sd"> :return: numpy array</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">dat</span> <span class="o">=</span> <span class="n">get_dataframe</span><span class="p">()</span>
|
||||
<span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">dat</span><span class="p">[</span><span class="n">field</span><span class="p">])</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="get_dataframe"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.GBPUSD.get_dataframe">[docs]</a><span class="k">def</span> <span class="nf">get_dataframe</span><span class="p">()</span> <span class="o">-></span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">:</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Get the complete multivariate time series data.</span>
|
||||
|
||||
<span class="sd"> :return: Pandas DataFrame</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">df</span> <span class="o">=</span> <span class="n">common</span><span class="o">.</span><span class="n">get_dataframe</span><span class="p">(</span><span class="s2">"GBPUSD.csv"</span><span class="p">,</span> <span class="s2">"https://query.data.world/s/sw4mijpowb3mqv6bsat7cdj54hyxix"</span><span class="p">,</span>
|
||||
<span class="n">sep</span><span class="o">=</span><span class="s2">","</span><span class="p">)</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">df</span></div>
|
||||
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../index.html">
|
||||
<img class="logo" src="../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.data.GBPUSD</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
113
docs/build/html/_modules/pyFTS/data/INMET.html
vendored
113
docs/build/html/_modules/pyFTS/data/INMET.html
vendored
@ -1,113 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.data.INMET — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../_static/jquery.js"></script>
|
||||
<script src="../../../_static/underscore.js"></script>
|
||||
<script src="../../../_static/doctools.js"></script>
|
||||
<script src="../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.data.INMET</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.data.INMET</h1><div class="highlight"><pre>
|
||||
<span></span><span class="sd">"""</span>
|
||||
<span class="sd">INMET - Instituto Nacional Meteorologia / Brasil</span>
|
||||
|
||||
<span class="sd">Belo Horizonte station, from 2000-01-01 to 31/12/2012</span>
|
||||
|
||||
<span class="sd">Source: http://www.inmet.gov.br</span>
|
||||
<span class="sd">"""</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.data</span> <span class="kn">import</span> <span class="n">common</span>
|
||||
<span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="get_dataframe"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.INMET.get_dataframe">[docs]</a><span class="k">def</span> <span class="nf">get_dataframe</span><span class="p">()</span> <span class="o">-></span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">:</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Get the complete multivariate time series data.</span>
|
||||
|
||||
<span class="sd"> :return: Pandas DataFrame</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">dat</span> <span class="o">=</span> <span class="n">common</span><span class="o">.</span><span class="n">get_dataframe</span><span class="p">(</span><span class="s1">'INMET.csv.bz2'</span><span class="p">,</span>
|
||||
<span class="s1">'https://github.com/petroniocandido/pyFTS/raw/8f20f3634aa6a8f58083bdcd1bbf93795e6ed767/pyFTS/data/INMET.csv.bz2'</span><span class="p">,</span>
|
||||
<span class="n">sep</span><span class="o">=</span><span class="s2">";"</span><span class="p">,</span> <span class="n">compression</span><span class="o">=</span><span class="s1">'bz2'</span><span class="p">)</span>
|
||||
<span class="n">dat</span><span class="p">[</span><span class="s2">"DataHora"</span><span class="p">]</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">to_datetime</span><span class="p">(</span><span class="n">dat</span><span class="p">[</span><span class="s2">"DataHora"</span><span class="p">],</span> <span class="nb">format</span><span class="o">=</span><span class="s1">'</span><span class="si">%d</span><span class="s1">/%m/%Y %H:%M'</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">dat</span></div>
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../index.html">
|
||||
<img class="logo" src="../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.data.INMET</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
123
docs/build/html/_modules/pyFTS/data/Malaysia.html
vendored
123
docs/build/html/_modules/pyFTS/data/Malaysia.html
vendored
@ -1,123 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.data.Malaysia — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../_static/jquery.js"></script>
|
||||
<script src="../../../_static/underscore.js"></script>
|
||||
<script src="../../../_static/doctools.js"></script>
|
||||
<script src="../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.data.Malaysia</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.data.Malaysia</h1><div class="highlight"><pre>
|
||||
<span></span><span class="sd">"""</span>
|
||||
<span class="sd">Hourly Malaysia eletric load and tempeature</span>
|
||||
<span class="sd">"""</span>
|
||||
|
||||
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.data</span> <span class="kn">import</span> <span class="n">common</span>
|
||||
<span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span>
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="get_data"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.Malaysia.get_data">[docs]</a><span class="k">def</span> <span class="nf">get_data</span><span class="p">(</span><span class="n">field</span><span class="p">:</span> <span class="nb">str</span><span class="o">=</span><span class="s1">'load'</span><span class="p">)</span> <span class="o">-></span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">:</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Get the univariate time series data.</span>
|
||||
|
||||
<span class="sd"> :param field: dataset field to load</span>
|
||||
<span class="sd"> :return: numpy array</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">dat</span> <span class="o">=</span> <span class="n">get_dataframe</span><span class="p">()</span>
|
||||
<span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">dat</span><span class="p">[</span><span class="n">field</span><span class="p">])</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="get_dataframe"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.Malaysia.get_dataframe">[docs]</a><span class="k">def</span> <span class="nf">get_dataframe</span><span class="p">()</span> <span class="o">-></span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">:</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Get the complete multivariate time series data.</span>
|
||||
|
||||
<span class="sd"> :return: Pandas DataFrame</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">df</span> <span class="o">=</span> <span class="n">common</span><span class="o">.</span><span class="n">get_dataframe</span><span class="p">(</span><span class="s2">"malaysia.csv"</span><span class="p">,</span><span class="s2">"https://query.data.world/s/e5arbthdytod3m7wfcg7gmtluh3wa5"</span><span class="p">,</span>
|
||||
<span class="n">sep</span><span class="o">=</span><span class="s2">";"</span><span class="p">)</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">df</span></div>
|
||||
|
||||
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../index.html">
|
||||
<img class="logo" src="../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.data.Malaysia</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
126
docs/build/html/_modules/pyFTS/data/NASDAQ.html
vendored
126
docs/build/html/_modules/pyFTS/data/NASDAQ.html
vendored
@ -1,126 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.data.NASDAQ — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../_static/jquery.js"></script>
|
||||
<script src="../../../_static/underscore.js"></script>
|
||||
<script src="../../../_static/doctools.js"></script>
|
||||
<script src="../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.data.NASDAQ</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.data.NASDAQ</h1><div class="highlight"><pre>
|
||||
<span></span><span class="sd">"""</span>
|
||||
<span class="sd">National Association of Securities Dealers Automated Quotations - Composite Index (NASDAQ IXIC)</span>
|
||||
|
||||
<span class="sd">Daily averaged index by business day, from 2000 to 2016.</span>
|
||||
|
||||
<span class="sd">Source: http://www.nasdaq.com/aspx/flashquotes.aspx?symbol=IXIC&selected=IXIC</span>
|
||||
<span class="sd">"""</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.data</span> <span class="kn">import</span> <span class="n">common</span>
|
||||
<span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span>
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="get_data"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.NASDAQ.get_data">[docs]</a><span class="k">def</span> <span class="nf">get_data</span><span class="p">(</span><span class="n">field</span><span class="p">:</span> <span class="nb">str</span><span class="o">=</span><span class="s2">"avg"</span><span class="p">)</span> <span class="o">-></span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">:</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Get a simple univariate time series data.</span>
|
||||
|
||||
<span class="sd"> :param field: the dataset field name to extract</span>
|
||||
<span class="sd"> :return: numpy array</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">dat</span> <span class="o">=</span> <span class="n">get_dataframe</span><span class="p">()</span>
|
||||
<span class="n">dat</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">dat</span><span class="p">[</span><span class="n">field</span><span class="p">])</span>
|
||||
<span class="k">return</span> <span class="n">dat</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="get_dataframe"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.NASDAQ.get_dataframe">[docs]</a><span class="k">def</span> <span class="nf">get_dataframe</span><span class="p">()</span> <span class="o">-></span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">:</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Get the complete multivariate time series data.</span>
|
||||
|
||||
<span class="sd"> :return: Pandas DataFrame</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">dat</span> <span class="o">=</span> <span class="n">common</span><span class="o">.</span><span class="n">get_dataframe</span><span class="p">(</span><span class="s1">'NASDAQ.csv.bz2'</span><span class="p">,</span>
|
||||
<span class="s1">'https://github.com/petroniocandido/pyFTS/raw/8f20f3634aa6a8f58083bdcd1bbf93795e6ed767/pyFTS/data/NASDAQ.csv.bz2'</span><span class="p">,</span>
|
||||
<span class="n">sep</span><span class="o">=</span><span class="s2">","</span><span class="p">,</span> <span class="n">compression</span><span class="o">=</span><span class="s1">'bz2'</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">dat</span></div>
|
||||
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../index.html">
|
||||
<img class="logo" src="../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.data.NASDAQ</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
127
docs/build/html/_modules/pyFTS/data/SONDA.html
vendored
127
docs/build/html/_modules/pyFTS/data/SONDA.html
vendored
@ -1,127 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.data.SONDA — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../_static/jquery.js"></script>
|
||||
<script src="../../../_static/underscore.js"></script>
|
||||
<script src="../../../_static/doctools.js"></script>
|
||||
<script src="../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.data.SONDA</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.data.SONDA</h1><div class="highlight"><pre>
|
||||
<span></span><span class="sd">"""</span>
|
||||
<span class="sd">SONDA - Sistema de Organização Nacional de Dados Ambientais, from INPE - Instituto Nacional de Pesquisas Espaciais, Brasil.</span>
|
||||
|
||||
<span class="sd">Brasilia station</span>
|
||||
|
||||
<span class="sd">Source: http://sonda.ccst.inpe.br/</span>
|
||||
|
||||
<span class="sd">"""</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.data</span> <span class="kn">import</span> <span class="n">common</span>
|
||||
<span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span>
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="get_data"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.SONDA.get_data">[docs]</a><span class="k">def</span> <span class="nf">get_data</span><span class="p">(</span><span class="n">field</span><span class="p">:</span><span class="nb">str</span><span class="p">)</span> <span class="o">-></span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">:</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Get a simple univariate time series data.</span>
|
||||
|
||||
<span class="sd"> :param field: the dataset field name to extract</span>
|
||||
<span class="sd"> :return: numpy array</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">dat</span> <span class="o">=</span> <span class="n">get_dataframe</span><span class="p">()</span>
|
||||
<span class="n">dat</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">dat</span><span class="p">[</span><span class="n">field</span><span class="p">])</span>
|
||||
<span class="k">return</span> <span class="n">dat</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="get_dataframe"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.SONDA.get_dataframe">[docs]</a><span class="k">def</span> <span class="nf">get_dataframe</span><span class="p">()</span> <span class="o">-></span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">:</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Get the complete multivariate time series data.</span>
|
||||
|
||||
<span class="sd"> :return: Pandas DataFrame</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">dat</span> <span class="o">=</span> <span class="n">common</span><span class="o">.</span><span class="n">get_dataframe</span><span class="p">(</span><span class="s1">'SONDA_BSB.csv.bz2'</span><span class="p">,</span>
|
||||
<span class="s1">'https://github.com/petroniocandido/pyFTS/raw/8f20f3634aa6a8f58083bdcd1bbf93795e6ed767/pyFTS/data/SONDA_BSB.csv.bz2'</span><span class="p">,</span>
|
||||
<span class="n">sep</span><span class="o">=</span><span class="s2">";"</span><span class="p">,</span> <span class="n">compression</span><span class="o">=</span><span class="s1">'bz2'</span><span class="p">)</span>
|
||||
<span class="n">dat</span><span class="p">[</span><span class="s2">"datahora"</span><span class="p">]</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">to_datetime</span><span class="p">(</span><span class="n">dat</span><span class="p">[</span><span class="s2">"datahora"</span><span class="p">],</span> <span class="nb">format</span><span class="o">=</span><span class="s1">'%Y-%m-</span><span class="si">%d</span><span class="s1"> %H:%M:%S'</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">dat</span></div>
|
||||
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../index.html">
|
||||
<img class="logo" src="../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.data.SONDA</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
124
docs/build/html/_modules/pyFTS/data/SP500.html
vendored
124
docs/build/html/_modules/pyFTS/data/SP500.html
vendored
@ -1,124 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.data.SP500 — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../_static/jquery.js"></script>
|
||||
<script src="../../../_static/underscore.js"></script>
|
||||
<script src="../../../_static/doctools.js"></script>
|
||||
<script src="../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.data.SP500</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.data.SP500</h1><div class="highlight"><pre>
|
||||
<span></span><span class="sd">"""</span>
|
||||
<span class="sd">S&P500 - Standard & Poor's 500</span>
|
||||
|
||||
<span class="sd">Daily averaged index, by business day, from 1950 to 2017.</span>
|
||||
|
||||
<span class="sd">Source: https://finance.yahoo.com/quote/%5EGSPC/history?p=%5EGSPC</span>
|
||||
<span class="sd">"""</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.data</span> <span class="kn">import</span> <span class="n">common</span>
|
||||
<span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span>
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="get_data"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.SP500.get_data">[docs]</a><span class="k">def</span> <span class="nf">get_data</span><span class="p">()</span> <span class="o">-></span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">:</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Get the univariate time series data.</span>
|
||||
|
||||
<span class="sd"> :return: numpy array</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">dat</span> <span class="o">=</span> <span class="n">get_dataframe</span><span class="p">()</span>
|
||||
<span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">dat</span><span class="p">[</span><span class="s2">"Avg"</span><span class="p">])</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="get_dataframe"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.SP500.get_dataframe">[docs]</a><span class="k">def</span> <span class="nf">get_dataframe</span><span class="p">()</span> <span class="o">-></span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">:</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Get the complete multivariate time series data.</span>
|
||||
|
||||
<span class="sd"> :return: Pandas DataFrame</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">dat</span> <span class="o">=</span> <span class="n">common</span><span class="o">.</span><span class="n">get_dataframe</span><span class="p">(</span><span class="s1">'SP500.csv.bz2'</span><span class="p">,</span>
|
||||
<span class="s1">'https://github.com/petroniocandido/pyFTS/raw/8f20f3634aa6a8f58083bdcd1bbf93795e6ed767/pyFTS/data/SP500.csv.bz2'</span><span class="p">,</span>
|
||||
<span class="n">sep</span><span class="o">=</span><span class="s2">","</span><span class="p">,</span> <span class="n">compression</span><span class="o">=</span><span class="s1">'bz2'</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">dat</span></div>
|
||||
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../index.html">
|
||||
<img class="logo" src="../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.data.SP500</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
125
docs/build/html/_modules/pyFTS/data/TAIEX.html
vendored
125
docs/build/html/_modules/pyFTS/data/TAIEX.html
vendored
@ -1,125 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.data.TAIEX — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../_static/jquery.js"></script>
|
||||
<script src="../../../_static/underscore.js"></script>
|
||||
<script src="../../../_static/doctools.js"></script>
|
||||
<script src="../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.data.TAIEX</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.data.TAIEX</h1><div class="highlight"><pre>
|
||||
<span></span><span class="sd">"""</span>
|
||||
<span class="sd">The Taiwan Stock Exchange Capitalization Weighted Stock Index (TAIEX)</span>
|
||||
|
||||
<span class="sd">Daily averaged index by business day, from 1995 to 2014.</span>
|
||||
|
||||
<span class="sd">Source: http://www.twse.com.tw/en/products/indices/Index_Series.php</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.data</span> <span class="kn">import</span> <span class="n">common</span>
|
||||
<span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span>
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="get_data"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.TAIEX.get_data">[docs]</a><span class="k">def</span> <span class="nf">get_data</span><span class="p">()</span> <span class="o">-></span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">:</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Get the univariate time series data.</span>
|
||||
|
||||
<span class="sd"> :return: numpy array</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">dat</span> <span class="o">=</span> <span class="n">get_dataframe</span><span class="p">()</span>
|
||||
<span class="n">dat</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">dat</span><span class="p">[</span><span class="s2">"avg"</span><span class="p">])</span>
|
||||
<span class="k">return</span> <span class="n">dat</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="get_dataframe"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.TAIEX.get_dataframe">[docs]</a><span class="k">def</span> <span class="nf">get_dataframe</span><span class="p">()</span> <span class="o">-></span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">:</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Get the complete multivariate time series data.</span>
|
||||
|
||||
<span class="sd"> :return: Pandas DataFrame</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">dat</span> <span class="o">=</span> <span class="n">common</span><span class="o">.</span><span class="n">get_dataframe</span><span class="p">(</span><span class="s1">'TAIEX.csv.bz2'</span><span class="p">,</span>
|
||||
<span class="s1">'https://github.com/petroniocandido/pyFTS/raw/8f20f3634aa6a8f58083bdcd1bbf93795e6ed767/pyFTS/data/TAIEX.csv.bz2'</span><span class="p">,</span>
|
||||
<span class="n">sep</span><span class="o">=</span><span class="s2">","</span><span class="p">,</span> <span class="n">compression</span><span class="o">=</span><span class="s1">'bz2'</span><span class="p">)</span>
|
||||
<span class="n">dat</span><span class="p">[</span><span class="s2">"Date"</span><span class="p">]</span> <span class="o">=</span> <span class="n">pd</span><span class="o">.</span><span class="n">to_datetime</span><span class="p">(</span><span class="n">dat</span><span class="p">[</span><span class="s2">"Date"</span><span class="p">])</span>
|
||||
<span class="k">return</span> <span class="n">dat</span></div>
|
||||
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../index.html">
|
||||
<img class="logo" src="../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.data.TAIEX</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
430
docs/build/html/_modules/pyFTS/data/artificial.html
vendored
430
docs/build/html/_modules/pyFTS/data/artificial.html
vendored
@ -1,430 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.data.artificial — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../_static/jquery.js"></script>
|
||||
<script src="../../../_static/underscore.js"></script>
|
||||
<script src="../../../_static/doctools.js"></script>
|
||||
<script src="../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.data.artificial</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.data.artificial</h1><div class="highlight"><pre>
|
||||
<span></span><span class="sd">"""</span>
|
||||
<span class="sd">Facilities to generate synthetic stochastic processes</span>
|
||||
<span class="sd">"""</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="SignalEmulator"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.artificial.SignalEmulator">[docs]</a><span class="k">class</span> <span class="nc">SignalEmulator</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Emulate a complex signal built from several additive and non-additive components</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">SignalEmulator</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">()</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">components</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="w"> </span><span class="sd">"""Components of the signal"""</span>
|
||||
|
||||
<div class="viewcode-block" id="SignalEmulator.stationary_gaussian"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.artificial.SignalEmulator.stationary_gaussian">[docs]</a> <span class="k">def</span> <span class="nf">stationary_gaussian</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">mu</span><span class="p">:</span><span class="nb">float</span><span class="p">,</span> <span class="n">sigma</span><span class="p">:</span><span class="nb">float</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Creates a continuous Gaussian signal with mean mu and variance sigma.</span>
|
||||
|
||||
<span class="sd"> :param mu: mean</span>
|
||||
<span class="sd"> :param sigma: variance</span>
|
||||
<span class="sd"> :keyword additive: If False it cancels the previous signal and start this one, if True</span>
|
||||
<span class="sd"> this signal is added to the previous one</span>
|
||||
<span class="sd"> :keyword start: lag index to start this signal, the default value is 0</span>
|
||||
<span class="sd"> :keyword it: Number of iterations, the default value is 1</span>
|
||||
<span class="sd"> :keyword length: Number of samples generated on each iteration, the default value is 100</span>
|
||||
<span class="sd"> :keyword vmin: Lower bound value of generated data, the default value is None</span>
|
||||
<span class="sd"> :keyword vmax: Upper bound value of generated data, the default value is None</span>
|
||||
<span class="sd"> :return: the current SignalEmulator instance, for method chaining</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">parameters</span> <span class="o">=</span> <span class="p">{</span><span class="s1">'mu'</span><span class="p">:</span> <span class="n">mu</span><span class="p">,</span> <span class="s1">'sigma'</span><span class="p">:</span> <span class="n">sigma</span><span class="p">}</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">components</span><span class="o">.</span><span class="n">append</span><span class="p">({</span><span class="s1">'dist'</span><span class="p">:</span> <span class="s1">'gaussian'</span><span class="p">,</span> <span class="s1">'type'</span><span class="p">:</span> <span class="s1">'constant'</span><span class="p">,</span>
|
||||
<span class="s1">'parameters'</span><span class="p">:</span> <span class="n">parameters</span><span class="p">,</span> <span class="s1">'args'</span><span class="p">:</span> <span class="n">kwargs</span><span class="p">})</span>
|
||||
<span class="k">return</span> <span class="bp">self</span></div>
|
||||
|
||||
<div class="viewcode-block" id="SignalEmulator.incremental_gaussian"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.artificial.SignalEmulator.incremental_gaussian">[docs]</a> <span class="k">def</span> <span class="nf">incremental_gaussian</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">mu</span><span class="p">:</span><span class="nb">float</span><span class="p">,</span> <span class="n">sigma</span><span class="p">:</span><span class="nb">float</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Creates an additive gaussian interference on a previous signal</span>
|
||||
|
||||
<span class="sd"> :param mu: increment on mean</span>
|
||||
<span class="sd"> :param sigma: increment on variance</span>
|
||||
<span class="sd"> :keyword start: lag index to start this signal, the default value is 0</span>
|
||||
<span class="sd"> :keyword it: Number of iterations, the default value is 1</span>
|
||||
<span class="sd"> :keyword length: Number of samples generated on each iteration, the default value is 100</span>
|
||||
<span class="sd"> :keyword vmin: Lower bound value of generated data, the default value is None</span>
|
||||
<span class="sd"> :keyword vmax: Upper bound value of generated data, the default value is None</span>
|
||||
<span class="sd"> :return: the current SignalEmulator instance, for method chaining</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">parameters</span> <span class="o">=</span> <span class="p">{</span><span class="s1">'mu'</span><span class="p">:</span> <span class="n">mu</span><span class="p">,</span> <span class="s1">'sigma'</span><span class="p">:</span> <span class="n">sigma</span><span class="p">}</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">components</span><span class="o">.</span><span class="n">append</span><span class="p">({</span><span class="s1">'dist'</span><span class="p">:</span> <span class="s1">'gaussian'</span><span class="p">,</span> <span class="s1">'type'</span><span class="p">:</span> <span class="s1">'incremental'</span><span class="p">,</span>
|
||||
<span class="s1">'parameters'</span><span class="p">:</span> <span class="n">parameters</span><span class="p">,</span> <span class="s1">'args'</span><span class="p">:</span> <span class="n">kwargs</span><span class="p">})</span>
|
||||
<span class="k">return</span> <span class="bp">self</span></div>
|
||||
|
||||
<div class="viewcode-block" id="SignalEmulator.periodic_gaussian"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.artificial.SignalEmulator.periodic_gaussian">[docs]</a> <span class="k">def</span> <span class="nf">periodic_gaussian</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="nb">type</span><span class="p">:</span><span class="nb">str</span><span class="p">,</span> <span class="n">period</span><span class="p">:</span><span class="nb">int</span><span class="p">,</span> <span class="n">mu_min</span><span class="p">:</span><span class="nb">float</span><span class="p">,</span> <span class="n">sigma_min</span><span class="p">:</span><span class="nb">float</span><span class="p">,</span> <span class="n">mu_max</span><span class="p">:</span><span class="nb">float</span><span class="p">,</span> <span class="n">sigma_max</span><span class="p">:</span><span class="nb">float</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Creates an additive periodic gaussian interference on a previous signal</span>
|
||||
|
||||
<span class="sd"> :param type: 'linear' or 'sinoidal'</span>
|
||||
<span class="sd"> :param period: the period of recurrence</span>
|
||||
<span class="sd"> :param mu: increment on mean</span>
|
||||
<span class="sd"> :param sigma: increment on variance</span>
|
||||
<span class="sd"> :keyword start: lag index to start this signal, the default value is 0</span>
|
||||
<span class="sd"> :keyword it: Number of iterations, the default value is 1</span>
|
||||
<span class="sd"> :keyword length: Number of samples generated on each iteration, the default value is 100</span>
|
||||
<span class="sd"> :keyword vmin: Lower bound value of generated data, the default value is None</span>
|
||||
<span class="sd"> :keyword vmax: Upper bound value of generated data, the default value is None</span>
|
||||
<span class="sd"> :return: the current SignalEmulator instance, for method chaining</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">parameters</span> <span class="o">=</span> <span class="p">{</span><span class="s1">'type'</span><span class="p">:</span><span class="nb">type</span><span class="p">,</span> <span class="s1">'period'</span><span class="p">:</span><span class="n">period</span><span class="p">,</span>
|
||||
<span class="s1">'mu_min'</span><span class="p">:</span> <span class="n">mu_min</span><span class="p">,</span> <span class="s1">'sigma_min'</span><span class="p">:</span> <span class="n">sigma_min</span><span class="p">,</span> <span class="s1">'mu_max'</span><span class="p">:</span> <span class="n">mu_max</span><span class="p">,</span> <span class="s1">'sigma_max'</span><span class="p">:</span> <span class="n">sigma_max</span><span class="p">}</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">components</span><span class="o">.</span><span class="n">append</span><span class="p">({</span><span class="s1">'dist'</span><span class="p">:</span> <span class="s1">'gaussian'</span><span class="p">,</span> <span class="s1">'type'</span><span class="p">:</span> <span class="s1">'periodic'</span><span class="p">,</span>
|
||||
<span class="s1">'parameters'</span><span class="p">:</span> <span class="n">parameters</span><span class="p">,</span> <span class="s1">'args'</span><span class="p">:</span> <span class="n">kwargs</span><span class="p">})</span>
|
||||
<span class="k">return</span> <span class="bp">self</span></div>
|
||||
|
||||
<div class="viewcode-block" id="SignalEmulator.blip"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.artificial.SignalEmulator.blip">[docs]</a> <span class="k">def</span> <span class="nf">blip</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Creates an outlier greater than the maximum or lower then the minimum previous values of the signal,</span>
|
||||
<span class="sd"> and insert it on a random location of the signal.</span>
|
||||
|
||||
<span class="sd"> :return: the current SignalEmulator instance, for method chaining</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">parameters</span> <span class="o">=</span> <span class="p">{}</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">components</span><span class="o">.</span><span class="n">append</span><span class="p">({</span><span class="s1">'dist'</span><span class="p">:</span> <span class="s1">'blip'</span><span class="p">,</span> <span class="s1">'type'</span><span class="p">:</span> <span class="s1">'blip'</span><span class="p">,</span>
|
||||
<span class="s1">'parameters'</span><span class="p">:</span> <span class="n">parameters</span><span class="p">,</span> <span class="s1">'args'</span><span class="p">:</span><span class="n">kwargs</span><span class="p">})</span>
|
||||
<span class="k">return</span> <span class="bp">self</span></div>
|
||||
|
||||
<div class="viewcode-block" id="SignalEmulator.run"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.artificial.SignalEmulator.run">[docs]</a> <span class="k">def</span> <span class="nf">run</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Render the signal</span>
|
||||
|
||||
<span class="sd"> :return: a list of float values</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">signal</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="n">last_it</span> <span class="o">=</span> <span class="mi">10</span>
|
||||
<span class="n">last_num</span> <span class="o">=</span> <span class="mi">10</span>
|
||||
<span class="k">for</span> <span class="n">ct</span><span class="p">,</span> <span class="n">component</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">components</span><span class="p">):</span>
|
||||
<span class="n">parameters</span> <span class="o">=</span> <span class="n">component</span><span class="p">[</span><span class="s1">'parameters'</span><span class="p">]</span>
|
||||
<span class="n">kwargs</span> <span class="o">=</span> <span class="n">component</span><span class="p">[</span><span class="s1">'args'</span><span class="p">]</span>
|
||||
<span class="n">additive</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'additive'</span><span class="p">,</span> <span class="kc">True</span><span class="p">)</span>
|
||||
<span class="n">start</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'start'</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
|
||||
<span class="n">it</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'it'</span><span class="p">,</span> <span class="n">last_it</span><span class="p">)</span>
|
||||
<span class="n">num</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'length'</span><span class="p">,</span> <span class="n">last_num</span><span class="p">)</span>
|
||||
<span class="n">vmin</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'vmin'</span><span class="p">,</span><span class="kc">None</span><span class="p">)</span>
|
||||
<span class="n">vmax</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'vmax'</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">component</span><span class="p">[</span><span class="s1">'type'</span><span class="p">]</span> <span class="o">==</span> <span class="s1">'constant'</span><span class="p">:</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">generate_gaussian_linear</span><span class="p">(</span><span class="n">parameters</span><span class="p">[</span><span class="s1">'mu'</span><span class="p">],</span> <span class="n">parameters</span><span class="p">[</span><span class="s1">'sigma'</span><span class="p">],</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span>
|
||||
<span class="n">it</span><span class="o">=</span><span class="n">it</span><span class="p">,</span> <span class="n">num</span><span class="o">=</span><span class="n">num</span><span class="p">,</span> <span class="n">vmin</span><span class="o">=</span><span class="n">vmin</span><span class="p">,</span> <span class="n">vmax</span><span class="o">=</span><span class="n">vmax</span><span class="p">)</span>
|
||||
<span class="k">elif</span> <span class="n">component</span><span class="p">[</span><span class="s1">'type'</span><span class="p">]</span> <span class="o">==</span> <span class="s1">'incremental'</span><span class="p">:</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">generate_gaussian_linear</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">parameters</span><span class="p">[</span><span class="s1">'mu'</span><span class="p">],</span> <span class="n">parameters</span><span class="p">[</span><span class="s1">'sigma'</span><span class="p">],</span>
|
||||
<span class="n">it</span><span class="o">=</span><span class="n">num</span><span class="p">,</span> <span class="n">num</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">vmin</span><span class="o">=</span><span class="n">vmin</span><span class="p">,</span> <span class="n">vmax</span><span class="o">=</span><span class="n">vmax</span><span class="p">)</span>
|
||||
<span class="k">elif</span> <span class="n">component</span><span class="p">[</span><span class="s1">'type'</span><span class="p">]</span> <span class="o">==</span> <span class="s1">'periodic'</span><span class="p">:</span>
|
||||
<span class="n">period</span> <span class="o">=</span> <span class="n">parameters</span><span class="p">[</span><span class="s1">'period'</span><span class="p">]</span>
|
||||
<span class="n">mu_min</span><span class="p">,</span> <span class="n">sigma_min</span> <span class="o">=</span> <span class="n">parameters</span><span class="p">[</span><span class="s1">'mu_min'</span><span class="p">],</span><span class="n">parameters</span><span class="p">[</span><span class="s1">'sigma_min'</span><span class="p">]</span>
|
||||
<span class="n">mu_max</span><span class="p">,</span> <span class="n">sigma_max</span> <span class="o">=</span> <span class="n">parameters</span><span class="p">[</span><span class="s1">'mu_max'</span><span class="p">],</span><span class="n">parameters</span><span class="p">[</span><span class="s1">'sigma_max'</span><span class="p">]</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">parameters</span><span class="p">[</span><span class="s1">'type'</span><span class="p">]</span> <span class="o">==</span> <span class="s1">'sinoidal'</span><span class="p">:</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">generate_sinoidal_periodic_gaussian</span><span class="p">(</span><span class="n">period</span><span class="p">,</span> <span class="n">mu_min</span><span class="p">,</span> <span class="n">sigma_min</span><span class="p">,</span> <span class="n">mu_max</span><span class="p">,</span> <span class="n">sigma_max</span><span class="p">,</span>
|
||||
<span class="n">it</span><span class="o">=</span><span class="n">num</span><span class="p">,</span> <span class="n">num</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">vmin</span><span class="o">=</span><span class="n">vmin</span><span class="p">,</span> <span class="n">vmax</span><span class="o">=</span><span class="n">vmax</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">generate_linear_periodic_gaussian</span><span class="p">(</span><span class="n">period</span><span class="p">,</span> <span class="n">mu_min</span><span class="p">,</span> <span class="n">sigma_min</span><span class="p">,</span> <span class="n">mu_max</span><span class="p">,</span> <span class="n">sigma_max</span><span class="p">,</span>
|
||||
<span class="n">it</span><span class="o">=</span><span class="n">num</span><span class="p">,</span> <span class="n">num</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">vmin</span><span class="o">=</span><span class="n">vmin</span><span class="p">,</span> <span class="n">vmax</span><span class="o">=</span><span class="n">vmax</span><span class="p">)</span>
|
||||
<span class="k">elif</span> <span class="n">component</span><span class="p">[</span><span class="s1">'type'</span><span class="p">]</span> <span class="o">==</span> <span class="s1">'blip'</span><span class="p">:</span>
|
||||
<span class="n">_mx</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">nanmax</span><span class="p">(</span><span class="n">signal</span><span class="p">)</span>
|
||||
<span class="n">_mn</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">nanmin</span><span class="p">(</span><span class="n">signal</span><span class="p">)</span>
|
||||
|
||||
<span class="n">_mx</span> <span class="o">+=</span> <span class="mi">2</span><span class="o">*</span><span class="n">_mx</span> <span class="k">if</span> <span class="n">_mx</span> <span class="o">></span> <span class="mi">0</span> <span class="k">else</span> <span class="o">-</span><span class="mi">2</span><span class="o">*</span><span class="n">_mx</span>
|
||||
<span class="n">_mn</span> <span class="o">+=</span> <span class="o">-</span><span class="mi">2</span><span class="o">*</span><span class="n">_mn</span> <span class="k">if</span> <span class="n">_mn</span> <span class="o">></span> <span class="mi">0</span> <span class="k">else</span> <span class="mi">2</span><span class="o">*</span><span class="n">_mn</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">vmax</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">_mx</span> <span class="o">=</span> <span class="nb">min</span><span class="p">(</span><span class="n">_mx</span><span class="p">,</span> <span class="n">vmax</span><span class="p">)</span> <span class="k">if</span> <span class="n">vmax</span> <span class="o">></span> <span class="mi">0</span> <span class="k">else</span> <span class="nb">max</span><span class="p">(</span><span class="n">_mx</span><span class="p">,</span> <span class="n">vmax</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">vmin</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">_mn</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="n">_mn</span><span class="p">,</span> <span class="n">vmin</span><span class="p">)</span> <span class="k">if</span> <span class="n">vmin</span> <span class="o">></span> <span class="mi">0</span> <span class="k">else</span> <span class="nb">min</span><span class="p">(</span><span class="n">_mn</span><span class="p">,</span> <span class="n">vmin</span><span class="p">)</span>
|
||||
|
||||
<span class="n">start</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">randint</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">signal</span><span class="p">))</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="p">[</span><span class="n">_mx</span><span class="p">]</span> <span class="k">if</span> <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">rand</span><span class="p">()</span> <span class="o">>=</span> <span class="mf">.5</span> <span class="k">else</span> <span class="p">[</span><span class="o">-</span><span class="n">_mn</span><span class="p">]</span>
|
||||
|
||||
<span class="n">last_num</span> <span class="o">=</span> <span class="n">num</span>
|
||||
<span class="n">last_it</span> <span class="o">=</span> <span class="n">it</span>
|
||||
|
||||
<span class="n">signal</span> <span class="o">=</span> <span class="n">_append</span><span class="p">(</span><span class="n">additive</span><span class="p">,</span> <span class="n">start</span><span class="p">,</span> <span class="n">signal</span><span class="p">,</span> <span class="n">tmp</span><span class="p">)</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">signal</span></div></div>
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="viewcode-block" id="generate_gaussian_linear"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.artificial.generate_gaussian_linear">[docs]</a><span class="k">def</span> <span class="nf">generate_gaussian_linear</span><span class="p">(</span><span class="n">mu_ini</span><span class="p">,</span> <span class="n">sigma_ini</span><span class="p">,</span> <span class="n">mu_inc</span><span class="p">,</span> <span class="n">sigma_inc</span><span class="p">,</span> <span class="n">it</span><span class="o">=</span><span class="mi">100</span><span class="p">,</span> <span class="n">num</span><span class="o">=</span><span class="mi">10</span><span class="p">,</span> <span class="n">vmin</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">vmax</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Generate data sampled from Gaussian distribution, with constant or linear changing parameters</span>
|
||||
|
||||
<span class="sd"> :param mu_ini: Initial mean</span>
|
||||
<span class="sd"> :param sigma_ini: Initial variance</span>
|
||||
<span class="sd"> :param mu_inc: Mean increment after 'num' samples</span>
|
||||
<span class="sd"> :param sigma_inc: Variance increment after 'num' samples</span>
|
||||
<span class="sd"> :param it: Number of iterations</span>
|
||||
<span class="sd"> :param num: Number of samples generated on each iteration</span>
|
||||
<span class="sd"> :param vmin: Lower bound value of generated data</span>
|
||||
<span class="sd"> :param vmax: Upper bound value of generated data</span>
|
||||
<span class="sd"> :return: A list of it*num float values</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">mu</span> <span class="o">=</span> <span class="n">mu_ini</span>
|
||||
<span class="n">sigma</span> <span class="o">=</span> <span class="n">sigma_ini</span>
|
||||
<span class="n">ret</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="n">it</span><span class="p">):</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">normal</span><span class="p">(</span><span class="n">mu</span><span class="p">,</span> <span class="n">sigma</span><span class="p">,</span> <span class="n">num</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">vmin</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">maximum</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">full</span><span class="p">(</span><span class="n">num</span><span class="p">,</span> <span class="n">vmin</span><span class="p">),</span> <span class="n">tmp</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">vmax</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">minimum</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">full</span><span class="p">(</span><span class="n">num</span><span class="p">,</span> <span class="n">vmax</span><span class="p">),</span> <span class="n">tmp</span><span class="p">)</span>
|
||||
<span class="n">ret</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">tmp</span><span class="p">)</span>
|
||||
<span class="n">mu</span> <span class="o">+=</span> <span class="n">mu_inc</span>
|
||||
<span class="n">sigma</span> <span class="o">+=</span> <span class="n">sigma_inc</span>
|
||||
<span class="k">return</span> <span class="n">ret</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="generate_linear_periodic_gaussian"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.artificial.generate_linear_periodic_gaussian">[docs]</a><span class="k">def</span> <span class="nf">generate_linear_periodic_gaussian</span><span class="p">(</span><span class="n">period</span><span class="p">,</span> <span class="n">mu_min</span><span class="p">,</span> <span class="n">sigma_min</span><span class="p">,</span> <span class="n">mu_max</span><span class="p">,</span> <span class="n">sigma_max</span><span class="p">,</span> <span class="n">it</span><span class="o">=</span><span class="mi">100</span><span class="p">,</span> <span class="n">num</span><span class="o">=</span><span class="mi">10</span><span class="p">,</span> <span class="n">vmin</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">vmax</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Generates a periodic linear variation on mean and variance</span>
|
||||
|
||||
<span class="sd"> :param period: the period of recurrence</span>
|
||||
<span class="sd"> :param mu_min: initial (and minimum) mean of each period</span>
|
||||
<span class="sd"> :param sigma_min: initial (and minimum) variance of each period</span>
|
||||
<span class="sd"> :param mu_max: final (and maximum) mean of each period</span>
|
||||
<span class="sd"> :param sigma_max: final (and maximum) variance of each period</span>
|
||||
<span class="sd"> :param it: Number of iterations</span>
|
||||
<span class="sd"> :param num: Number of samples generated on each iteration</span>
|
||||
<span class="sd"> :param vmin: Lower bound value of generated data</span>
|
||||
<span class="sd"> :param vmax: Upper bound value of generated data</span>
|
||||
<span class="sd"> :return: A list of it*num float values</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">period</span> <span class="o">></span> <span class="n">it</span><span class="p">:</span>
|
||||
<span class="k">raise</span><span class="p">(</span><span class="s2">"The 'period' parameter must be lesser than 'it' parameter"</span><span class="p">)</span>
|
||||
|
||||
<span class="n">mu_inc</span> <span class="o">=</span> <span class="p">(</span><span class="n">mu_max</span> <span class="o">-</span> <span class="n">mu_min</span><span class="p">)</span><span class="o">/</span><span class="n">period</span>
|
||||
<span class="n">sigma_inc</span> <span class="o">=</span> <span class="p">(</span><span class="n">sigma_max</span> <span class="o">-</span> <span class="n">sigma_min</span><span class="p">)</span> <span class="o">/</span> <span class="n">period</span>
|
||||
<span class="n">mu</span> <span class="o">=</span> <span class="n">mu_min</span>
|
||||
<span class="n">sigma</span> <span class="o">=</span> <span class="n">sigma_min</span>
|
||||
<span class="n">ret</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="n">signal</span> <span class="o">=</span> <span class="kc">True</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">it</span><span class="p">):</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">normal</span><span class="p">(</span><span class="n">mu</span><span class="p">,</span> <span class="n">sigma</span><span class="p">,</span> <span class="n">num</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">vmin</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">maximum</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">full</span><span class="p">(</span><span class="n">num</span><span class="p">,</span> <span class="n">vmin</span><span class="p">),</span> <span class="n">tmp</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">vmax</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">minimum</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">full</span><span class="p">(</span><span class="n">num</span><span class="p">,</span> <span class="n">vmax</span><span class="p">),</span> <span class="n">tmp</span><span class="p">)</span>
|
||||
<span class="n">ret</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">tmp</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">k</span> <span class="o">%</span> <span class="n">period</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
|
||||
<span class="n">signal</span> <span class="o">=</span> <span class="ow">not</span> <span class="n">signal</span>
|
||||
|
||||
<span class="n">mu</span> <span class="o">+=</span> <span class="p">(</span><span class="n">mu_inc</span> <span class="k">if</span> <span class="n">signal</span> <span class="k">else</span> <span class="o">-</span><span class="n">mu_inc</span><span class="p">)</span>
|
||||
<span class="n">sigma</span> <span class="o">+=</span> <span class="p">(</span><span class="n">sigma_inc</span> <span class="k">if</span> <span class="n">signal</span> <span class="k">else</span> <span class="o">-</span><span class="n">sigma_inc</span><span class="p">)</span>
|
||||
|
||||
<span class="n">sigma</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="n">sigma</span><span class="p">,</span> <span class="mf">0.005</span><span class="p">)</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">ret</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="generate_sinoidal_periodic_gaussian"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.artificial.generate_sinoidal_periodic_gaussian">[docs]</a><span class="k">def</span> <span class="nf">generate_sinoidal_periodic_gaussian</span><span class="p">(</span><span class="n">period</span><span class="p">,</span> <span class="n">mu_min</span><span class="p">,</span> <span class="n">sigma_min</span><span class="p">,</span> <span class="n">mu_max</span><span class="p">,</span> <span class="n">sigma_max</span><span class="p">,</span> <span class="n">it</span><span class="o">=</span><span class="mi">100</span><span class="p">,</span> <span class="n">num</span><span class="o">=</span><span class="mi">10</span><span class="p">,</span> <span class="n">vmin</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">vmax</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Generates a periodic sinoidal variation on mean and variance</span>
|
||||
|
||||
<span class="sd"> :param period: the period of recurrence</span>
|
||||
<span class="sd"> :param mu_min: initial (and minimum) mean of each period</span>
|
||||
<span class="sd"> :param sigma_min: initial (and minimum) variance of each period</span>
|
||||
<span class="sd"> :param mu_max: final (and maximum) mean of each period</span>
|
||||
<span class="sd"> :param sigma_max: final (and maximum) variance of each period</span>
|
||||
<span class="sd"> :param it: Number of iterations</span>
|
||||
<span class="sd"> :param num: Number of samples generated on each iteration</span>
|
||||
<span class="sd"> :param vmin: Lower bound value of generated data</span>
|
||||
<span class="sd"> :param vmax: Upper bound value of generated data</span>
|
||||
<span class="sd"> :return: A list of it*num float values</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">mu_range</span> <span class="o">=</span> <span class="n">mu_max</span> <span class="o">-</span> <span class="n">mu_min</span>
|
||||
<span class="n">sigma_range</span> <span class="o">=</span> <span class="n">sigma_max</span> <span class="o">-</span> <span class="n">sigma_min</span>
|
||||
<span class="n">mu</span> <span class="o">=</span> <span class="n">mu_min</span>
|
||||
<span class="n">sigma</span> <span class="o">=</span> <span class="n">sigma_min</span>
|
||||
<span class="n">ret</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">it</span><span class="p">):</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">normal</span><span class="p">(</span><span class="n">mu</span><span class="p">,</span> <span class="n">sigma</span><span class="p">,</span> <span class="n">num</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">vmin</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">maximum</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">full</span><span class="p">(</span><span class="n">num</span><span class="p">,</span> <span class="n">vmin</span><span class="p">),</span> <span class="n">tmp</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">vmax</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">minimum</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">full</span><span class="p">(</span><span class="n">num</span><span class="p">,</span> <span class="n">vmax</span><span class="p">),</span> <span class="n">tmp</span><span class="p">)</span>
|
||||
<span class="n">ret</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">tmp</span><span class="p">)</span>
|
||||
|
||||
<span class="n">mu</span> <span class="o">+=</span> <span class="n">mu_range</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">sin</span><span class="p">(</span><span class="n">period</span> <span class="o">*</span> <span class="n">k</span><span class="p">)</span>
|
||||
<span class="n">sigma</span> <span class="o">+=</span> <span class="n">sigma_range</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">sin</span><span class="p">(</span><span class="n">period</span> <span class="o">*</span> <span class="n">k</span><span class="p">)</span>
|
||||
|
||||
<span class="n">sigma</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="n">sigma</span><span class="p">,</span> <span class="mf">0.005</span><span class="p">)</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">ret</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="generate_uniform_linear"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.artificial.generate_uniform_linear">[docs]</a><span class="k">def</span> <span class="nf">generate_uniform_linear</span><span class="p">(</span><span class="n">min_ini</span><span class="p">,</span> <span class="n">max_ini</span><span class="p">,</span> <span class="n">min_inc</span><span class="p">,</span> <span class="n">max_inc</span><span class="p">,</span> <span class="n">it</span><span class="o">=</span><span class="mi">100</span><span class="p">,</span> <span class="n">num</span><span class="o">=</span><span class="mi">10</span><span class="p">,</span> <span class="n">vmin</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">vmax</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Generate data sampled from Uniform distribution, with constant or linear changing bounds</span>
|
||||
|
||||
<span class="sd"> :param mu_ini: Initial mean</span>
|
||||
<span class="sd"> :param sigma_ini: Initial variance</span>
|
||||
<span class="sd"> :param mu_inc: Mean increment after 'num' samples</span>
|
||||
<span class="sd"> :param sigma_inc: Variance increment after 'num' samples</span>
|
||||
<span class="sd"> :param it: Number of iterations</span>
|
||||
<span class="sd"> :param num: Number of samples generated on each iteration</span>
|
||||
<span class="sd"> :param vmin: Lower bound value of generated data</span>
|
||||
<span class="sd"> :param vmax: Upper bound value of generated data</span>
|
||||
<span class="sd"> :return: A list of it*num float values</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">_min</span> <span class="o">=</span> <span class="n">min_ini</span>
|
||||
<span class="n">_max</span> <span class="o">=</span> <span class="n">max_ini</span>
|
||||
<span class="n">ret</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="n">it</span><span class="p">):</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">uniform</span><span class="p">(</span><span class="n">_min</span><span class="p">,</span> <span class="n">_max</span><span class="p">,</span> <span class="n">num</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">vmin</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">maximum</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">full</span><span class="p">(</span><span class="n">num</span><span class="p">,</span> <span class="n">vmin</span><span class="p">),</span> <span class="n">tmp</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">vmax</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">minimum</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">full</span><span class="p">(</span><span class="n">num</span><span class="p">,</span> <span class="n">vmax</span><span class="p">),</span> <span class="n">tmp</span><span class="p">)</span>
|
||||
<span class="n">ret</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">tmp</span><span class="p">)</span>
|
||||
<span class="n">_min</span> <span class="o">+=</span> <span class="n">min_inc</span>
|
||||
<span class="n">_max</span> <span class="o">+=</span> <span class="n">max_inc</span>
|
||||
<span class="k">return</span> <span class="n">ret</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="white_noise"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.artificial.white_noise">[docs]</a><span class="k">def</span> <span class="nf">white_noise</span><span class="p">(</span><span class="n">n</span><span class="o">=</span><span class="mi">500</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Simple Gaussian noise signal</span>
|
||||
<span class="sd"> :param n: number of samples</span>
|
||||
<span class="sd"> :return:</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">normal</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="n">n</span><span class="p">)</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="random_walk"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.artificial.random_walk">[docs]</a><span class="k">def</span> <span class="nf">random_walk</span><span class="p">(</span><span class="n">n</span><span class="o">=</span><span class="mi">500</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="s1">'gaussian'</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Simple random walk</span>
|
||||
|
||||
<span class="sd"> :param n: number of samples</span>
|
||||
<span class="sd"> :param type: 'gaussian' or 'uniform'</span>
|
||||
<span class="sd"> :return:</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">if</span> <span class="nb">type</span> <span class="o">==</span> <span class="s1">'gaussian'</span><span class="p">:</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">generate_gaussian_linear</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">it</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">num</span><span class="o">=</span><span class="n">n</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">generate_uniform_linear</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="n">it</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">num</span><span class="o">=</span><span class="n">n</span><span class="p">)</span>
|
||||
<span class="n">ret</span> <span class="o">=</span> <span class="p">[</span><span class="mi">0</span><span class="p">]</span>
|
||||
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">n</span><span class="p">):</span>
|
||||
<span class="n">ret</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">tmp</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">+</span> <span class="n">ret</span><span class="p">[</span><span class="n">i</span><span class="p">])</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">ret</span></div>
|
||||
|
||||
|
||||
<span class="k">def</span> <span class="nf">_append</span><span class="p">(</span><span class="n">additive</span><span class="p">,</span> <span class="n">start</span><span class="p">,</span> <span class="n">before</span><span class="p">,</span> <span class="n">new</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">additive</span><span class="p">:</span>
|
||||
<span class="n">before</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">new</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">before</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">start</span><span class="p">):</span>
|
||||
<span class="n">new</span><span class="o">.</span><span class="n">insert</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">0</span><span class="p">)</span>
|
||||
|
||||
<span class="n">l1</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">before</span><span class="p">)</span>
|
||||
<span class="n">l2</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">new</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">l2</span> <span class="o"><</span> <span class="n">l1</span><span class="p">:</span>
|
||||
<span class="n">new</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">l1</span> <span class="o">-</span> <span class="n">l2</span><span class="p">)</span><span class="o">.</span><span class="n">tolist</span><span class="p">())</span>
|
||||
<span class="k">elif</span> <span class="mi">0</span> <span class="o"><</span> <span class="n">l1</span> <span class="o"><</span> <span class="n">l2</span><span class="p">:</span>
|
||||
<span class="n">new</span> <span class="o">=</span> <span class="n">new</span><span class="p">[:</span><span class="n">l1</span><span class="p">]</span>
|
||||
|
||||
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">before</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">new</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">before</span><span class="p">)</span> <span class="o">+</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">new</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">tmp</span><span class="o">.</span><span class="n">tolist</span><span class="p">()</span>
|
||||
|
||||
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../index.html">
|
||||
<img class="logo" src="../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.data.artificial</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
120
docs/build/html/_modules/pyFTS/data/common.html
vendored
120
docs/build/html/_modules/pyFTS/data/common.html
vendored
@ -1,120 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.data.common — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../_static/jquery.js"></script>
|
||||
<script src="../../../_static/underscore.js"></script>
|
||||
<script src="../../../_static/doctools.js"></script>
|
||||
<script src="../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.data.common</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.data.common</h1><div class="highlight"><pre>
|
||||
<span></span>
|
||||
<span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span>
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
<span class="kn">import</span> <span class="nn">os</span>
|
||||
<span class="kn">import</span> <span class="nn">pkg_resources</span>
|
||||
<span class="kn">from</span> <span class="nn">pathlib</span> <span class="kn">import</span> <span class="n">Path</span>
|
||||
<span class="kn">from</span> <span class="nn">urllib</span> <span class="kn">import</span> <span class="n">request</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="get_dataframe"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.common.get_dataframe">[docs]</a><span class="k">def</span> <span class="nf">get_dataframe</span><span class="p">(</span><span class="n">filename</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">url</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">sep</span><span class="p">:</span><span class="nb">str</span><span class="o">=</span><span class="s2">";"</span><span class="p">,</span> <span class="n">compression</span><span class="p">:</span><span class="nb">str</span><span class="o">=</span><span class="s1">'infer'</span><span class="p">)</span> <span class="o">-></span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">:</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> This method check if filename already exists, read the file and return its data.</span>
|
||||
<span class="sd"> If the file don't already exists, it will be downloaded and decompressed.</span>
|
||||
|
||||
<span class="sd"> :param filename: dataset local filename</span>
|
||||
<span class="sd"> :param url: dataset internet URL</span>
|
||||
<span class="sd"> :param sep: CSV field separator</span>
|
||||
<span class="sd"> :param compression: type of compression</span>
|
||||
<span class="sd"> :return: Pandas dataset</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="n">tmp_file</span> <span class="o">=</span> <span class="n">Path</span><span class="p">(</span><span class="n">filename</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">tmp_file</span><span class="o">.</span><span class="n">is_file</span><span class="p">():</span>
|
||||
<span class="k">return</span> <span class="n">pd</span><span class="o">.</span><span class="n">read_csv</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="n">sep</span><span class="p">,</span> <span class="n">compression</span><span class="o">=</span><span class="n">compression</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">request</span><span class="o">.</span><span class="n">urlretrieve</span><span class="p">(</span><span class="n">url</span><span class="p">,</span> <span class="n">filename</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">pd</span><span class="o">.</span><span class="n">read_csv</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="n">sep</span><span class="o">=</span><span class="n">sep</span><span class="p">,</span> <span class="n">compression</span><span class="o">=</span><span class="n">compression</span><span class="p">)</span></div>
|
||||
|
||||
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../index.html">
|
||||
<img class="logo" src="../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.data.common</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
130
docs/build/html/_modules/pyFTS/data/henon.html
vendored
130
docs/build/html/_modules/pyFTS/data/henon.html
vendored
@ -1,130 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.data.henon — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../_static/jquery.js"></script>
|
||||
<script src="../../../_static/underscore.js"></script>
|
||||
<script src="../../../_static/doctools.js"></script>
|
||||
<script src="../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.data.henon</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.data.henon</h1><div class="highlight"><pre>
|
||||
<span></span><span class="sd">"""</span>
|
||||
<span class="sd">M. Hénon. "A two-dimensional mapping with a strange attractor". Commun. Math. Phys. 50, 69-77 (1976)</span>
|
||||
|
||||
<span class="sd">dx/dt = a + by(t-1) - x(t-1)^2</span>
|
||||
<span class="sd">dy/dt = x</span>
|
||||
<span class="sd">"""</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
<span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="get_data"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.henon.get_data">[docs]</a><span class="k">def</span> <span class="nf">get_data</span><span class="p">(</span><span class="n">var</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">a</span><span class="p">:</span><span class="nb">float</span><span class="o">=</span><span class="mf">1.4</span><span class="p">,</span> <span class="n">b</span><span class="p">:</span><span class="nb">float</span><span class="o">=</span><span class="mf">0.3</span><span class="p">,</span> <span class="n">initial_values</span><span class="p">:</span> <span class="nb">list</span> <span class="o">=</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">],</span> <span class="n">iterations</span><span class="p">:</span><span class="nb">int</span><span class="o">=</span><span class="mi">1000</span><span class="p">)</span> <span class="o">-></span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">:</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Get a simple univariate time series data.</span>
|
||||
|
||||
<span class="sd"> :param var: the dataset field name to extract</span>
|
||||
<span class="sd"> :return: numpy array</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">return</span> <span class="n">get_dataframe</span><span class="p">(</span><span class="n">a</span><span class="p">,</span><span class="n">b</span><span class="p">,</span> <span class="n">initial_values</span><span class="p">,</span> <span class="n">iterations</span><span class="p">)[</span><span class="n">var</span><span class="p">]</span><span class="o">.</span><span class="n">values</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="get_dataframe"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.henon.get_dataframe">[docs]</a><span class="k">def</span> <span class="nf">get_dataframe</span><span class="p">(</span><span class="n">a</span><span class="p">:</span><span class="nb">float</span><span class="o">=</span><span class="mf">1.4</span><span class="p">,</span> <span class="n">b</span><span class="p">:</span><span class="nb">float</span><span class="o">=</span><span class="mf">0.3</span><span class="p">,</span> <span class="n">initial_values</span><span class="p">:</span> <span class="nb">list</span> <span class="o">=</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">],</span> <span class="n">iterations</span><span class="p">:</span><span class="nb">int</span><span class="o">=</span><span class="mi">1000</span><span class="p">)</span> <span class="o">-></span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">:</span>
|
||||
<span class="w"> </span><span class="sd">'''</span>
|
||||
<span class="sd"> Return a dataframe with the bivariate Henon Map time series (x, y).</span>
|
||||
|
||||
<span class="sd"> :param a: Equation coefficient</span>
|
||||
<span class="sd"> :param b: Equation coefficient</span>
|
||||
<span class="sd"> :param initial_values: numpy array with the initial values of x and y. Default: [1, 1]</span>
|
||||
<span class="sd"> :param iterations: number of iterations. Default: 1000</span>
|
||||
<span class="sd"> :return: Panda dataframe with the x and y values</span>
|
||||
<span class="sd"> '''</span>
|
||||
|
||||
<span class="n">x</span> <span class="o">=</span> <span class="p">[</span><span class="n">initial_values</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span>
|
||||
<span class="n">y</span> <span class="o">=</span> <span class="p">[</span><span class="n">initial_values</span><span class="p">[</span><span class="mi">1</span><span class="p">]]</span>
|
||||
<span class="k">for</span> <span class="n">t</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">iterations</span><span class="p">):</span>
|
||||
<span class="n">xx</span> <span class="o">=</span> <span class="n">a</span> <span class="o">+</span> <span class="n">b</span> <span class="o">*</span> <span class="n">y</span><span class="p">[</span><span class="n">t</span><span class="p">]</span> <span class="o">-</span> <span class="n">x</span><span class="p">[</span><span class="n">t</span><span class="p">]</span> <span class="o">**</span> <span class="mi">2</span>
|
||||
<span class="n">y</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">x</span><span class="p">[</span><span class="n">t</span><span class="p">])</span>
|
||||
<span class="n">x</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">xx</span><span class="p">)</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">({</span><span class="s1">'x'</span><span class="p">:</span> <span class="n">x</span><span class="p">,</span> <span class="s1">'y'</span><span class="p">:</span><span class="n">y</span><span class="p">})</span></div>
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../index.html">
|
||||
<img class="logo" src="../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.data.henon</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,114 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.data.logistic_map — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../_static/jquery.js"></script>
|
||||
<script src="../../../_static/underscore.js"></script>
|
||||
<script src="../../../_static/doctools.js"></script>
|
||||
<script src="../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.data.logistic_map</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.data.logistic_map</h1><div class="highlight"><pre>
|
||||
<span></span><span class="sd">"""</span>
|
||||
<span class="sd">May, Robert M. (1976). "Simple mathematical models with very complicated dynamics".</span>
|
||||
<span class="sd">Nature. 261 (5560): 459–467. doi:10.1038/261459a0.</span>
|
||||
|
||||
<span class="sd">x(t) = r * x(t-1) * (1 - x(t -1) )</span>
|
||||
<span class="sd">"""</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="get_data"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.logistic_map.get_data">[docs]</a><span class="k">def</span> <span class="nf">get_data</span><span class="p">(</span><span class="n">r</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mi">4</span><span class="p">,</span> <span class="n">initial_value</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mf">0.3</span><span class="p">,</span> <span class="n">iterations</span><span class="p">:</span> <span class="nb">int</span><span class="o">=</span><span class="mi">100</span><span class="p">)</span> <span class="o">-></span> <span class="nb">list</span><span class="p">:</span>
|
||||
<span class="w"> </span><span class="sd">'''</span>
|
||||
<span class="sd"> Return a list with the logistic map chaotic time series.</span>
|
||||
|
||||
<span class="sd"> :param r: Equation coefficient</span>
|
||||
<span class="sd"> :param initial_value: Initial value of x. Default: 0.3</span>
|
||||
<span class="sd"> :param iterations: number of iterations. Default: 100</span>
|
||||
<span class="sd"> :return:</span>
|
||||
<span class="sd"> '''</span>
|
||||
<span class="n">x</span> <span class="o">=</span> <span class="p">[</span><span class="n">initial_value</span><span class="p">]</span>
|
||||
<span class="k">for</span> <span class="n">t</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="n">iterations</span><span class="p">):</span>
|
||||
<span class="n">x</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">r</span> <span class="o">*</span> <span class="n">x</span><span class="p">[</span><span class="n">t</span><span class="p">]</span><span class="o">*</span><span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="n">x</span><span class="p">[</span><span class="n">t</span><span class="p">]))</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">x</span></div>
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../index.html">
|
||||
<img class="logo" src="../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.data.logistic_map</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
141
docs/build/html/_modules/pyFTS/data/lorentz.html
vendored
141
docs/build/html/_modules/pyFTS/data/lorentz.html
vendored
@ -1,141 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.data.lorentz — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../_static/jquery.js"></script>
|
||||
<script src="../../../_static/underscore.js"></script>
|
||||
<script src="../../../_static/doctools.js"></script>
|
||||
<script src="../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.data.lorentz</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.data.lorentz</h1><div class="highlight"><pre>
|
||||
<span></span><span class="sd">"""</span>
|
||||
<span class="sd">Lorenz, Edward Norton (1963). "Deterministic nonperiodic flow". Journal of the Atmospheric Sciences. 20 (2): 130–141.</span>
|
||||
<span class="sd">https://doi.org/10.1175/1520-0469(1963)020<0130:DNF>2.0.CO;2</span>
|
||||
|
||||
<span class="sd">dx/dt = a(y -x)</span>
|
||||
<span class="sd">dy/dt = x(b - z) - y</span>
|
||||
<span class="sd">dz/dt = xy - cz</span>
|
||||
<span class="sd">"""</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
<span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="get_data"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.lorentz.get_data">[docs]</a><span class="k">def</span> <span class="nf">get_data</span><span class="p">(</span><span class="n">var</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">a</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mf">10.0</span><span class="p">,</span> <span class="n">b</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mf">28.0</span><span class="p">,</span> <span class="n">c</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mf">8.0</span> <span class="o">/</span> <span class="mf">3.0</span><span class="p">,</span> <span class="n">dt</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mf">0.01</span><span class="p">,</span>
|
||||
<span class="n">initial_values</span><span class="p">:</span> <span class="nb">list</span> <span class="o">=</span> <span class="p">[</span><span class="mf">0.1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">],</span> <span class="n">iterations</span><span class="p">:</span> <span class="nb">int</span><span class="o">=</span><span class="mi">1000</span><span class="p">)</span> <span class="o">-></span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">:</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Get a simple univariate time series data.</span>
|
||||
|
||||
<span class="sd"> :param var: the dataset field name to extract</span>
|
||||
<span class="sd"> :return: numpy array</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">return</span> <span class="n">get_dataframe</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">,</span> <span class="n">c</span><span class="p">,</span> <span class="n">dt</span><span class="p">,</span> <span class="n">initial_values</span><span class="p">,</span> <span class="n">iterations</span><span class="p">)[</span><span class="n">var</span><span class="p">]</span><span class="o">.</span><span class="n">values</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="get_dataframe"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.lorentz.get_dataframe">[docs]</a><span class="k">def</span> <span class="nf">get_dataframe</span><span class="p">(</span><span class="n">a</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mf">10.0</span><span class="p">,</span> <span class="n">b</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mf">28.0</span><span class="p">,</span> <span class="n">c</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mf">8.0</span> <span class="o">/</span> <span class="mf">3.0</span><span class="p">,</span> <span class="n">dt</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mf">0.01</span><span class="p">,</span>
|
||||
<span class="n">initial_values</span><span class="p">:</span> <span class="nb">list</span> <span class="o">=</span> <span class="p">[</span><span class="mf">0.1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">],</span> <span class="n">iterations</span><span class="p">:</span> <span class="nb">int</span><span class="o">=</span><span class="mi">1000</span><span class="p">)</span><span class="o">-></span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">:</span>
|
||||
<span class="w"> </span><span class="sd">'''</span>
|
||||
<span class="sd"> Return a dataframe with the multivariate Lorenz Map time series (x, y, z).</span>
|
||||
|
||||
<span class="sd"> :param a: Equation coefficient. Default value: 10</span>
|
||||
<span class="sd"> :param b: Equation coefficient. Default value: 28</span>
|
||||
<span class="sd"> :param c: Equation coefficient. Default value: 8.0/3.0</span>
|
||||
<span class="sd"> :param dt: Time differential for continuous time integration. Default value: 0.01</span>
|
||||
<span class="sd"> :param initial_values: numpy array with the initial values of x,y and z. Default: [0.1, 0, 0]</span>
|
||||
<span class="sd"> :param iterations: number of iterations. Default: 1000</span>
|
||||
<span class="sd"> :return: Panda dataframe with the x, y and z values</span>
|
||||
<span class="sd"> '''</span>
|
||||
|
||||
<span class="n">x</span> <span class="o">=</span> <span class="p">[</span><span class="n">initial_values</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span>
|
||||
<span class="n">y</span> <span class="o">=</span> <span class="p">[</span><span class="n">initial_values</span><span class="p">[</span><span class="mi">1</span><span class="p">]]</span>
|
||||
<span class="n">z</span> <span class="o">=</span> <span class="p">[</span><span class="n">initial_values</span><span class="p">[</span><span class="mi">2</span><span class="p">]]</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">t</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">iterations</span><span class="p">):</span>
|
||||
<span class="n">dxdt</span> <span class="o">=</span> <span class="n">a</span> <span class="o">*</span> <span class="p">(</span><span class="n">y</span><span class="p">[</span><span class="n">t</span><span class="p">]</span> <span class="o">-</span> <span class="n">x</span><span class="p">[</span><span class="n">t</span><span class="p">])</span>
|
||||
<span class="n">dydt</span> <span class="o">=</span> <span class="n">x</span><span class="p">[</span><span class="n">t</span><span class="p">]</span> <span class="o">*</span> <span class="p">(</span><span class="n">b</span> <span class="o">-</span> <span class="n">z</span><span class="p">[</span><span class="n">t</span><span class="p">])</span> <span class="o">-</span> <span class="n">y</span><span class="p">[</span><span class="n">t</span><span class="p">]</span>
|
||||
<span class="n">dzdt</span> <span class="o">=</span> <span class="n">x</span><span class="p">[</span><span class="n">t</span><span class="p">]</span> <span class="o">*</span> <span class="n">y</span><span class="p">[</span><span class="n">t</span><span class="p">]</span> <span class="o">-</span> <span class="n">c</span> <span class="o">*</span> <span class="n">z</span><span class="p">[</span><span class="n">t</span><span class="p">]</span>
|
||||
<span class="n">x</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">x</span><span class="p">[</span><span class="n">t</span><span class="p">]</span> <span class="o">+</span> <span class="n">dt</span> <span class="o">*</span> <span class="n">dxdt</span><span class="p">)</span>
|
||||
<span class="n">y</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">y</span><span class="p">[</span><span class="n">t</span><span class="p">]</span> <span class="o">+</span> <span class="n">dt</span> <span class="o">*</span> <span class="n">dydt</span><span class="p">)</span>
|
||||
<span class="n">z</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">z</span><span class="p">[</span><span class="n">t</span><span class="p">]</span> <span class="o">+</span> <span class="n">dt</span> <span class="o">*</span> <span class="n">dzdt</span><span class="p">)</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">({</span><span class="s1">'x'</span><span class="p">:</span> <span class="n">x</span><span class="p">,</span> <span class="s1">'y'</span><span class="p">:</span><span class="n">y</span><span class="p">,</span> <span class="s1">'z'</span><span class="p">:</span> <span class="n">z</span><span class="p">})</span></div>
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../index.html">
|
||||
<img class="logo" src="../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.data.lorentz</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,117 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.data.mackey_glass — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../_static/jquery.js"></script>
|
||||
<script src="../../../_static/underscore.js"></script>
|
||||
<script src="../../../_static/doctools.js"></script>
|
||||
<script src="../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.data.mackey_glass</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.data.mackey_glass</h1><div class="highlight"><pre>
|
||||
<span></span><span class="sd">"""</span>
|
||||
<span class="sd">Mackey, M. C. and Glass, L. (1977). Oscillation and chaos in physiological control systems.</span>
|
||||
<span class="sd">Science, 197(4300):287-289.</span>
|
||||
|
||||
<span class="sd">dy/dt = -by(t)+ cy(t - tau) / 1+y(t-tau)^10</span>
|
||||
<span class="sd">"""</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="get_data"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.mackey_glass.get_data">[docs]</a><span class="k">def</span> <span class="nf">get_data</span><span class="p">(</span><span class="n">b</span><span class="p">:</span> <span class="nb">float</span><span class="o">=</span><span class="mf">0.1</span><span class="p">,</span> <span class="n">c</span><span class="p">:</span> <span class="nb">float</span><span class="o">=</span><span class="mf">0.2</span><span class="p">,</span> <span class="n">tau</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span><span class="mi">17</span><span class="p">,</span> <span class="n">initial_values</span><span class="p">:</span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">linspace</span><span class="p">(</span><span class="mf">0.5</span><span class="p">,</span><span class="mf">1.5</span><span class="p">,</span> <span class="mi">18</span><span class="p">),</span> <span class="n">iterations</span><span class="p">:</span> <span class="nb">int</span><span class="o">=</span><span class="mi">1000</span><span class="p">)</span> <span class="o">-></span> <span class="nb">list</span><span class="p">:</span>
|
||||
<span class="w"> </span><span class="sd">'''</span>
|
||||
<span class="sd"> Return a list with the Mackey-Glass chaotic time series.</span>
|
||||
|
||||
<span class="sd"> :param b: Equation coefficient</span>
|
||||
<span class="sd"> :param c: Equation coefficient</span>
|
||||
<span class="sd"> :param tau: Lag parameter, default: 17</span>
|
||||
<span class="sd"> :param initial_values: numpy array with the initial values of y. Default: np.linspace(0.5,1.5,18)</span>
|
||||
<span class="sd"> :param iterations: number of iterations. Default: 1000</span>
|
||||
<span class="sd"> :return:</span>
|
||||
<span class="sd"> '''</span>
|
||||
<span class="n">y</span> <span class="o">=</span> <span class="n">initial_values</span><span class="o">.</span><span class="n">tolist</span><span class="p">()</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">n</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">y</span><span class="p">)</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="n">iterations</span><span class="o">+</span><span class="mi">100</span><span class="p">):</span>
|
||||
<span class="n">y</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">y</span><span class="p">[</span><span class="n">n</span><span class="p">]</span> <span class="o">-</span> <span class="n">b</span> <span class="o">*</span> <span class="n">y</span><span class="p">[</span><span class="n">n</span><span class="p">]</span> <span class="o">+</span> <span class="n">c</span> <span class="o">*</span> <span class="n">y</span><span class="p">[</span><span class="n">n</span> <span class="o">-</span> <span class="n">tau</span><span class="p">]</span> <span class="o">/</span> <span class="p">(</span><span class="mi">1</span> <span class="o">+</span> <span class="n">y</span><span class="p">[</span><span class="n">n</span> <span class="o">-</span> <span class="n">tau</span><span class="p">]</span> <span class="o">**</span> <span class="mi">10</span><span class="p">))</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">y</span><span class="p">[</span><span class="mi">100</span><span class="p">:]</span></div>
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../index.html">
|
||||
<img class="logo" src="../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.data.mackey_glass</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
141
docs/build/html/_modules/pyFTS/data/rossler.html
vendored
141
docs/build/html/_modules/pyFTS/data/rossler.html
vendored
@ -1,141 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.data.rossler — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../_static/jquery.js"></script>
|
||||
<script src="../../../_static/underscore.js"></script>
|
||||
<script src="../../../_static/doctools.js"></script>
|
||||
<script src="../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.data.rossler</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.data.rossler</h1><div class="highlight"><pre>
|
||||
<span></span><span class="sd">"""</span>
|
||||
<span class="sd">O. E. Rössler, Phys. Lett. 57A, 397 (1976).</span>
|
||||
|
||||
<span class="sd">dx/dt = -z - y</span>
|
||||
<span class="sd">dy/dt = x + ay</span>
|
||||
<span class="sd">dz/dt = b + z( x - c )</span>
|
||||
|
||||
<span class="sd">"""</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
<span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="get_data"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.rossler.get_data">[docs]</a><span class="k">def</span> <span class="nf">get_data</span><span class="p">(</span><span class="n">var</span><span class="p">:</span> <span class="nb">str</span><span class="p">,</span> <span class="n">a</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mf">0.2</span><span class="p">,</span> <span class="n">b</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mf">0.2</span><span class="p">,</span> <span class="n">c</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mf">5.7</span><span class="p">,</span> <span class="n">dt</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mf">0.01</span><span class="p">,</span>
|
||||
<span class="n">initial_values</span><span class="p">:</span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span> <span class="o">=</span> <span class="p">[</span><span class="mf">0.001</span><span class="p">,</span> <span class="mf">0.001</span><span class="p">,</span> <span class="mf">0.001</span><span class="p">],</span> <span class="n">iterations</span><span class="p">:</span> <span class="nb">int</span><span class="o">=</span><span class="mi">5000</span><span class="p">)</span> <span class="o">-></span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">:</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Get a simple univariate time series data.</span>
|
||||
|
||||
<span class="sd"> :param var: the dataset field name to extract</span>
|
||||
<span class="sd"> :return: numpy array</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">return</span> <span class="n">get_dataframe</span><span class="p">(</span><span class="n">a</span><span class="p">,</span> <span class="n">b</span><span class="p">,</span> <span class="n">c</span><span class="p">,</span> <span class="n">dt</span><span class="p">,</span> <span class="n">initial_values</span><span class="p">,</span> <span class="n">iterations</span><span class="p">)[</span><span class="n">var</span><span class="p">]</span><span class="o">.</span><span class="n">values</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="get_dataframe"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.rossler.get_dataframe">[docs]</a><span class="k">def</span> <span class="nf">get_dataframe</span><span class="p">(</span><span class="n">a</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mf">0.2</span><span class="p">,</span> <span class="n">b</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mf">0.2</span><span class="p">,</span> <span class="n">c</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mf">5.7</span><span class="p">,</span> <span class="n">dt</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mf">0.01</span><span class="p">,</span>
|
||||
<span class="n">initial_values</span><span class="p">:</span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span> <span class="o">=</span> <span class="p">[</span><span class="mf">0.001</span><span class="p">,</span> <span class="mf">0.001</span><span class="p">,</span> <span class="mf">0.001</span><span class="p">],</span> <span class="n">iterations</span><span class="p">:</span> <span class="nb">int</span><span class="o">=</span><span class="mi">5000</span><span class="p">)</span> <span class="o">-></span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">:</span>
|
||||
<span class="w"> </span><span class="sd">'''</span>
|
||||
<span class="sd"> Return a dataframe with the multivariate Rössler Map time series (x, y, z).</span>
|
||||
|
||||
<span class="sd"> :param a: Equation coefficient. Default value: 0.2</span>
|
||||
<span class="sd"> :param b: Equation coefficient. Default value: 0.2</span>
|
||||
<span class="sd"> :param c: Equation coefficient. Default value: 5.7</span>
|
||||
<span class="sd"> :param dt: Time differential for continuous time integration. Default value: 0.01</span>
|
||||
<span class="sd"> :param initial_values: numpy array with the initial values of x,y and z. Default: [0.001, 0.001, 0.001]</span>
|
||||
<span class="sd"> :param iterations: number of iterations. Default: 5000</span>
|
||||
<span class="sd"> :return: Panda dataframe with the x, y and z values</span>
|
||||
<span class="sd"> '''</span>
|
||||
|
||||
<span class="n">x</span> <span class="o">=</span> <span class="p">[</span><span class="n">initial_values</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span>
|
||||
<span class="n">y</span> <span class="o">=</span> <span class="p">[</span><span class="n">initial_values</span><span class="p">[</span><span class="mi">1</span><span class="p">]]</span>
|
||||
<span class="n">z</span> <span class="o">=</span> <span class="p">[</span><span class="n">initial_values</span><span class="p">[</span><span class="mi">2</span><span class="p">]]</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">t</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">iterations</span><span class="p">):</span>
|
||||
<span class="n">dxdt</span> <span class="o">=</span> <span class="o">-</span> <span class="p">(</span><span class="n">y</span><span class="p">[</span><span class="n">t</span><span class="p">]</span> <span class="o">+</span> <span class="n">z</span><span class="p">[</span><span class="n">t</span><span class="p">])</span>
|
||||
<span class="n">dydt</span> <span class="o">=</span> <span class="n">x</span><span class="p">[</span><span class="n">t</span><span class="p">]</span> <span class="o">+</span> <span class="n">a</span> <span class="o">*</span> <span class="n">y</span><span class="p">[</span><span class="n">t</span><span class="p">]</span>
|
||||
<span class="n">dzdt</span> <span class="o">=</span> <span class="n">b</span> <span class="o">+</span> <span class="n">z</span><span class="p">[</span><span class="n">t</span><span class="p">]</span> <span class="o">*</span> <span class="n">x</span><span class="p">[</span><span class="n">t</span><span class="p">]</span> <span class="o">-</span> <span class="n">z</span><span class="p">[</span><span class="n">t</span><span class="p">]</span> <span class="o">*</span> <span class="n">c</span>
|
||||
<span class="n">x</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">x</span><span class="p">[</span><span class="n">t</span><span class="p">]</span> <span class="o">+</span> <span class="n">dt</span> <span class="o">*</span> <span class="n">dxdt</span><span class="p">)</span>
|
||||
<span class="n">y</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">y</span><span class="p">[</span><span class="n">t</span><span class="p">]</span> <span class="o">+</span> <span class="n">dt</span> <span class="o">*</span> <span class="n">dydt</span><span class="p">)</span>
|
||||
<span class="n">z</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">z</span><span class="p">[</span><span class="n">t</span><span class="p">]</span> <span class="o">+</span> <span class="n">dt</span> <span class="o">*</span> <span class="n">dzdt</span><span class="p">)</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">({</span><span class="s1">'x'</span><span class="p">:</span> <span class="n">x</span><span class="p">,</span> <span class="s1">'y'</span><span class="p">:</span><span class="n">y</span><span class="p">,</span> <span class="s1">'z'</span><span class="p">:</span> <span class="n">z</span><span class="p">})</span></div>
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../index.html">
|
||||
<img class="logo" src="../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.data.rossler</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
121
docs/build/html/_modules/pyFTS/data/sunspots.html
vendored
121
docs/build/html/_modules/pyFTS/data/sunspots.html
vendored
@ -1,121 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.data.sunspots — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../_static/jquery.js"></script>
|
||||
<script src="../../../_static/underscore.js"></script>
|
||||
<script src="../../../_static/doctools.js"></script>
|
||||
<script src="../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.data.sunspots</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.data.sunspots</h1><div class="highlight"><pre>
|
||||
<span></span><span class="sd">"""</span>
|
||||
<span class="sd">Monthly sunspot numbers from 1749 to May 2016</span>
|
||||
|
||||
<span class="sd">Source: https://www.esrl.noaa.gov/psd/gcos_wgsp/Timeseries/SUNSPOT/</span>
|
||||
<span class="sd">"""</span>
|
||||
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.data</span> <span class="kn">import</span> <span class="n">common</span>
|
||||
<span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span>
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
|
||||
<div class="viewcode-block" id="get_data"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.sunspots.get_data">[docs]</a><span class="k">def</span> <span class="nf">get_data</span><span class="p">()</span> <span class="o">-></span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">:</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Get a simple univariate time series data.</span>
|
||||
|
||||
<span class="sd"> :return: numpy array</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">dat</span> <span class="o">=</span> <span class="n">get_dataframe</span><span class="p">()</span>
|
||||
<span class="n">dat</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">dat</span><span class="p">[</span><span class="s2">"SUNACTIVITY"</span><span class="p">])</span>
|
||||
<span class="k">return</span> <span class="n">dat</span></div>
|
||||
|
||||
<div class="viewcode-block" id="get_dataframe"><a class="viewcode-back" href="../../../pyFTS.data.html#pyFTS.data.sunspots.get_dataframe">[docs]</a><span class="k">def</span> <span class="nf">get_dataframe</span><span class="p">()</span> <span class="o">-></span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">:</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Get the complete multivariate time series data.</span>
|
||||
|
||||
<span class="sd"> :return: Pandas DataFrame</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">dat</span> <span class="o">=</span> <span class="n">common</span><span class="o">.</span><span class="n">get_dataframe</span><span class="p">(</span><span class="s1">'sunspots.csv'</span><span class="p">,</span>
|
||||
<span class="s1">'https://github.com/petroniocandido/pyFTS/raw/8f20f3634aa6a8f58083bdcd1bbf93795e6ed767/pyFTS/data/sunspots.csv'</span><span class="p">,</span>
|
||||
<span class="n">sep</span><span class="o">=</span><span class="s2">","</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">dat</span></div>
|
||||
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../index.html">
|
||||
<img class="logo" src="../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.data.sunspots</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
160
docs/build/html/_modules/pyFTS/hyperparam/Util.html
vendored
160
docs/build/html/_modules/pyFTS/hyperparam/Util.html
vendored
@ -1,160 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.hyperparam.Util — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../_static/jquery.js"></script>
|
||||
<script src="../../../_static/underscore.js"></script>
|
||||
<script src="../../../_static/doctools.js"></script>
|
||||
<script src="../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.hyperparam.Util</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.hyperparam.Util</h1><div class="highlight"><pre>
|
||||
<span></span><span class="sd">"""</span>
|
||||
<span class="sd">Common facilities for hyperparameter optimization</span>
|
||||
<span class="sd">"""</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">sqlite3</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="open_hyperparam_db"><a class="viewcode-back" href="../../../pyFTS.hyperparam.html#pyFTS.hyperparam.Util.open_hyperparam_db">[docs]</a><span class="k">def</span> <span class="nf">open_hyperparam_db</span><span class="p">(</span><span class="n">name</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Open a connection with a Sqlite database designed to store benchmark results.</span>
|
||||
|
||||
<span class="sd"> :param name: database filenem</span>
|
||||
<span class="sd"> :return: a sqlite3 database connection</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">conn</span> <span class="o">=</span> <span class="n">sqlite3</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="n">name</span><span class="p">)</span>
|
||||
|
||||
<span class="c1">#performance optimizations</span>
|
||||
<span class="n">conn</span><span class="o">.</span><span class="n">execute</span><span class="p">(</span><span class="s2">"PRAGMA journal_mode = WAL"</span><span class="p">)</span>
|
||||
<span class="n">conn</span><span class="o">.</span><span class="n">execute</span><span class="p">(</span><span class="s2">"PRAGMA synchronous = NORMAL"</span><span class="p">)</span>
|
||||
|
||||
<span class="n">create_hyperparam_tables</span><span class="p">(</span><span class="n">conn</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">conn</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="create_hyperparam_tables"><a class="viewcode-back" href="../../../pyFTS.hyperparam.html#pyFTS.hyperparam.Util.create_hyperparam_tables">[docs]</a><span class="k">def</span> <span class="nf">create_hyperparam_tables</span><span class="p">(</span><span class="n">conn</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Create a sqlite3 table designed to store benchmark results.</span>
|
||||
|
||||
<span class="sd"> :param conn: a sqlite3 database connection</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">c</span> <span class="o">=</span> <span class="n">conn</span><span class="o">.</span><span class="n">cursor</span><span class="p">()</span>
|
||||
|
||||
<span class="n">c</span><span class="o">.</span><span class="n">execute</span><span class="p">(</span><span class="s1">'''CREATE TABLE if not exists hyperparam(</span>
|
||||
<span class="s1"> ID integer primary key, Date int, Dataset text, Tag text, </span>
|
||||
<span class="s1"> Model text, Transformation text, mf text, 'Order' int, </span>
|
||||
<span class="s1"> Partitioner text, Partitions int, alpha real, lags text, </span>
|
||||
<span class="s1"> Measure text, Value real)'''</span><span class="p">)</span>
|
||||
|
||||
<span class="n">conn</span><span class="o">.</span><span class="n">commit</span><span class="p">()</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="insert_hyperparam"><a class="viewcode-back" href="../../../pyFTS.hyperparam.html#pyFTS.hyperparam.Util.insert_hyperparam">[docs]</a><span class="k">def</span> <span class="nf">insert_hyperparam</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">conn</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Insert benchmark data on database</span>
|
||||
|
||||
<span class="sd"> :param data: a tuple with the benchmark data with format:</span>
|
||||
|
||||
<span class="sd"> Dataset: Identify on which dataset the dataset was performed</span>
|
||||
<span class="sd"> Tag: a user defined word that indentify a benchmark set</span>
|
||||
<span class="sd"> Model: FTS model</span>
|
||||
<span class="sd"> Transformation: The name of data transformation, if one was used</span>
|
||||
<span class="sd"> mf: membership function</span>
|
||||
<span class="sd"> Order: the order of the FTS method</span>
|
||||
<span class="sd"> Partitioner: UoD partitioning scheme</span>
|
||||
<span class="sd"> Partitions: Number of partitions</span>
|
||||
<span class="sd"> alpha: alpha cut</span>
|
||||
<span class="sd"> lags: lags</span>
|
||||
<span class="sd"> Measure: accuracy measure</span>
|
||||
<span class="sd"> Value: the measure value</span>
|
||||
|
||||
<span class="sd"> :param conn: a sqlite3 database connection</span>
|
||||
<span class="sd"> :return:</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">c</span> <span class="o">=</span> <span class="n">conn</span><span class="o">.</span><span class="n">cursor</span><span class="p">()</span>
|
||||
|
||||
<span class="n">c</span><span class="o">.</span><span class="n">execute</span><span class="p">(</span><span class="s2">"INSERT INTO hyperparam(Date, Dataset, Tag, Model, "</span>
|
||||
<span class="o">+</span> <span class="s2">"Transformation, mf, 'Order', Partitioner, Partitions, "</span>
|
||||
<span class="o">+</span> <span class="s2">"alpha, lags, Measure, Value) "</span>
|
||||
<span class="o">+</span> <span class="s2">"VALUES(datetime('now'),?,?,?,?,?,?,?,?,?,?,?,?)"</span><span class="p">,</span> <span class="n">data</span><span class="p">)</span>
|
||||
<span class="n">conn</span><span class="o">.</span><span class="n">commit</span><span class="p">()</span></div>
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../index.html">
|
||||
<img class="logo" src="../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.hyperparam.Util</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,115 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.models.multivariate.FLR — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../../" id="documentation_options" src="../../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../../_static/jquery.js"></script>
|
||||
<script src="../../../../_static/underscore.js"></script>
|
||||
<script src="../../../../_static/doctools.js"></script>
|
||||
<script src="../../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.models.multivariate.FLR</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.models.multivariate.FLR</h1><div class="highlight"><pre>
|
||||
<span></span>
|
||||
|
||||
<div class="viewcode-block" id="FLR"><a class="viewcode-back" href="../../../../pyFTS.models.multivariate.html#pyFTS.models.multivariate.FLR.FLR">[docs]</a><span class="k">class</span> <span class="nc">FLR</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""Multivariate Fuzzy Logical Relationship"""</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Creates a Fuzzy Logical Relationship</span>
|
||||
<span class="sd"> :param LHS: Left Hand Side fuzzy set</span>
|
||||
<span class="sd"> :param RHS: Right Hand Side fuzzy set</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">LHS</span> <span class="o">=</span> <span class="p">{}</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">RHS</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
|
||||
<div class="viewcode-block" id="FLR.set_lhs"><a class="viewcode-back" href="../../../../pyFTS.models.multivariate.html#pyFTS.models.multivariate.FLR.FLR.set_lhs">[docs]</a> <span class="k">def</span> <span class="nf">set_lhs</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">var</span><span class="p">,</span> <span class="nb">set</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">LHS</span><span class="p">[</span><span class="n">var</span><span class="p">]</span> <span class="o">=</span> <span class="nb">set</span></div>
|
||||
|
||||
<div class="viewcode-block" id="FLR.set_rhs"><a class="viewcode-back" href="../../../../pyFTS.models.multivariate.html#pyFTS.models.multivariate.FLR.FLR.set_rhs">[docs]</a> <span class="k">def</span> <span class="nf">set_rhs</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="nb">set</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">RHS</span> <span class="o">=</span> <span class="nb">set</span></div>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="s2">"</span><span class="si">{}</span><span class="s2"> -> </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">([</span><span class="n">k</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">LHS</span><span class="o">.</span><span class="n">values</span><span class="p">()],</span> <span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="p">)</span></div>
|
||||
|
||||
|
||||
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../../index.html">
|
||||
<img class="logo" src="../../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.models.multivariate.FLR</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,167 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.models.multivariate.common — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../../" id="documentation_options" src="../../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../../_static/jquery.js"></script>
|
||||
<script src="../../../../_static/underscore.js"></script>
|
||||
<script src="../../../../_static/doctools.js"></script>
|
||||
<script src="../../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.models.multivariate.common</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.models.multivariate.common</h1><div class="highlight"><pre>
|
||||
<span></span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
<span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.common</span> <span class="kn">import</span> <span class="n">FuzzySet</span><span class="p">,</span> <span class="n">Composite</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="MultivariateFuzzySet"><a class="viewcode-back" href="../../../../pyFTS.models.multivariate.html#pyFTS.models.multivariate.common.MultivariateFuzzySet">[docs]</a><span class="k">class</span> <span class="nc">MultivariateFuzzySet</span><span class="p">(</span><span class="n">Composite</span><span class="o">.</span><span class="n">FuzzySet</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Multivariate Composite Fuzzy Set</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Create an empty composite fuzzy set</span>
|
||||
<span class="sd"> :param name: fuzzy set name</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">MultivariateFuzzySet</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="s2">""</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">sets</span> <span class="o">=</span> <span class="p">{}</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">target_variable</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'target_variable'</span><span class="p">,</span><span class="kc">None</span><span class="p">)</span>
|
||||
|
||||
<div class="viewcode-block" id="MultivariateFuzzySet.append_set"><a class="viewcode-back" href="../../../../pyFTS.models.multivariate.html#pyFTS.models.multivariate.common.MultivariateFuzzySet.append_set">[docs]</a> <span class="k">def</span> <span class="nf">append_set</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">variable</span><span class="p">,</span> <span class="nb">set</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Appends a new fuzzy set from a new variable</span>
|
||||
|
||||
<span class="sd"> :param variable: an multivariate.variable instance</span>
|
||||
<span class="sd"> :param set: an common.FuzzySet instance</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="n">variable</span><span class="p">]</span> <span class="o">=</span> <span class="nb">set</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">variable</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">target_variable</span><span class="o">.</span><span class="n">name</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">centroid</span> <span class="o">=</span> <span class="nb">set</span><span class="o">.</span><span class="n">centroid</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">upper</span> <span class="o">=</span> <span class="nb">set</span><span class="o">.</span><span class="n">upper</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">lower</span> <span class="o">=</span> <span class="nb">set</span><span class="o">.</span><span class="n">lower</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">+=</span> <span class="nb">set</span><span class="o">.</span><span class="n">name</span></div>
|
||||
|
||||
<div class="viewcode-block" id="MultivariateFuzzySet.set_target_variable"><a class="viewcode-back" href="../../../../pyFTS.models.multivariate.html#pyFTS.models.multivariate.common.MultivariateFuzzySet.set_target_variable">[docs]</a> <span class="k">def</span> <span class="nf">set_target_variable</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">variable</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">target_variable</span> <span class="o">=</span> <span class="n">variable</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">centroid</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="n">variable</span><span class="o">.</span><span class="n">name</span><span class="p">]</span><span class="o">.</span><span class="n">centroid</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">upper</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="n">variable</span><span class="o">.</span><span class="n">name</span><span class="p">]</span><span class="o">.</span><span class="n">upper</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">lower</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="n">variable</span><span class="o">.</span><span class="n">name</span><span class="p">]</span><span class="o">.</span><span class="n">lower</span></div>
|
||||
|
||||
<div class="viewcode-block" id="MultivariateFuzzySet.membership"><a class="viewcode-back" href="../../../../pyFTS.models.multivariate.html#pyFTS.models.multivariate.common.MultivariateFuzzySet.membership">[docs]</a> <span class="k">def</span> <span class="nf">membership</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">x</span><span class="p">):</span>
|
||||
<span class="n">mv</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="p">(</span><span class="nb">dict</span><span class="p">,</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">)):</span>
|
||||
<span class="k">for</span> <span class="n">var</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
|
||||
<span class="n">data</span> <span class="o">=</span> <span class="n">x</span><span class="p">[</span><span class="n">var</span><span class="p">]</span>
|
||||
<span class="n">mv</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="n">var</span><span class="p">]</span><span class="o">.</span><span class="n">membership</span><span class="p">(</span><span class="n">data</span><span class="p">))</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">mv</span> <span class="o">=</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">target_variable</span><span class="o">.</span><span class="n">name</span><span class="p">]</span><span class="o">.</span><span class="n">membership</span><span class="p">(</span><span class="n">x</span><span class="p">)]</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">nanmin</span><span class="p">(</span><span class="n">mv</span><span class="p">)</span></div></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="fuzzyfy_instance"><a class="viewcode-back" href="../../../../pyFTS.models.multivariate.html#pyFTS.models.multivariate.common.fuzzyfy_instance">[docs]</a><span class="k">def</span> <span class="nf">fuzzyfy_instance</span><span class="p">(</span><span class="n">data_point</span><span class="p">,</span> <span class="n">var</span><span class="p">,</span> <span class="n">tuples</span><span class="o">=</span><span class="kc">True</span><span class="p">):</span>
|
||||
<span class="c1">#try:</span>
|
||||
<span class="n">fsets</span> <span class="o">=</span> <span class="n">var</span><span class="o">.</span><span class="n">partitioner</span><span class="o">.</span><span class="n">fuzzyfy</span><span class="p">(</span><span class="n">data_point</span><span class="p">,</span> <span class="n">mode</span><span class="o">=</span><span class="s1">'sets'</span><span class="p">,</span> <span class="n">method</span><span class="o">=</span><span class="s1">'fuzzy'</span><span class="p">,</span> <span class="n">alpha_cut</span><span class="o">=</span><span class="n">var</span><span class="o">.</span><span class="n">alpha_cut</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">tuples</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="p">[(</span><span class="n">var</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">fs</span><span class="p">)</span> <span class="k">for</span> <span class="n">fs</span> <span class="ow">in</span> <span class="n">fsets</span><span class="p">]</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">fsets</span></div>
|
||||
<span class="c1">#except Exception as ex:</span>
|
||||
<span class="c1"># print(data_point)</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="fuzzyfy_instance_clustered"><a class="viewcode-back" href="../../../../pyFTS.models.multivariate.html#pyFTS.models.multivariate.common.fuzzyfy_instance_clustered">[docs]</a><span class="k">def</span> <span class="nf">fuzzyfy_instance_clustered</span><span class="p">(</span><span class="n">data_point</span><span class="p">,</span> <span class="n">cluster</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="n">alpha_cut</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'alpha_cut'</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">)</span>
|
||||
<span class="n">mode</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'mode'</span><span class="p">,</span> <span class="s1">'sets'</span><span class="p">)</span>
|
||||
<span class="n">fsets</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">fset</span> <span class="ow">in</span> <span class="n">cluster</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">data_point</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="s1">'name'</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="n">cluster</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="n">fset</span><span class="p">]</span><span class="o">.</span><span class="n">membership</span><span class="p">(</span><span class="n">data_point</span><span class="p">)</span> <span class="o">>=</span> <span class="n">alpha_cut</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="n">mode</span> <span class="o">==</span> <span class="s1">'sets'</span><span class="p">:</span>
|
||||
<span class="n">fsets</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">fset</span><span class="p">)</span>
|
||||
<span class="k">elif</span> <span class="n">mode</span> <span class="o">==</span><span class="s1">'both'</span><span class="p">:</span>
|
||||
<span class="n">fsets</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> <span class="p">(</span><span class="n">fset</span><span class="p">,</span> <span class="n">cluster</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="n">fset</span><span class="p">]</span><span class="o">.</span><span class="n">membership</span><span class="p">(</span><span class="n">data_point</span><span class="p">))</span> <span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">fsets</span></div>
|
||||
|
||||
|
||||
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../../index.html">
|
||||
<img class="logo" src="../../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.models.multivariate.common</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,144 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.models.multivariate.flrg — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../../" id="documentation_options" src="../../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../../_static/jquery.js"></script>
|
||||
<script src="../../../../_static/underscore.js"></script>
|
||||
<script src="../../../../_static/doctools.js"></script>
|
||||
<script src="../../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.models.multivariate.flrg</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.models.multivariate.flrg</h1><div class="highlight"><pre>
|
||||
<span></span>
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.common</span> <span class="kn">import</span> <span class="n">flrg</span> <span class="k">as</span> <span class="n">flg</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="FLRG"><a class="viewcode-back" href="../../../../pyFTS.models.multivariate.html#pyFTS.models.multivariate.flrg.FLRG">[docs]</a><span class="k">class</span> <span class="nc">FLRG</span><span class="p">(</span><span class="n">flg</span><span class="o">.</span><span class="n">FLRG</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Multivariate Fuzzy Logical Rule Group</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">FLRG</span><span class="p">,</span><span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">order</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'order'</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">LHS</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'lhs'</span><span class="p">,</span> <span class="p">{})</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">RHS</span> <span class="o">=</span> <span class="nb">set</span><span class="p">()</span>
|
||||
|
||||
<div class="viewcode-block" id="FLRG.set_lhs"><a class="viewcode-back" href="../../../../pyFTS.models.multivariate.html#pyFTS.models.multivariate.flrg.FLRG.set_lhs">[docs]</a> <span class="k">def</span> <span class="nf">set_lhs</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">var</span><span class="p">,</span> <span class="n">fset</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">order</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">LHS</span><span class="p">[</span><span class="n">var</span><span class="p">]</span> <span class="o">=</span> <span class="n">fset</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="n">var</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">LHS</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">LHS</span><span class="p">[</span><span class="n">var</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">LHS</span><span class="p">[</span><span class="n">var</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">fset</span><span class="p">)</span></div>
|
||||
|
||||
<div class="viewcode-block" id="FLRG.append_rhs"><a class="viewcode-back" href="../../../../pyFTS.models.multivariate.html#pyFTS.models.multivariate.flrg.FLRG.append_rhs">[docs]</a> <span class="k">def</span> <span class="nf">append_rhs</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fset</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="n">fset</span><span class="p">)</span></div>
|
||||
|
||||
<div class="viewcode-block" id="FLRG.get_membership"><a class="viewcode-back" href="../../../../pyFTS.models.multivariate.html#pyFTS.models.multivariate.flrg.FLRG.get_membership">[docs]</a> <span class="k">def</span> <span class="nf">get_membership</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">variables</span><span class="p">):</span>
|
||||
<span class="n">mvs</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">var</span> <span class="ow">in</span> <span class="n">variables</span><span class="p">:</span>
|
||||
<span class="n">s</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">LHS</span><span class="p">[</span><span class="n">var</span><span class="o">.</span><span class="n">name</span><span class="p">]</span>
|
||||
<span class="n">mvs</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">var</span><span class="o">.</span><span class="n">partitioner</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="n">s</span><span class="p">]</span><span class="o">.</span><span class="n">membership</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="n">var</span><span class="o">.</span><span class="n">name</span><span class="p">]))</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">nanmin</span><span class="p">(</span><span class="n">mvs</span><span class="p">)</span></div>
|
||||
|
||||
<div class="viewcode-block" id="FLRG.get_lower"><a class="viewcode-back" href="../../../../pyFTS.models.multivariate.html#pyFTS.models.multivariate.flrg.FLRG.get_lower">[docs]</a> <span class="k">def</span> <span class="nf">get_lower</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sets</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">lower</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">lower</span> <span class="o">=</span> <span class="nb">min</span><span class="p">([</span><span class="n">sets</span><span class="p">[</span><span class="n">rhs</span><span class="p">]</span><span class="o">.</span><span class="n">lower</span> <span class="k">for</span> <span class="n">rhs</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="p">])</span>
|
||||
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">lower</span></div>
|
||||
|
||||
<div class="viewcode-block" id="FLRG.get_upper"><a class="viewcode-back" href="../../../../pyFTS.models.multivariate.html#pyFTS.models.multivariate.flrg.FLRG.get_upper">[docs]</a> <span class="k">def</span> <span class="nf">get_upper</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">sets</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">upper</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">upper</span> <span class="o">=</span> <span class="nb">max</span><span class="p">([</span><span class="n">sets</span><span class="p">[</span><span class="n">rhs</span><span class="p">]</span><span class="o">.</span><span class="n">upper</span> <span class="k">for</span> <span class="n">rhs</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="p">])</span>
|
||||
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">upper</span></div>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="n">_str</span> <span class="o">=</span> <span class="s2">""</span>
|
||||
<span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="p">:</span>
|
||||
<span class="n">_str</span> <span class="o">+=</span> <span class="s2">","</span> <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">_str</span><span class="p">)</span> <span class="o">></span> <span class="mi">0</span> <span class="k">else</span> <span class="s2">""</span>
|
||||
<span class="n">_str</span> <span class="o">+=</span> <span class="n">k</span>
|
||||
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_key</span><span class="p">()</span> <span class="o">+</span> <span class="s2">" -> "</span> <span class="o">+</span> <span class="n">_str</span></div>
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../../index.html">
|
||||
<img class="logo" src="../../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.models.multivariate.flrg</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,228 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.models.multivariate.grid — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../../" id="documentation_options" src="../../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../../_static/jquery.js"></script>
|
||||
<script src="../../../../_static/underscore.js"></script>
|
||||
<script src="../../../../_static/doctools.js"></script>
|
||||
<script src="../../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.models.multivariate.grid</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.models.multivariate.grid</h1><div class="highlight"><pre>
|
||||
<span></span><span class="kn">from</span> <span class="nn">pyFTS.models.multivariate</span> <span class="kn">import</span> <span class="n">partitioner</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.models.multivariate.common</span> <span class="kn">import</span> <span class="n">MultivariateFuzzySet</span><span class="p">,</span> <span class="n">fuzzyfy_instance_clustered</span>
|
||||
<span class="kn">from</span> <span class="nn">itertools</span> <span class="kn">import</span> <span class="n">product</span>
|
||||
<span class="kn">from</span> <span class="nn">scipy.spatial</span> <span class="kn">import</span> <span class="n">KDTree</span>
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
<span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="GridCluster"><a class="viewcode-back" href="../../../../pyFTS.models.multivariate.html#pyFTS.models.multivariate.grid.GridCluster">[docs]</a><span class="k">class</span> <span class="nc">GridCluster</span><span class="p">(</span><span class="n">partitioner</span><span class="o">.</span><span class="n">MultivariatePartitioner</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> A cartesian product of all fuzzy sets of all variables</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">GridCluster</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="o">=</span><span class="s2">"GridCluster"</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">build</span><span class="p">(</span><span class="kc">None</span><span class="p">)</span>
|
||||
|
||||
<div class="viewcode-block" id="GridCluster.build"><a class="viewcode-back" href="../../../../pyFTS.models.multivariate.html#pyFTS.models.multivariate.grid.GridCluster.build">[docs]</a> <span class="k">def</span> <span class="nf">build</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
|
||||
|
||||
<span class="n">fsets</span> <span class="o">=</span> <span class="p">[[</span><span class="n">x</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="n">k</span><span class="o">.</span><span class="n">partitioner</span><span class="o">.</span><span class="n">sets</span><span class="o">.</span><span class="n">values</span><span class="p">()]</span>
|
||||
<span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">explanatory_variables</span><span class="p">]</span>
|
||||
<span class="n">c</span> <span class="o">=</span> <span class="mi">0</span>
|
||||
<span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">product</span><span class="p">(</span><span class="o">*</span><span class="n">fsets</span><span class="p">):</span>
|
||||
<span class="n">mvfset</span> <span class="o">=</span> <span class="n">MultivariateFuzzySet</span><span class="p">(</span><span class="n">target_variable</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">target_variable</span><span class="p">)</span>
|
||||
<span class="k">for</span> <span class="n">fset</span> <span class="ow">in</span> <span class="n">k</span><span class="p">:</span>
|
||||
<span class="n">mvfset</span><span class="o">.</span><span class="n">append_set</span><span class="p">(</span><span class="n">fset</span><span class="o">.</span><span class="n">variable</span><span class="p">,</span> <span class="n">fset</span><span class="p">)</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="n">mvfset</span><span class="o">.</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="n">mvfset</span>
|
||||
<span class="n">c</span> <span class="o">+=</span> <span class="mi">1</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">build_index</span><span class="p">()</span></div>
|
||||
|
||||
<div class="viewcode-block" id="GridCluster.defuzzyfy"><a class="viewcode-back" href="../../../../pyFTS.models.multivariate.html#pyFTS.models.multivariate.grid.GridCluster.defuzzyfy">[docs]</a> <span class="k">def</span> <span class="nf">defuzzyfy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">values</span><span class="p">,</span> <span class="n">mode</span><span class="o">=</span><span class="s1">'both'</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">values</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span>
|
||||
<span class="n">values</span> <span class="o">=</span> <span class="p">[</span><span class="n">values</span><span class="p">]</span>
|
||||
|
||||
<span class="n">ret</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">val</span> <span class="ow">in</span> <span class="n">values</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="n">mode</span> <span class="o">==</span> <span class="s1">'both'</span><span class="p">:</span>
|
||||
<span class="n">num</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="n">den</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">fset</span><span class="p">,</span> <span class="n">mv</span> <span class="ow">in</span> <span class="n">val</span><span class="p">:</span>
|
||||
<span class="n">num</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="n">fset</span><span class="p">]</span><span class="o">.</span><span class="n">centroid</span> <span class="o">*</span> <span class="n">mv</span><span class="p">)</span>
|
||||
<span class="n">den</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">mv</span><span class="p">)</span>
|
||||
<span class="n">ret</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">nansum</span><span class="p">(</span><span class="n">num</span><span class="p">)</span> <span class="o">/</span> <span class="n">np</span><span class="o">.</span><span class="n">nansum</span><span class="p">(</span><span class="n">den</span><span class="p">))</span>
|
||||
<span class="k">elif</span> <span class="n">mode</span> <span class="o">==</span> <span class="s1">'both'</span><span class="p">:</span>
|
||||
<span class="n">num</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">mean</span><span class="p">([</span><span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="n">fset</span><span class="p">]</span><span class="o">.</span><span class="n">centroid</span> <span class="k">for</span> <span class="n">fset</span> <span class="ow">in</span> <span class="n">val</span><span class="p">])</span>
|
||||
<span class="n">ret</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">num</span><span class="p">)</span>
|
||||
<span class="k">elif</span> <span class="n">mode</span> <span class="o">==</span> <span class="s1">'vector'</span><span class="p">:</span>
|
||||
<span class="n">num</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="n">den</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">fset</span><span class="p">,</span> <span class="n">mv</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">val</span><span class="p">):</span>
|
||||
<span class="n">num</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">ordered_sets</span><span class="p">[</span><span class="n">fset</span><span class="p">]]</span><span class="o">.</span><span class="n">centroid</span> <span class="o">*</span> <span class="n">mv</span><span class="p">)</span>
|
||||
<span class="n">den</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">mv</span><span class="p">)</span>
|
||||
<span class="n">ret</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">nansum</span><span class="p">(</span><span class="n">num</span><span class="p">)</span> <span class="o">/</span> <span class="n">np</span><span class="o">.</span><span class="n">nansum</span><span class="p">(</span><span class="n">den</span><span class="p">))</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s1">'Unknown deffuzyfication mode'</span><span class="p">)</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">ret</span></div></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="IncrementalGridCluster"><a class="viewcode-back" href="../../../../pyFTS.models.multivariate.html#pyFTS.models.multivariate.grid.IncrementalGridCluster">[docs]</a><span class="k">class</span> <span class="nc">IncrementalGridCluster</span><span class="p">(</span><span class="n">partitioner</span><span class="o">.</span><span class="n">MultivariatePartitioner</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Create combinations of fuzzy sets of the variables on demand, incrementally increasing the</span>
|
||||
<span class="sd"> multivariate fuzzy set base.</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">IncrementalGridCluster</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="o">=</span><span class="s2">"IncrementalGridCluster"</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">build</span><span class="p">(</span><span class="kc">None</span><span class="p">)</span>
|
||||
|
||||
<div class="viewcode-block" id="IncrementalGridCluster.fuzzyfy"><a class="viewcode-back" href="../../../../pyFTS.models.multivariate.html#pyFTS.models.multivariate.grid.IncrementalGridCluster.fuzzyfy">[docs]</a> <span class="k">def</span> <span class="nf">fuzzyfy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
|
||||
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">):</span>
|
||||
<span class="n">ret</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">index</span><span class="p">,</span> <span class="n">inst</span> <span class="ow">in</span> <span class="n">data</span><span class="o">.</span><span class="n">iterrows</span><span class="p">():</span>
|
||||
<span class="n">mv</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">fuzzyfy</span><span class="p">(</span><span class="n">inst</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
<span class="n">ret</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">mv</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">ret</span>
|
||||
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">kdtree</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">fsets</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="s1">'name'</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">fsets</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">incremental_search</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="s1">'name'</span><span class="p">)</span>
|
||||
|
||||
<span class="n">mode</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'mode'</span><span class="p">,</span> <span class="s1">'sets'</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">mode</span> <span class="o">==</span> <span class="s1">'sets'</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">fsets</span>
|
||||
<span class="k">elif</span> <span class="n">mode</span> <span class="o">==</span> <span class="s1">'vector'</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="ne">NotImplementedError</span><span class="p">()</span>
|
||||
<span class="k">elif</span> <span class="n">mode</span> <span class="o">==</span> <span class="s1">'both'</span><span class="p">:</span>
|
||||
<span class="n">ret</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">fsets</span><span class="p">:</span>
|
||||
<span class="n">mvfset</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="n">key</span><span class="p">]</span>
|
||||
<span class="n">ret</span><span class="o">.</span><span class="n">append</span><span class="p">((</span><span class="n">key</span><span class="p">,</span> <span class="n">mvfset</span><span class="o">.</span><span class="n">membership</span><span class="p">(</span><span class="n">data</span><span class="p">)))</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">ret</span></div>
|
||||
|
||||
<div class="viewcode-block" id="IncrementalGridCluster.incremental_search"><a class="viewcode-back" href="../../../../pyFTS.models.multivariate.html#pyFTS.models.multivariate.grid.IncrementalGridCluster.incremental_search">[docs]</a> <span class="k">def</span> <span class="nf">incremental_search</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="n">alpha_cut</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'alpha_cut'</span><span class="p">,</span> <span class="mf">0.</span><span class="p">)</span>
|
||||
<span class="n">mode</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'mode'</span><span class="p">,</span> <span class="s1">'sets'</span><span class="p">)</span>
|
||||
|
||||
<span class="n">fsets</span> <span class="o">=</span> <span class="p">{}</span>
|
||||
<span class="n">ret</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">var</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">explanatory_variables</span><span class="p">:</span>
|
||||
<span class="n">ac</span> <span class="o">=</span> <span class="n">alpha_cut</span> <span class="k">if</span> <span class="n">alpha_cut</span> <span class="o">></span> <span class="mf">0.</span> <span class="k">else</span> <span class="n">var</span><span class="o">.</span><span class="n">alpha_cut</span>
|
||||
<span class="n">fsets</span><span class="p">[</span><span class="n">var</span><span class="o">.</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="n">var</span><span class="o">.</span><span class="n">partitioner</span><span class="o">.</span><span class="n">fuzzyfy</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="n">var</span><span class="o">.</span><span class="n">name</span><span class="p">],</span> <span class="n">mode</span><span class="o">=</span><span class="n">mode</span><span class="p">,</span> <span class="n">alpha_cut</span><span class="o">=</span><span class="n">ac</span><span class="p">)</span>
|
||||
|
||||
<span class="n">fsets_by_var</span> <span class="o">=</span> <span class="p">[</span><span class="n">fsets</span> <span class="k">for</span> <span class="n">var</span><span class="p">,</span> <span class="n">fsets</span> <span class="ow">in</span> <span class="n">fsets</span><span class="o">.</span><span class="n">items</span><span class="p">()]</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="n">product</span><span class="p">(</span><span class="o">*</span><span class="n">fsets_by_var</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="n">mode</span> <span class="o">==</span> <span class="s1">'both'</span><span class="p">:</span>
|
||||
<span class="n">path</span> <span class="o">=</span> <span class="p">[</span><span class="n">fset</span> <span class="k">for</span> <span class="n">fset</span><span class="p">,</span> <span class="n">mv</span> <span class="ow">in</span> <span class="n">p</span><span class="p">]</span>
|
||||
<span class="n">mv</span> <span class="o">=</span> <span class="p">[</span><span class="n">mv</span> <span class="k">for</span> <span class="n">fset</span><span class="p">,</span> <span class="n">mv</span> <span class="ow">in</span> <span class="n">p</span><span class="p">]</span>
|
||||
<span class="n">key</span> <span class="o">=</span> <span class="s1">''</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
|
||||
<span class="k">elif</span> <span class="n">mode</span> <span class="o">==</span> <span class="s1">'sets'</span><span class="p">:</span>
|
||||
<span class="n">key</span> <span class="o">=</span> <span class="s1">''</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">p</span><span class="p">)</span>
|
||||
<span class="n">path</span> <span class="o">=</span> <span class="n">p</span>
|
||||
<span class="k">if</span> <span class="n">key</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">:</span>
|
||||
<span class="n">mvfset</span> <span class="o">=</span> <span class="n">MultivariateFuzzySet</span><span class="p">(</span><span class="n">target_variable</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">target_variable</span><span class="p">)</span>
|
||||
<span class="k">for</span> <span class="n">ct</span><span class="p">,</span> <span class="n">fs</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">path</span><span class="p">):</span>
|
||||
<span class="n">mvfset</span><span class="o">.</span><span class="n">append_set</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">explanatory_variables</span><span class="p">[</span><span class="n">ct</span><span class="p">]</span><span class="o">.</span><span class="n">name</span><span class="p">,</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">explanatory_variables</span><span class="p">[</span><span class="n">ct</span><span class="p">]</span><span class="o">.</span><span class="n">partitioner</span><span class="p">[</span><span class="n">fs</span><span class="p">])</span>
|
||||
<span class="n">mvfset</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="n">key</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="n">mvfset</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">mode</span> <span class="o">==</span> <span class="s1">'sets'</span><span class="p">:</span>
|
||||
<span class="n">ret</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">key</span><span class="p">)</span>
|
||||
<span class="k">elif</span> <span class="n">mode</span> <span class="o">==</span> <span class="s1">'both'</span><span class="p">:</span>
|
||||
<span class="n">ret</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> <span class="nb">tuple</span><span class="p">(</span><span class="n">key</span><span class="p">,</span><span class="n">np</span><span class="o">.</span><span class="n">nanmin</span><span class="p">(</span><span class="n">mv</span><span class="p">))</span> <span class="p">)</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">ret</span></div>
|
||||
|
||||
<div class="viewcode-block" id="IncrementalGridCluster.prune"><a class="viewcode-back" href="../../../../pyFTS.models.multivariate.html#pyFTS.models.multivariate.grid.IncrementalGridCluster.prune">[docs]</a> <span class="k">def</span> <span class="nf">prune</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">build_index</span><span class="p">()</span></div></div>
|
||||
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../../index.html">
|
||||
<img class="logo" src="../../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.models.multivariate.grid</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,210 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.models.multivariate.partitioner — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../../" id="documentation_options" src="../../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../../_static/jquery.js"></script>
|
||||
<script src="../../../../_static/underscore.js"></script>
|
||||
<script src="../../../../_static/doctools.js"></script>
|
||||
<script src="../../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.models.multivariate.partitioner</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.models.multivariate.partitioner</h1><div class="highlight"><pre>
|
||||
<span></span><span class="kn">from</span> <span class="nn">pyFTS.partitioners</span> <span class="kn">import</span> <span class="n">partitioner</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.models.multivariate.common</span> <span class="kn">import</span> <span class="n">MultivariateFuzzySet</span><span class="p">,</span> <span class="n">fuzzyfy_instance_clustered</span>
|
||||
<span class="kn">from</span> <span class="nn">itertools</span> <span class="kn">import</span> <span class="n">product</span>
|
||||
<span class="kn">from</span> <span class="nn">scipy.spatial</span> <span class="kn">import</span> <span class="n">KDTree</span>
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
<span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="MultivariatePartitioner"><a class="viewcode-back" href="../../../../pyFTS.models.multivariate.html#pyFTS.models.multivariate.partitioner.MultivariatePartitioner">[docs]</a><span class="k">class</span> <span class="nc">MultivariatePartitioner</span><span class="p">(</span><span class="n">partitioner</span><span class="o">.</span><span class="n">Partitioner</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Base class for partitioners which use the MultivariateFuzzySet</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">MultivariatePartitioner</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s2">"MultivariatePartitioner"</span><span class="p">,</span> <span class="n">preprocess</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">type</span> <span class="o">=</span> <span class="s1">'multivariate'</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">sets</span> <span class="o">=</span> <span class="p">{}</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">kdtree</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">index</span> <span class="o">=</span> <span class="p">{}</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">explanatory_variables</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'explanatory_variables'</span><span class="p">,</span> <span class="p">[])</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">target_variable</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'target_variable'</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">neighbors</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'neighbors'</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">optimize</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'optimize'</span><span class="p">,</span> <span class="kc">True</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">optimize</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">count</span> <span class="o">=</span> <span class="p">{}</span>
|
||||
<span class="n">data</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'data'</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">build</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">uod</span> <span class="o">=</span> <span class="p">{}</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">min</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">target_variable</span><span class="o">.</span><span class="n">partitioner</span><span class="o">.</span><span class="n">min</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">max</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">target_variable</span><span class="o">.</span><span class="n">partitioner</span><span class="o">.</span><span class="n">max</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="MultivariatePartitioner.format_data"><a class="viewcode-back" href="../../../../pyFTS.models.multivariate.html#pyFTS.models.multivariate.partitioner.MultivariatePartitioner.format_data">[docs]</a> <span class="k">def</span> <span class="nf">format_data</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
|
||||
<span class="n">ndata</span> <span class="o">=</span> <span class="p">{}</span>
|
||||
<span class="k">for</span> <span class="n">var</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">explanatory_variables</span><span class="p">:</span>
|
||||
<span class="n">ndata</span><span class="p">[</span><span class="n">var</span><span class="o">.</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="n">var</span><span class="o">.</span><span class="n">partitioner</span><span class="o">.</span><span class="n">extractor</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="n">var</span><span class="o">.</span><span class="n">data_label</span><span class="p">])</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">ndata</span></div>
|
||||
|
||||
<div class="viewcode-block" id="MultivariatePartitioner.build"><a class="viewcode-back" href="../../../../pyFTS.models.multivariate.html#pyFTS.models.multivariate.partitioner.MultivariatePartitioner.build">[docs]</a> <span class="k">def</span> <span class="nf">build</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
|
||||
<span class="k">pass</span></div>
|
||||
|
||||
<div class="viewcode-block" id="MultivariatePartitioner.append"><a class="viewcode-back" href="../../../../pyFTS.models.multivariate.html#pyFTS.models.multivariate.partitioner.MultivariatePartitioner.append">[docs]</a> <span class="k">def</span> <span class="nf">append</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fset</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="n">fset</span><span class="o">.</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="n">fset</span></div>
|
||||
|
||||
<div class="viewcode-block" id="MultivariatePartitioner.prune"><a class="viewcode-back" href="../../../../pyFTS.models.multivariate.html#pyFTS.models.multivariate.partitioner.MultivariatePartitioner.prune">[docs]</a> <span class="k">def</span> <span class="nf">prune</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">optimize</span><span class="p">:</span>
|
||||
<span class="k">return</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">fset</span> <span class="ow">in</span> <span class="p">[</span><span class="n">fs</span> <span class="k">for</span> <span class="n">fs</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="o">.</span><span class="n">keys</span><span class="p">()]:</span>
|
||||
<span class="k">if</span> <span class="n">fset</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">count</span><span class="p">:</span>
|
||||
<span class="n">fs</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="n">fset</span><span class="p">)</span>
|
||||
<span class="k">del</span> <span class="p">(</span><span class="n">fs</span><span class="p">)</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">build_index</span><span class="p">()</span></div>
|
||||
|
||||
<div class="viewcode-block" id="MultivariatePartitioner.search"><a class="viewcode-back" href="../../../../pyFTS.models.multivariate.html#pyFTS.models.multivariate.partitioner.MultivariatePartitioner.search">[docs]</a> <span class="k">def</span> <span class="nf">search</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Perform a search for the nearest fuzzy sets of the point 'data'. This function were designed to work with several</span>
|
||||
<span class="sd"> overlapped fuzzy sets.</span>
|
||||
|
||||
<span class="sd"> :param data: the value to search for the nearest fuzzy sets</span>
|
||||
<span class="sd"> :param type: the return type: 'index' for the fuzzy set indexes or 'name' for fuzzy set names.</span>
|
||||
<span class="sd"> :return: a list with the nearest fuzzy sets</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">kdtree</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">build_index</span><span class="p">()</span>
|
||||
|
||||
<span class="nb">type</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'type'</span><span class="p">,</span> <span class="s1">'index'</span><span class="p">)</span>
|
||||
|
||||
<span class="n">ndata</span> <span class="o">=</span> <span class="p">[</span><span class="n">data</span><span class="p">[</span><span class="n">k</span><span class="o">.</span><span class="n">name</span><span class="p">]</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">explanatory_variables</span><span class="p">]</span>
|
||||
<span class="n">_</span><span class="p">,</span> <span class="n">ix</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">kdtree</span><span class="o">.</span><span class="n">query</span><span class="p">(</span><span class="n">ndata</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">neighbors</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">ix</span><span class="p">,</span> <span class="p">(</span><span class="nb">list</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">)):</span>
|
||||
<span class="n">ix</span> <span class="o">=</span> <span class="p">[</span><span class="n">ix</span><span class="p">]</span>
|
||||
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">optimize</span><span class="p">:</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">ix</span><span class="p">:</span>
|
||||
<span class="n">tmp</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">index</span><span class="p">[</span><span class="n">k</span><span class="p">])</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">count</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">index</span><span class="p">[</span><span class="n">k</span><span class="p">]]</span> <span class="o">=</span> <span class="mi">1</span>
|
||||
|
||||
<span class="k">if</span> <span class="nb">type</span> <span class="o">==</span> <span class="s1">'name'</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">index</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">ix</span><span class="p">]</span>
|
||||
<span class="k">elif</span> <span class="nb">type</span> <span class="o">==</span> <span class="s1">'index'</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">ix</span><span class="p">)</span></div>
|
||||
|
||||
<div class="viewcode-block" id="MultivariatePartitioner.fuzzyfy"><a class="viewcode-back" href="../../../../pyFTS.models.multivariate.html#pyFTS.models.multivariate.partitioner.MultivariatePartitioner.fuzzyfy">[docs]</a> <span class="k">def</span> <span class="nf">fuzzyfy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="n">fuzzyfy_instance_clustered</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span></div>
|
||||
|
||||
<div class="viewcode-block" id="MultivariatePartitioner.change_target_variable"><a class="viewcode-back" href="../../../../pyFTS.models.multivariate.html#pyFTS.models.multivariate.partitioner.MultivariatePartitioner.change_target_variable">[docs]</a> <span class="k">def</span> <span class="nf">change_target_variable</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">variable</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">target_variable</span> <span class="o">=</span> <span class="n">variable</span>
|
||||
<span class="k">for</span> <span class="n">fset</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="o">.</span><span class="n">values</span><span class="p">():</span>
|
||||
<span class="n">fset</span><span class="o">.</span><span class="n">set_target_variable</span><span class="p">(</span><span class="n">variable</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">min</span> <span class="o">=</span> <span class="n">variable</span><span class="o">.</span><span class="n">partitioner</span><span class="o">.</span><span class="n">min</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">max</span> <span class="o">=</span> <span class="n">variable</span><span class="o">.</span><span class="n">partitioner</span><span class="o">.</span><span class="n">max</span></div>
|
||||
|
||||
<div class="viewcode-block" id="MultivariatePartitioner.build_index"><a class="viewcode-back" href="../../../../pyFTS.models.multivariate.html#pyFTS.models.multivariate.partitioner.MultivariatePartitioner.build_index">[docs]</a> <span class="k">def</span> <span class="nf">build_index</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
|
||||
<span class="n">midpoints</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">index</span> <span class="o">=</span> <span class="p">{}</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">ct</span><span class="p">,</span> <span class="n">fset</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="o">.</span><span class="n">values</span><span class="p">()):</span>
|
||||
<span class="n">mp</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">vr</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">explanatory_variables</span><span class="p">:</span>
|
||||
<span class="n">mp</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">fset</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="n">vr</span><span class="o">.</span><span class="n">name</span><span class="p">]</span><span class="o">.</span><span class="n">centroid</span><span class="p">)</span>
|
||||
<span class="n">midpoints</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">mp</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">index</span><span class="p">[</span><span class="n">ct</span><span class="p">]</span> <span class="o">=</span> <span class="n">fset</span><span class="o">.</span><span class="n">name</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">sys</span>
|
||||
<span class="n">sys</span><span class="o">.</span><span class="n">setrecursionlimit</span><span class="p">(</span><span class="mi">100000</span><span class="p">)</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">kdtree</span> <span class="o">=</span> <span class="n">KDTree</span><span class="p">(</span><span class="n">midpoints</span><span class="p">)</span>
|
||||
|
||||
<span class="n">sys</span><span class="o">.</span><span class="n">setrecursionlimit</span><span class="p">(</span><span class="mi">1000</span><span class="p">)</span></div></div>
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../../index.html">
|
||||
<img class="logo" src="../../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.models.multivariate.partitioner</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,332 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.models.nonstationary.common — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../../" id="documentation_options" src="../../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../../_static/jquery.js"></script>
|
||||
<script src="../../../../_static/underscore.js"></script>
|
||||
<script src="../../../../_static/doctools.js"></script>
|
||||
<script src="../../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.models.nonstationary.common</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.models.nonstationary.common</h1><div class="highlight"><pre>
|
||||
<span></span><span class="sd">"""</span>
|
||||
<span class="sd">Non Stationary Fuzzy Sets</span>
|
||||
|
||||
<span class="sd">GARIBALDI, Jonathan M.; JAROSZEWSKI, Marcin; MUSIKASUWAN, Salang. Nonstationary fuzzy sets.</span>
|
||||
<span class="sd">IEEE Transactions on Fuzzy Systems, v. 16, n. 4, p. 1072-1086, 2008.</span>
|
||||
<span class="sd">"""</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS</span> <span class="kn">import</span> <span class="o">*</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.common</span> <span class="kn">import</span> <span class="n">FuzzySet</span> <span class="k">as</span> <span class="n">FS</span><span class="p">,</span> <span class="n">Membership</span><span class="p">,</span> <span class="n">FLR</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.partitioners</span> <span class="kn">import</span> <span class="n">partitioner</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.models.nonstationary</span> <span class="kn">import</span> <span class="n">perturbation</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="FuzzySet"><a class="viewcode-back" href="../../../../pyFTS.models.nonstationary.html#pyFTS.models.nonstationary.common.FuzzySet">[docs]</a><span class="k">class</span> <span class="nc">FuzzySet</span><span class="p">(</span><span class="n">FS</span><span class="o">.</span><span class="n">FuzzySet</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Non Stationary Fuzzy Sets</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">mf</span><span class="p">,</span> <span class="n">parameters</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Constructor</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">FuzzySet</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="n">name</span><span class="p">,</span> <span class="n">mf</span><span class="o">=</span><span class="n">mf</span><span class="p">,</span> <span class="n">parameters</span><span class="o">=</span><span class="n">parameters</span><span class="p">,</span> <span class="n">centroid</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">alpha</span><span class="o">=</span><span class="mf">1.0</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">location</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"location"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
|
||||
<span class="w"> </span><span class="sd">"""Pertubation function that affects the location of the membership function"""</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">location_params</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"location_params"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
|
||||
<span class="w"> </span><span class="sd">"""Parameters for location pertubation function"""</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">location_roots</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"location_roots"</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">width</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"width"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
|
||||
<span class="w"> </span><span class="sd">"""Pertubation function that affects the width of the membership function"""</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">width_params</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"width_params"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
|
||||
<span class="w"> </span><span class="sd">"""Parameters for width pertubation function"""</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">width_roots</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"width_roots"</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">noise</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"noise"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
|
||||
<span class="w"> </span><span class="sd">"""Pertubation function that adds noise on the membership function"""</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">noise_params</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"noise_params"</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
|
||||
<span class="w"> </span><span class="sd">"""Parameters for noise pertubation function"""</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">perturbated_parameters</span> <span class="o">=</span> <span class="p">{}</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">type</span> <span class="o">=</span> <span class="s1">'nonstationary'</span>
|
||||
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">location</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="ow">and</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">location</span><span class="p">,</span> <span class="p">(</span><span class="nb">list</span><span class="p">,</span> <span class="nb">set</span><span class="p">)):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">location</span> <span class="o">=</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">location</span><span class="p">]</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">location_params</span> <span class="o">=</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">location_params</span><span class="p">]</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">location_roots</span> <span class="o">=</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">location_roots</span><span class="p">]</span>
|
||||
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">width</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span> <span class="ow">and</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">width</span><span class="p">,</span> <span class="p">(</span><span class="nb">list</span><span class="p">,</span> <span class="nb">set</span><span class="p">)):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">width</span> <span class="o">=</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">width</span><span class="p">]</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">width_params</span> <span class="o">=</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">width_params</span><span class="p">]</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">width_roots</span> <span class="o">=</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">width_roots</span><span class="p">]</span>
|
||||
|
||||
<div class="viewcode-block" id="FuzzySet.perform_location"><a class="viewcode-back" href="../../../../pyFTS.models.nonstationary.html#pyFTS.models.nonstationary.common.FuzzySet.perform_location">[docs]</a> <span class="k">def</span> <span class="nf">perform_location</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">t</span><span class="p">,</span> <span class="n">param</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">location</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">inc</span> <span class="o">=</span> <span class="n">t</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">l</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">location</span><span class="p">)</span>
|
||||
<span class="n">inc</span> <span class="o">=</span> <span class="nb">sum</span><span class="p">([</span><span class="bp">self</span><span class="o">.</span><span class="n">location</span><span class="p">[</span><span class="n">k</span><span class="p">](</span><span class="n">t</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">location_roots</span><span class="p">[</span><span class="n">k</span><span class="p">],</span> <span class="bp">self</span><span class="o">.</span><span class="n">location_params</span><span class="p">[</span><span class="n">k</span><span class="p">])</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">l</span><span class="p">)])</span>
|
||||
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">mf</span> <span class="o">==</span> <span class="n">Membership</span><span class="o">.</span><span class="n">gaussmf</span><span class="p">:</span>
|
||||
<span class="c1"># changes only the mean parameter</span>
|
||||
<span class="k">return</span> <span class="p">[</span><span class="n">param</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">+</span> <span class="n">inc</span><span class="p">,</span> <span class="n">param</span><span class="p">[</span><span class="mi">1</span><span class="p">]]</span>
|
||||
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">mf</span> <span class="o">==</span> <span class="n">Membership</span><span class="o">.</span><span class="n">sigmf</span><span class="p">:</span>
|
||||
<span class="c1"># changes only the midpoint parameter</span>
|
||||
<span class="k">return</span> <span class="p">[</span><span class="n">param</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">param</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="n">inc</span><span class="p">]</span>
|
||||
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">mf</span> <span class="o">==</span> <span class="n">Membership</span><span class="o">.</span><span class="n">bellmf</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="p">[</span><span class="n">param</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">param</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">param</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">+</span> <span class="n">inc</span><span class="p">]</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="c1"># translate all parameters</span>
|
||||
<span class="k">return</span> <span class="p">[</span><span class="n">k</span> <span class="o">+</span> <span class="n">inc</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">param</span><span class="p">]</span></div>
|
||||
|
||||
<div class="viewcode-block" id="FuzzySet.perform_width"><a class="viewcode-back" href="../../../../pyFTS.models.nonstationary.html#pyFTS.models.nonstationary.common.FuzzySet.perform_width">[docs]</a> <span class="k">def</span> <span class="nf">perform_width</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">t</span><span class="p">,</span> <span class="n">param</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">width</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">inc</span> <span class="o">=</span> <span class="n">t</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
|
||||
<span class="n">l</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">width</span><span class="p">)</span>
|
||||
|
||||
<span class="n">inc</span> <span class="o">=</span> <span class="nb">sum</span><span class="p">([</span><span class="bp">self</span><span class="o">.</span><span class="n">width</span><span class="p">[</span><span class="n">k</span><span class="p">](</span><span class="n">t</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">width_roots</span><span class="p">[</span><span class="n">k</span><span class="p">],</span> <span class="bp">self</span><span class="o">.</span><span class="n">width_params</span><span class="p">[</span><span class="n">k</span><span class="p">])</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">l</span><span class="p">)])</span>
|
||||
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">mf</span> <span class="o">==</span> <span class="n">Membership</span><span class="o">.</span><span class="n">gaussmf</span><span class="p">:</span>
|
||||
<span class="c1"># changes only the variance parameter</span>
|
||||
<span class="k">return</span> <span class="p">[</span><span class="n">param</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">param</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="n">inc</span><span class="p">]</span>
|
||||
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">mf</span> <span class="o">==</span> <span class="n">Membership</span><span class="o">.</span><span class="n">sigmf</span><span class="p">:</span>
|
||||
<span class="c1"># changes only the smooth parameter</span>
|
||||
<span class="k">return</span> <span class="p">[</span><span class="n">param</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">+</span> <span class="n">inc</span><span class="p">,</span> <span class="n">param</span><span class="p">[</span><span class="mi">1</span><span class="p">]]</span>
|
||||
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">mf</span> <span class="o">==</span> <span class="n">Membership</span><span class="o">.</span><span class="n">trimf</span><span class="p">:</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">inc</span> <span class="o">/</span> <span class="mi">2</span>
|
||||
<span class="k">return</span> <span class="p">[</span><span class="n">param</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">-</span> <span class="n">tmp</span><span class="p">,</span> <span class="n">param</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">param</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">+</span> <span class="n">tmp</span><span class="p">]</span>
|
||||
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">mf</span> <span class="o">==</span> <span class="n">Membership</span><span class="o">.</span><span class="n">trapmf</span><span class="p">:</span>
|
||||
<span class="n">l</span> <span class="o">=</span> <span class="p">(</span><span class="n">param</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span> <span class="o">-</span> <span class="n">param</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
|
||||
<span class="n">rab</span> <span class="o">=</span> <span class="p">(</span><span class="n">param</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">-</span> <span class="n">param</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="o">/</span> <span class="n">l</span>
|
||||
<span class="n">rcd</span> <span class="o">=</span> <span class="p">(</span><span class="n">param</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span> <span class="o">-</span> <span class="n">param</span><span class="p">[</span><span class="mi">2</span><span class="p">])</span> <span class="o">/</span> <span class="n">l</span>
|
||||
<span class="k">return</span> <span class="p">[</span><span class="n">param</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">-</span> <span class="n">inc</span><span class="p">,</span> <span class="n">param</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">-</span> <span class="n">inc</span> <span class="o">*</span> <span class="n">rab</span><span class="p">,</span> <span class="n">param</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">+</span> <span class="n">inc</span> <span class="o">*</span> <span class="n">rcd</span><span class="p">,</span> <span class="n">param</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span> <span class="o">+</span> <span class="n">inc</span><span class="p">]</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">param</span></div>
|
||||
|
||||
<div class="viewcode-block" id="FuzzySet.membership"><a class="viewcode-back" href="../../../../pyFTS.models.nonstationary.html#pyFTS.models.nonstationary.common.FuzzySet.membership">[docs]</a> <span class="k">def</span> <span class="nf">membership</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">x</span><span class="p">,</span> <span class="n">t</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Calculate the membership value of a given input</span>
|
||||
|
||||
<span class="sd"> :param x: input value</span>
|
||||
<span class="sd"> :param t: time displacement or perturbation parameters</span>
|
||||
<span class="sd"> :return: membership value of x at this fuzzy set</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">perturbate_parameters</span><span class="p">(</span><span class="n">t</span><span class="p">)</span>
|
||||
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">mf</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">perturbated_parameters</span><span class="p">[</span><span class="nb">str</span><span class="p">(</span><span class="n">t</span><span class="p">)])</span>
|
||||
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">noise</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">tmp</span> <span class="o">+=</span> <span class="bp">self</span><span class="o">.</span><span class="n">noise</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">noise_params</span><span class="p">)</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">tmp</span></div>
|
||||
|
||||
<div class="viewcode-block" id="FuzzySet.perturbate_parameters"><a class="viewcode-back" href="../../../../pyFTS.models.nonstationary.html#pyFTS.models.nonstationary.common.FuzzySet.perturbate_parameters">[docs]</a> <span class="k">def</span> <span class="nf">perturbate_parameters</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">t</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="nb">str</span><span class="p">(</span><span class="n">t</span><span class="p">)</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">perturbated_parameters</span><span class="p">:</span>
|
||||
<span class="n">param</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">parameters</span>
|
||||
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="p">(</span><span class="nb">list</span><span class="p">,</span> <span class="nb">set</span><span class="p">)):</span>
|
||||
<span class="n">param</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">perform_location</span><span class="p">(</span><span class="n">t</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">param</span><span class="p">)</span>
|
||||
<span class="n">param</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">perform_width</span><span class="p">(</span><span class="n">t</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">param</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">param</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">perform_location</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">param</span><span class="p">)</span>
|
||||
<span class="n">param</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">perform_width</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">param</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">perturbated_parameters</span><span class="p">[</span><span class="nb">str</span><span class="p">(</span><span class="n">t</span><span class="p">)]</span> <span class="o">=</span> <span class="n">param</span></div>
|
||||
|
||||
<div class="viewcode-block" id="FuzzySet.get_midpoint"><a class="viewcode-back" href="../../../../pyFTS.models.nonstationary.html#pyFTS.models.nonstationary.common.FuzzySet.get_midpoint">[docs]</a> <span class="k">def</span> <span class="nf">get_midpoint</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">t</span><span class="p">):</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">perturbate_parameters</span><span class="p">(</span><span class="n">t</span><span class="p">)</span>
|
||||
<span class="n">param</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">perturbated_parameters</span><span class="p">[</span><span class="nb">str</span><span class="p">(</span><span class="n">t</span><span class="p">)]</span>
|
||||
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">mf</span> <span class="o">==</span> <span class="n">Membership</span><span class="o">.</span><span class="n">gaussmf</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">param</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
|
||||
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">mf</span> <span class="o">==</span> <span class="n">Membership</span><span class="o">.</span><span class="n">sigmf</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">param</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
|
||||
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">mf</span> <span class="o">==</span> <span class="n">Membership</span><span class="o">.</span><span class="n">trimf</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">param</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
|
||||
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">mf</span> <span class="o">==</span> <span class="n">Membership</span><span class="o">.</span><span class="n">trapmf</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="p">(</span><span class="n">param</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">-</span> <span class="n">param</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span> <span class="o">/</span> <span class="mi">2</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">param</span></div>
|
||||
|
||||
<div class="viewcode-block" id="FuzzySet.get_lower"><a class="viewcode-back" href="../../../../pyFTS.models.nonstationary.html#pyFTS.models.nonstationary.common.FuzzySet.get_lower">[docs]</a> <span class="k">def</span> <span class="nf">get_lower</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">t</span><span class="p">):</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">perturbate_parameters</span><span class="p">(</span><span class="n">t</span><span class="p">)</span>
|
||||
<span class="n">param</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">perturbated_parameters</span><span class="p">[</span><span class="nb">str</span><span class="p">(</span><span class="n">t</span><span class="p">)]</span>
|
||||
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">mf</span> <span class="o">==</span> <span class="n">Membership</span><span class="o">.</span><span class="n">gaussmf</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">param</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">-</span> <span class="mi">3</span><span class="o">*</span><span class="n">param</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
|
||||
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">mf</span> <span class="o">==</span> <span class="n">Membership</span><span class="o">.</span><span class="n">sigmf</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">param</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">-</span> <span class="n">param</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
|
||||
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">mf</span> <span class="o">==</span> <span class="n">Membership</span><span class="o">.</span><span class="n">trimf</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">param</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
|
||||
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">mf</span> <span class="o">==</span> <span class="n">Membership</span><span class="o">.</span><span class="n">trapmf</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">param</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">param</span></div>
|
||||
|
||||
<div class="viewcode-block" id="FuzzySet.get_upper"><a class="viewcode-back" href="../../../../pyFTS.models.nonstationary.html#pyFTS.models.nonstationary.common.FuzzySet.get_upper">[docs]</a> <span class="k">def</span> <span class="nf">get_upper</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">t</span><span class="p">):</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">perturbate_parameters</span><span class="p">(</span><span class="n">t</span><span class="p">)</span>
|
||||
<span class="n">param</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">perturbated_parameters</span><span class="p">[</span><span class="nb">str</span><span class="p">(</span><span class="n">t</span><span class="p">)]</span>
|
||||
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">mf</span> <span class="o">==</span> <span class="n">Membership</span><span class="o">.</span><span class="n">gaussmf</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">param</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">+</span> <span class="mi">3</span><span class="o">*</span><span class="n">param</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
|
||||
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">mf</span> <span class="o">==</span> <span class="n">Membership</span><span class="o">.</span><span class="n">sigmf</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">param</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">+</span> <span class="n">param</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
|
||||
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">mf</span> <span class="o">==</span> <span class="n">Membership</span><span class="o">.</span><span class="n">trimf</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">param</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span>
|
||||
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">mf</span> <span class="o">==</span> <span class="n">Membership</span><span class="o">.</span><span class="n">trapmf</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">param</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">param</span></div>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="s2">""</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">location</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">tmp</span> <span class="o">+=</span> <span class="s2">"Location: "</span>
|
||||
<span class="k">for</span> <span class="n">ct</span><span class="p">,</span> <span class="n">f</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">location</span><span class="p">):</span>
|
||||
<span class="n">tmp</span> <span class="o">+=</span> <span class="nb">str</span><span class="p">(</span><span class="n">f</span><span class="o">.</span><span class="vm">__name__</span><span class="p">)</span> <span class="o">+</span> <span class="s2">"("</span> <span class="o">+</span> <span class="nb">str</span><span class="p">([</span><span class="s2">"</span><span class="si">{0:.2f}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">location_params</span><span class="p">[</span><span class="n">ct</span><span class="p">]])</span> <span class="o">+</span> <span class="s2">") "</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">width</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">tmp</span> <span class="o">+=</span> <span class="s2">"Width: "</span>
|
||||
<span class="k">for</span> <span class="n">ct</span><span class="p">,</span> <span class="n">f</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">width</span><span class="p">):</span>
|
||||
<span class="n">tmp</span> <span class="o">+=</span> <span class="nb">str</span><span class="p">(</span><span class="n">f</span><span class="o">.</span><span class="vm">__name__</span><span class="p">)</span> <span class="o">+</span> <span class="s2">"("</span> <span class="o">+</span> <span class="nb">str</span><span class="p">([</span><span class="s2">"</span><span class="si">{0:.2f}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">width_params</span><span class="p">[</span><span class="n">ct</span><span class="p">]])</span> <span class="o">+</span> <span class="s2">") "</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="s2">"("</span> <span class="o">+</span> <span class="nb">str</span><span class="p">([</span><span class="s2">"</span><span class="si">{0:.2f}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">p</span><span class="p">)</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">parameters</span><span class="p">])</span> <span class="o">+</span> <span class="s2">") "</span> <span class="o">+</span> <span class="n">tmp</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">+</span> <span class="s2">": "</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">mf</span><span class="o">.</span><span class="vm">__name__</span><span class="p">)</span> <span class="o">+</span> <span class="n">tmp</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="fuzzify"><a class="viewcode-back" href="../../../../pyFTS.models.nonstationary.html#pyFTS.models.nonstationary.common.fuzzify">[docs]</a><span class="k">def</span> <span class="nf">fuzzify</span><span class="p">(</span><span class="n">inst</span><span class="p">,</span> <span class="n">t</span><span class="p">,</span> <span class="n">fuzzySets</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Calculate the membership values for a data point given nonstationary fuzzy sets</span>
|
||||
|
||||
<span class="sd"> :param inst: data points</span>
|
||||
<span class="sd"> :param t: time displacement of the instance</span>
|
||||
<span class="sd"> :param fuzzySets: list of fuzzy sets</span>
|
||||
<span class="sd"> :return: array of membership values</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">ret</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">inst</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span>
|
||||
<span class="n">inst</span> <span class="o">=</span> <span class="p">[</span><span class="n">inst</span><span class="p">]</span>
|
||||
<span class="k">for</span> <span class="n">t</span><span class="p">,</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">inst</span><span class="p">):</span>
|
||||
<span class="n">mv</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="n">fs</span><span class="o">.</span><span class="n">membership</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">t</span><span class="p">)</span> <span class="k">for</span> <span class="n">fs</span> <span class="ow">in</span> <span class="n">fuzzySets</span><span class="p">])</span>
|
||||
<span class="n">ret</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">mv</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">ret</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="fuzzySeries"><a class="viewcode-back" href="../../../../pyFTS.models.nonstationary.html#pyFTS.models.nonstationary.common.fuzzySeries">[docs]</a><span class="k">def</span> <span class="nf">fuzzySeries</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">fuzzySets</span><span class="p">,</span> <span class="n">ordered_sets</span><span class="p">,</span> <span class="n">window_size</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span> <span class="n">method</span><span class="o">=</span><span class="s1">'fuzzy'</span><span class="p">,</span> <span class="n">const_t</span><span class="o">=</span> <span class="kc">None</span><span class="p">):</span>
|
||||
<span class="n">fts</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">t</span><span class="p">,</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">data</span><span class="p">):</span>
|
||||
<span class="n">tdisp</span> <span class="o">=</span> <span class="n">window_index</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">window_size</span><span class="p">)</span> <span class="k">if</span> <span class="n">const_t</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="n">const_t</span>
|
||||
<span class="n">mv</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="n">fuzzySets</span><span class="p">[</span><span class="n">fs</span><span class="p">]</span><span class="o">.</span><span class="n">membership</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">tdisp</span><span class="p">)</span> <span class="k">for</span> <span class="n">fs</span> <span class="ow">in</span> <span class="n">ordered_sets</span><span class="p">])</span>
|
||||
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">mv</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
|
||||
<span class="n">sets</span> <span class="o">=</span> <span class="p">[</span><span class="n">check_bounds</span><span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">fuzzySets</span><span class="p">,</span> <span class="n">tdisp</span><span class="p">)]</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="n">method</span> <span class="o">==</span> <span class="s1">'fuzzy'</span><span class="p">:</span>
|
||||
<span class="n">ix</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">ravel</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">argwhere</span><span class="p">(</span><span class="n">mv</span> <span class="o">></span> <span class="mf">0.0</span><span class="p">))</span>
|
||||
<span class="k">elif</span> <span class="n">method</span> <span class="o">==</span> <span class="s1">'maximum'</span><span class="p">:</span>
|
||||
<span class="n">mx</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="n">mv</span><span class="p">)</span>
|
||||
<span class="n">ix</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">ravel</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">argwhere</span><span class="p">(</span><span class="n">mv</span> <span class="o">==</span> <span class="n">mx</span><span class="p">))</span>
|
||||
<span class="n">sets</span> <span class="o">=</span> <span class="p">[</span><span class="n">fuzzySets</span><span class="p">[</span><span class="n">ordered_sets</span><span class="p">[</span><span class="n">i</span><span class="p">]]</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">ix</span><span class="p">]</span>
|
||||
<span class="n">fts</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">sets</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">fts</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="window_index"><a class="viewcode-back" href="../../../../pyFTS.models.nonstationary.html#pyFTS.models.nonstationary.common.window_index">[docs]</a><span class="k">def</span> <span class="nf">window_index</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">window_size</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="p">(</span><span class="nb">list</span><span class="p">,</span> <span class="nb">set</span><span class="p">)):</span>
|
||||
<span class="k">return</span> <span class="n">t</span>
|
||||
<span class="k">return</span> <span class="n">t</span> <span class="o">-</span> <span class="p">(</span><span class="n">t</span> <span class="o">%</span> <span class="n">window_size</span><span class="p">)</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="check_bounds"><a class="viewcode-back" href="../../../../pyFTS.models.nonstationary.html#pyFTS.models.nonstationary.common.check_bounds">[docs]</a><span class="k">def</span> <span class="nf">check_bounds</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">partitioner</span><span class="p">,</span> <span class="n">t</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="n">data</span> <span class="o"><</span> <span class="n">partitioner</span><span class="o">.</span><span class="n">lower_set</span><span class="p">()</span><span class="o">.</span><span class="n">get_lower</span><span class="p">(</span><span class="n">t</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="n">partitioner</span><span class="o">.</span><span class="n">lower_set</span><span class="p">()</span>
|
||||
<span class="k">elif</span> <span class="n">data</span> <span class="o">></span> <span class="n">partitioner</span><span class="o">.</span><span class="n">upper_set</span><span class="p">()</span><span class="o">.</span><span class="n">get_upper</span><span class="p">(</span><span class="n">t</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="n">partitioner</span><span class="o">.</span><span class="n">upper_set</span><span class="p">()</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="check_bounds_index"><a class="viewcode-back" href="../../../../pyFTS.models.nonstationary.html#pyFTS.models.nonstationary.common.check_bounds_index">[docs]</a><span class="k">def</span> <span class="nf">check_bounds_index</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">partitioner</span><span class="p">,</span> <span class="n">t</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="n">data</span> <span class="o"><</span> <span class="n">partitioner</span><span class="o">.</span><span class="n">lower_set</span><span class="p">()</span><span class="o">.</span><span class="n">get_lower</span><span class="p">(</span><span class="n">t</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="mi">0</span>
|
||||
<span class="k">elif</span> <span class="n">data</span> <span class="o">></span> <span class="n">partitioner</span><span class="o">.</span><span class="n">upper_set</span><span class="p">()</span><span class="o">.</span><span class="n">get_upper</span><span class="p">(</span><span class="n">t</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="nb">len</span><span class="p">(</span><span class="n">partitioner</span><span class="o">.</span><span class="n">sets</span><span class="p">)</span> <span class="o">-</span><span class="mi">1</span></div>
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../../index.html">
|
||||
<img class="logo" src="../../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.models.nonstationary.common</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,163 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.models.nonstationary.flrg — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../../" id="documentation_options" src="../../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../../_static/jquery.js"></script>
|
||||
<script src="../../../../_static/underscore.js"></script>
|
||||
<script src="../../../../_static/doctools.js"></script>
|
||||
<script src="../../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.models.nonstationary.flrg</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.models.nonstationary.flrg</h1><div class="highlight"><pre>
|
||||
<span></span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.common</span> <span class="kn">import</span> <span class="n">flrg</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.models.nonstationary</span> <span class="kn">import</span> <span class="n">common</span>
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="NonStationaryFLRG"><a class="viewcode-back" href="../../../../pyFTS.models.nonstationary.html#pyFTS.models.nonstationary.flrg.NonStationaryFLRG">[docs]</a><span class="k">class</span> <span class="nc">NonStationaryFLRG</span><span class="p">(</span><span class="n">flrg</span><span class="o">.</span><span class="n">FLRG</span><span class="p">):</span>
|
||||
<div class="viewcode-block" id="NonStationaryFLRG.unpack_args"><a class="viewcode-back" href="../../../../pyFTS.models.nonstationary.html#pyFTS.models.nonstationary.flrg.NonStationaryFLRG.unpack_args">[docs]</a> <span class="k">def</span> <span class="nf">unpack_args</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">):</span>
|
||||
<span class="n">l</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">args</span><span class="p">)</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">args</span>
|
||||
<span class="n">sets</span><span class="p">,</span> <span class="n">t</span><span class="p">,</span> <span class="n">w</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span>
|
||||
<span class="k">if</span> <span class="n">l</span> <span class="o">></span> <span class="mi">0</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">tmp</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="nb">dict</span><span class="p">):</span>
|
||||
<span class="n">sets</span> <span class="o">=</span> <span class="n">tmp</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
|
||||
<span class="k">if</span> <span class="n">l</span> <span class="o">></span> <span class="mi">1</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">tmp</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="p">(</span><span class="nb">int</span><span class="p">,</span> <span class="nb">list</span><span class="p">,</span> <span class="nb">tuple</span><span class="p">)):</span>
|
||||
<span class="n">t</span> <span class="o">=</span> <span class="n">tmp</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
|
||||
<span class="k">if</span> <span class="n">l</span> <span class="o">></span> <span class="mi">2</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">tmp</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span> <span class="nb">int</span><span class="p">):</span>
|
||||
<span class="n">w</span> <span class="o">=</span> <span class="n">tmp</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span>
|
||||
|
||||
<span class="k">return</span> <span class="p">(</span><span class="n">sets</span><span class="p">,</span> <span class="n">t</span><span class="p">,</span> <span class="n">w</span><span class="p">)</span></div>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">LHS</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">NonStationaryFLRG</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">LHS</span> <span class="o">=</span> <span class="n">LHS</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">RHS</span> <span class="o">=</span> <span class="nb">set</span><span class="p">()</span>
|
||||
|
||||
<div class="viewcode-block" id="NonStationaryFLRG.get_key"><a class="viewcode-back" href="../../../../pyFTS.models.nonstationary.html#pyFTS.models.nonstationary.flrg.NonStationaryFLRG.get_key">[docs]</a> <span class="k">def</span> <span class="nf">get_key</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">LHS</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="nb">str</span><span class="p">([</span><span class="n">k</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">LHS</span><span class="p">])</span>
|
||||
<span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">LHS</span><span class="p">,</span> <span class="nb">dict</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">LHS</span><span class="o">.</span><span class="n">keys</span><span class="p">())</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">LHS</span></div>
|
||||
|
||||
<div class="viewcode-block" id="NonStationaryFLRG.get_membership"><a class="viewcode-back" href="../../../../pyFTS.models.nonstationary.html#pyFTS.models.nonstationary.flrg.NonStationaryFLRG.get_membership">[docs]</a> <span class="k">def</span> <span class="nf">get_membership</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">):</span>
|
||||
<span class="n">sets</span><span class="p">,</span> <span class="n">t</span><span class="p">,</span> <span class="n">window_size</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">unpack_args</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">)</span>
|
||||
<span class="n">ret</span> <span class="o">=</span> <span class="mf">0.0</span>
|
||||
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">LHS</span><span class="p">,</span> <span class="p">(</span><span class="nb">list</span><span class="p">,</span> <span class="nb">set</span><span class="p">)):</span>
|
||||
<span class="n">ret</span> <span class="o">=</span> <span class="nb">min</span><span class="p">([</span><span class="n">sets</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">LHS</span><span class="p">[</span><span class="n">ct</span><span class="p">]]</span><span class="o">.</span><span class="n">membership</span><span class="p">(</span><span class="n">dat</span><span class="p">,</span> <span class="n">common</span><span class="o">.</span><span class="n">window_index</span><span class="p">(</span><span class="n">t</span> <span class="o">-</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">order</span> <span class="o">-</span> <span class="n">ct</span><span class="p">),</span> <span class="n">window_size</span><span class="p">))</span>
|
||||
<span class="k">for</span> <span class="n">ct</span><span class="p">,</span> <span class="n">dat</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">data</span><span class="p">)])</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">ret</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">LHS</span><span class="o">.</span><span class="n">membership</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">common</span><span class="o">.</span><span class="n">window_index</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">window_size</span><span class="p">))</span>
|
||||
<span class="k">return</span> <span class="n">ret</span></div>
|
||||
|
||||
<div class="viewcode-block" id="NonStationaryFLRG.get_midpoint"><a class="viewcode-back" href="../../../../pyFTS.models.nonstationary.html#pyFTS.models.nonstationary.flrg.NonStationaryFLRG.get_midpoint">[docs]</a> <span class="k">def</span> <span class="nf">get_midpoint</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">):</span>
|
||||
<span class="n">sets</span><span class="p">,</span> <span class="n">t</span><span class="p">,</span> <span class="n">window_size</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">unpack_args</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="p">)</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="p">,</span> <span class="p">(</span><span class="nb">list</span><span class="p">,</span> <span class="nb">set</span><span class="p">)):</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="p">[</span><span class="n">sets</span><span class="p">[</span><span class="n">r</span><span class="p">]</span><span class="o">.</span><span class="n">get_midpoint</span><span class="p">(</span><span class="n">common</span><span class="o">.</span><span class="n">window_index</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">window_size</span><span class="p">))</span> <span class="k">for</span> <span class="n">r</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="p">]</span>
|
||||
<span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="p">,</span> <span class="nb">dict</span><span class="p">):</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="p">[</span><span class="n">sets</span><span class="p">[</span><span class="n">r</span><span class="p">]</span><span class="o">.</span><span class="n">get_midpoint</span><span class="p">(</span><span class="n">common</span><span class="o">.</span><span class="n">window_index</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">window_size</span><span class="p">))</span> <span class="k">for</span> <span class="n">r</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="o">.</span><span class="n">keys</span><span class="p">()]</span>
|
||||
<span class="k">return</span> <span class="nb">sum</span><span class="p">(</span><span class="n">tmp</span><span class="p">)</span> <span class="o">/</span> <span class="nb">len</span><span class="p">(</span><span class="n">tmp</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">sets</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">LHS</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]]</span><span class="o">.</span><span class="n">get_midpoint</span><span class="p">(</span><span class="n">common</span><span class="o">.</span><span class="n">window_index</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">window_size</span><span class="p">))</span></div>
|
||||
|
||||
<div class="viewcode-block" id="NonStationaryFLRG.get_lower"><a class="viewcode-back" href="../../../../pyFTS.models.nonstationary.html#pyFTS.models.nonstationary.flrg.NonStationaryFLRG.get_lower">[docs]</a> <span class="k">def</span> <span class="nf">get_lower</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">):</span>
|
||||
<span class="n">sets</span><span class="p">,</span> <span class="n">t</span><span class="p">,</span> <span class="n">window_size</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">unpack_args</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="p">)</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="p">,</span> <span class="p">(</span><span class="nb">list</span><span class="p">,</span> <span class="nb">set</span><span class="p">)):</span>
|
||||
<span class="k">return</span> <span class="nb">min</span><span class="p">([</span><span class="n">sets</span><span class="p">[</span><span class="n">r</span><span class="p">]</span><span class="o">.</span><span class="n">get_lower</span><span class="p">(</span><span class="n">common</span><span class="o">.</span><span class="n">window_index</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">window_size</span><span class="p">))</span> <span class="k">for</span> <span class="n">r</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="p">])</span>
|
||||
<span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="p">,</span> <span class="nb">dict</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="nb">min</span><span class="p">([</span><span class="n">sets</span><span class="p">[</span><span class="n">r</span><span class="p">]</span><span class="o">.</span><span class="n">get_lower</span><span class="p">(</span><span class="n">common</span><span class="o">.</span><span class="n">window_index</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">window_size</span><span class="p">))</span> <span class="k">for</span> <span class="n">r</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="o">.</span><span class="n">keys</span><span class="p">()])</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">sets</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">LHS</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]]</span><span class="o">.</span><span class="n">get_lower</span><span class="p">(</span><span class="n">common</span><span class="o">.</span><span class="n">window_index</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">window_size</span><span class="p">))</span></div>
|
||||
|
||||
<div class="viewcode-block" id="NonStationaryFLRG.get_upper"><a class="viewcode-back" href="../../../../pyFTS.models.nonstationary.html#pyFTS.models.nonstationary.flrg.NonStationaryFLRG.get_upper">[docs]</a> <span class="k">def</span> <span class="nf">get_upper</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">):</span>
|
||||
<span class="n">sets</span><span class="p">,</span> <span class="n">t</span><span class="p">,</span> <span class="n">window_size</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">unpack_args</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="p">)</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="p">,</span> <span class="p">(</span><span class="nb">list</span><span class="p">,</span> <span class="nb">set</span><span class="p">)):</span>
|
||||
<span class="k">return</span> <span class="nb">max</span><span class="p">([</span><span class="n">sets</span><span class="p">[</span><span class="n">r</span><span class="p">]</span><span class="o">.</span><span class="n">get_upper</span><span class="p">(</span><span class="n">common</span><span class="o">.</span><span class="n">window_index</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">window_size</span><span class="p">))</span> <span class="k">for</span> <span class="n">r</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="p">])</span>
|
||||
<span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="p">,</span> <span class="nb">dict</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="nb">max</span><span class="p">([</span><span class="n">sets</span><span class="p">[</span><span class="n">r</span><span class="p">]</span><span class="o">.</span><span class="n">get_upper</span><span class="p">(</span><span class="n">common</span><span class="o">.</span><span class="n">window_index</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">window_size</span><span class="p">))</span> <span class="k">for</span> <span class="n">r</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">RHS</span><span class="o">.</span><span class="n">keys</span><span class="p">()])</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">sets</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">LHS</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]]</span><span class="o">.</span><span class="n">get_upper</span><span class="p">(</span><span class="n">common</span><span class="o">.</span><span class="n">window_index</span><span class="p">(</span><span class="n">t</span><span class="p">,</span> <span class="n">window_size</span><span class="p">))</span></div></div>
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../../index.html">
|
||||
<img class="logo" src="../../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.models.nonstationary.flrg</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,240 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.models.nonstationary.partitioners — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../../" id="documentation_options" src="../../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../../_static/jquery.js"></script>
|
||||
<script src="../../../../_static/underscore.js"></script>
|
||||
<script src="../../../../_static/doctools.js"></script>
|
||||
<script src="../../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.models.nonstationary.partitioners</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.models.nonstationary.partitioners</h1><div class="highlight"><pre>
|
||||
<span></span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.partitioners</span> <span class="kn">import</span> <span class="n">partitioner</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.models.nonstationary</span> <span class="kn">import</span> <span class="n">common</span><span class="p">,</span> <span class="n">perturbation</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.common</span> <span class="kn">import</span> <span class="n">FuzzySet</span> <span class="k">as</span> <span class="n">stationary_fs</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="PolynomialNonStationaryPartitioner"><a class="viewcode-back" href="../../../../pyFTS.models.nonstationary.html#pyFTS.models.nonstationary.partitioners.PolynomialNonStationaryPartitioner">[docs]</a><span class="k">class</span> <span class="nc">PolynomialNonStationaryPartitioner</span><span class="p">(</span><span class="n">partitioner</span><span class="o">.</span><span class="n">Partitioner</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Non Stationary Universe of Discourse Partitioner</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">part</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">""""""</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">PolynomialNonStationaryPartitioner</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="n">part</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="n">data</span><span class="p">,</span> <span class="n">npart</span><span class="o">=</span><span class="n">part</span><span class="o">.</span><span class="n">partitions</span><span class="p">,</span>
|
||||
<span class="n">func</span><span class="o">=</span><span class="n">part</span><span class="o">.</span><span class="n">membership_function</span><span class="p">,</span> <span class="n">names</span><span class="o">=</span><span class="n">part</span><span class="o">.</span><span class="n">setnames</span><span class="p">,</span>
|
||||
<span class="n">prefix</span><span class="o">=</span><span class="n">part</span><span class="o">.</span><span class="n">prefix</span><span class="p">,</span> <span class="n">transformation</span><span class="o">=</span><span class="n">part</span><span class="o">.</span><span class="n">transformation</span><span class="p">,</span>
|
||||
<span class="n">indexer</span><span class="o">=</span><span class="n">part</span><span class="o">.</span><span class="n">indexer</span><span class="p">,</span> <span class="n">preprocess</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">sets</span> <span class="o">=</span> <span class="p">{}</span>
|
||||
|
||||
<span class="n">loc_params</span><span class="p">,</span> <span class="n">wid_params</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_polynomial_perturbations</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">ordered_sets</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">setnames</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">ordered_sets</span> <span class="o">=</span> <span class="n">part</span><span class="o">.</span><span class="n">setnames</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">ordered_sets</span> <span class="o">=</span> <span class="n">stationary_fs</span><span class="o">.</span><span class="n">set_ordered</span><span class="p">(</span><span class="n">part</span><span class="o">.</span><span class="n">sets</span><span class="p">)</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">ct</span><span class="p">,</span> <span class="n">key</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">ordered_sets</span><span class="p">):</span>
|
||||
<span class="nb">set</span> <span class="o">=</span> <span class="n">part</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="n">key</span><span class="p">]</span>
|
||||
<span class="n">loc_roots</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">roots</span><span class="p">(</span><span class="n">loc_params</span><span class="p">[</span><span class="n">ct</span><span class="p">])[</span><span class="mi">0</span><span class="p">]</span>
|
||||
<span class="n">wid_roots</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">roots</span><span class="p">(</span><span class="n">wid_params</span><span class="p">[</span><span class="n">ct</span><span class="p">])[</span><span class="mi">0</span><span class="p">]</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">common</span><span class="o">.</span><span class="n">FuzzySet</span><span class="p">(</span><span class="nb">set</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="nb">set</span><span class="o">.</span><span class="n">mf</span><span class="p">,</span> <span class="nb">set</span><span class="o">.</span><span class="n">parameters</span><span class="p">,</span>
|
||||
<span class="n">location</span><span class="o">=</span><span class="n">perturbation</span><span class="o">.</span><span class="n">polynomial</span><span class="p">,</span>
|
||||
<span class="n">location_params</span><span class="o">=</span><span class="n">loc_params</span><span class="p">[</span><span class="n">ct</span><span class="p">],</span>
|
||||
<span class="n">location_roots</span><span class="o">=</span><span class="n">loc_roots</span><span class="p">,</span> <span class="c1">#**kwargs)</span>
|
||||
<span class="n">width</span><span class="o">=</span><span class="n">perturbation</span><span class="o">.</span><span class="n">polynomial</span><span class="p">,</span>
|
||||
<span class="n">width_params</span><span class="o">=</span><span class="n">wid_params</span><span class="p">[</span><span class="n">ct</span><span class="p">],</span>
|
||||
<span class="n">width_roots</span><span class="o">=</span><span class="n">wid_roots</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="nb">set</span><span class="o">.</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="n">tmp</span>
|
||||
|
||||
<div class="viewcode-block" id="PolynomialNonStationaryPartitioner.poly_width"><a class="viewcode-back" href="../../../../pyFTS.models.nonstationary.html#pyFTS.models.nonstationary.partitioners.PolynomialNonStationaryPartitioner.poly_width">[docs]</a> <span class="k">def</span> <span class="nf">poly_width</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">par1</span><span class="p">,</span> <span class="n">par2</span><span class="p">,</span> <span class="n">rng</span><span class="p">,</span> <span class="n">deg</span><span class="p">):</span>
|
||||
<span class="n">a</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">polyval</span><span class="p">(</span><span class="n">par1</span><span class="p">,</span> <span class="n">rng</span><span class="p">)</span>
|
||||
<span class="n">b</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">polyval</span><span class="p">(</span><span class="n">par2</span><span class="p">,</span> <span class="n">rng</span><span class="p">)</span>
|
||||
<span class="n">diff</span> <span class="o">=</span> <span class="p">[</span><span class="n">b</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">-</span> <span class="n">a</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">rng</span><span class="p">]</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">polyfit</span><span class="p">(</span><span class="n">rng</span><span class="p">,</span> <span class="n">diff</span><span class="p">,</span> <span class="n">deg</span><span class="o">=</span><span class="n">deg</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">tmp</span></div>
|
||||
|
||||
<div class="viewcode-block" id="PolynomialNonStationaryPartitioner.scale_up"><a class="viewcode-back" href="../../../../pyFTS.models.nonstationary.html#pyFTS.models.nonstationary.partitioners.PolynomialNonStationaryPartitioner.scale_up">[docs]</a> <span class="k">def</span> <span class="nf">scale_up</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">x</span><span class="p">,</span><span class="n">pct</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="n">x</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> <span class="k">return</span> <span class="n">x</span><span class="o">*</span><span class="p">(</span><span class="mi">1</span><span class="o">+</span><span class="n">pct</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span> <span class="k">return</span> <span class="n">x</span><span class="o">*</span><span class="n">pct</span></div>
|
||||
|
||||
<div class="viewcode-block" id="PolynomialNonStationaryPartitioner.scale_down"><a class="viewcode-back" href="../../../../pyFTS.models.nonstationary.html#pyFTS.models.nonstationary.partitioners.PolynomialNonStationaryPartitioner.scale_down">[docs]</a> <span class="k">def</span> <span class="nf">scale_down</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">x</span><span class="p">,</span><span class="n">pct</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="n">x</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span> <span class="k">return</span> <span class="n">x</span><span class="o">*</span><span class="n">pct</span>
|
||||
<span class="k">else</span><span class="p">:</span> <span class="k">return</span> <span class="n">x</span><span class="o">*</span><span class="p">(</span><span class="mi">1</span><span class="o">+</span><span class="n">pct</span><span class="p">)</span></div>
|
||||
|
||||
<div class="viewcode-block" id="PolynomialNonStationaryPartitioner.get_polynomial_perturbations"><a class="viewcode-back" href="../../../../pyFTS.models.nonstationary.html#pyFTS.models.nonstationary.partitioners.PolynomialNonStationaryPartitioner.get_polynomial_perturbations">[docs]</a> <span class="k">def</span> <span class="nf">get_polynomial_perturbations</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="n">w</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"window_size"</span><span class="p">,</span> <span class="nb">int</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">)</span> <span class="o">/</span> <span class="mi">5</span><span class="p">))</span>
|
||||
<span class="n">degree</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"degree"</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
|
||||
<span class="n">xmax</span> <span class="o">=</span> <span class="p">[</span><span class="n">data</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span>
|
||||
<span class="n">tmax</span> <span class="o">=</span> <span class="p">[</span><span class="mi">0</span><span class="p">]</span>
|
||||
<span class="n">xmin</span> <span class="o">=</span> <span class="p">[</span><span class="n">data</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span>
|
||||
<span class="n">tmin</span> <span class="o">=</span> <span class="p">[</span><span class="mi">0</span><span class="p">]</span>
|
||||
|
||||
<span class="n">l</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">l</span><span class="p">,</span> <span class="n">w</span><span class="p">):</span>
|
||||
<span class="n">sample</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="n">i</span><span class="p">:</span><span class="n">i</span> <span class="o">+</span> <span class="n">w</span><span class="p">]</span>
|
||||
<span class="n">tx</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="n">sample</span><span class="p">)</span>
|
||||
<span class="n">xmax</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">tx</span><span class="p">)</span>
|
||||
<span class="n">tmax</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">ravel</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">argwhere</span><span class="p">(</span><span class="n">data</span> <span class="o">==</span> <span class="n">tx</span><span class="p">))</span><span class="o">.</span><span class="n">tolist</span><span class="p">()[</span><span class="mi">0</span><span class="p">])</span>
|
||||
<span class="n">tn</span> <span class="o">=</span> <span class="nb">min</span><span class="p">(</span><span class="n">sample</span><span class="p">)</span>
|
||||
<span class="n">xmin</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">tn</span><span class="p">)</span>
|
||||
<span class="n">tmin</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">ravel</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">argwhere</span><span class="p">(</span><span class="n">data</span> <span class="o">==</span> <span class="n">tn</span><span class="p">))</span><span class="o">.</span><span class="n">tolist</span><span class="p">()[</span><span class="mi">0</span><span class="p">])</span>
|
||||
|
||||
<span class="n">cmax</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">polyfit</span><span class="p">(</span><span class="n">tmax</span><span class="p">,</span> <span class="n">xmax</span><span class="p">,</span> <span class="n">deg</span><span class="o">=</span><span class="n">degree</span><span class="p">)</span>
|
||||
<span class="n">cmin</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">polyfit</span><span class="p">(</span><span class="n">tmin</span><span class="p">,</span> <span class="n">xmin</span><span class="p">,</span> <span class="n">deg</span><span class="o">=</span><span class="n">degree</span><span class="p">)</span>
|
||||
|
||||
<span class="n">cmed</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">d</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">degree</span> <span class="o">+</span> <span class="mi">1</span><span class="p">):</span>
|
||||
<span class="n">cmed</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">linspace</span><span class="p">(</span><span class="n">cmin</span><span class="p">[</span><span class="n">d</span><span class="p">],</span> <span class="n">cmax</span><span class="p">[</span><span class="n">d</span><span class="p">],</span> <span class="bp">self</span><span class="o">.</span><span class="n">partitions</span><span class="p">)[</span><span class="mi">1</span><span class="p">:</span><span class="bp">self</span><span class="o">.</span><span class="n">partitions</span> <span class="o">-</span> <span class="mi">1</span><span class="p">])</span>
|
||||
|
||||
<span class="n">loc_params</span> <span class="o">=</span> <span class="p">[</span><span class="n">cmin</span><span class="o">.</span><span class="n">tolist</span><span class="p">()]</span>
|
||||
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">partitions</span> <span class="o">-</span> <span class="mi">2</span><span class="p">):</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="p">[</span><span class="n">cmed</span><span class="p">[</span><span class="n">k</span><span class="p">][</span><span class="n">i</span><span class="p">]</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">degree</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)]</span>
|
||||
<span class="n">loc_params</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">tmp</span><span class="p">)</span>
|
||||
<span class="n">loc_params</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">cmax</span><span class="o">.</span><span class="n">tolist</span><span class="p">())</span>
|
||||
|
||||
<span class="n">rng</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">l</span><span class="p">)</span>
|
||||
|
||||
<span class="n">clen</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">partitions</span><span class="o">-</span><span class="mi">1</span><span class="p">):</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">poly_width</span><span class="p">(</span><span class="n">loc_params</span><span class="p">[</span><span class="n">i</span> <span class="o">-</span> <span class="mi">1</span><span class="p">],</span> <span class="n">loc_params</span><span class="p">[</span><span class="n">i</span> <span class="o">+</span> <span class="mi">1</span><span class="p">],</span> <span class="n">rng</span><span class="p">,</span> <span class="n">degree</span><span class="p">)</span>
|
||||
<span class="n">clen</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">tmp</span><span class="p">)</span>
|
||||
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">poly_width</span><span class="p">(</span><span class="n">loc_params</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">loc_params</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">rng</span><span class="p">,</span> <span class="n">degree</span><span class="p">)</span>
|
||||
<span class="n">clen</span><span class="o">.</span><span class="n">insert</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">tmp</span><span class="p">)</span>
|
||||
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">poly_width</span><span class="p">(</span><span class="n">loc_params</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">partitions</span><span class="o">-</span><span class="mi">2</span><span class="p">],</span> <span class="n">loc_params</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">partitions</span><span class="o">-</span><span class="mi">1</span><span class="p">],</span> <span class="n">rng</span><span class="p">,</span> <span class="n">degree</span><span class="p">)</span>
|
||||
<span class="n">clen</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">tmp</span><span class="p">)</span>
|
||||
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="p">(</span><span class="n">loc_params</span><span class="p">,</span> <span class="n">clen</span><span class="p">)</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">tmp</span></div>
|
||||
|
||||
<div class="viewcode-block" id="PolynomialNonStationaryPartitioner.build"><a class="viewcode-back" href="../../../../pyFTS.models.nonstationary.html#pyFTS.models.nonstationary.partitioners.PolynomialNonStationaryPartitioner.build">[docs]</a> <span class="k">def</span> <span class="nf">build</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
|
||||
<span class="k">pass</span></div></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="SimpleNonStationaryPartitioner"><a class="viewcode-back" href="../../../../pyFTS.models.nonstationary.html#pyFTS.models.nonstationary.partitioners.SimpleNonStationaryPartitioner">[docs]</a><span class="k">class</span> <span class="nc">SimpleNonStationaryPartitioner</span><span class="p">(</span><span class="n">partitioner</span><span class="o">.</span><span class="n">Partitioner</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Non Stationary Universe of Discourse Partitioner</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">part</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">""""""</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">SimpleNonStationaryPartitioner</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="n">part</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="n">data</span><span class="p">,</span> <span class="n">npart</span><span class="o">=</span><span class="n">part</span><span class="o">.</span><span class="n">partitions</span><span class="p">,</span>
|
||||
<span class="n">func</span><span class="o">=</span><span class="n">part</span><span class="o">.</span><span class="n">membership_function</span><span class="p">,</span> <span class="n">names</span><span class="o">=</span><span class="n">part</span><span class="o">.</span><span class="n">setnames</span><span class="p">,</span>
|
||||
<span class="n">prefix</span><span class="o">=</span><span class="n">part</span><span class="o">.</span><span class="n">prefix</span><span class="p">,</span> <span class="n">transformation</span><span class="o">=</span><span class="n">part</span><span class="o">.</span><span class="n">transformation</span><span class="p">,</span>
|
||||
<span class="n">indexer</span><span class="o">=</span><span class="n">part</span><span class="o">.</span><span class="n">indexer</span><span class="p">)</span><span class="c1">#, preprocess=False)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">partitions</span> <span class="o">=</span> <span class="n">part</span><span class="o">.</span><span class="n">partitions</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="n">part</span><span class="o">.</span><span class="n">sets</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
|
||||
<span class="nb">set</span> <span class="o">=</span> <span class="n">part</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="n">key</span><span class="p">]</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">common</span><span class="o">.</span><span class="n">FuzzySet</span><span class="p">(</span><span class="nb">set</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="nb">set</span><span class="o">.</span><span class="n">mf</span><span class="p">,</span> <span class="nb">set</span><span class="o">.</span><span class="n">parameters</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
<span class="n">tmp</span><span class="o">.</span><span class="n">centroid</span> <span class="o">=</span> <span class="nb">set</span><span class="o">.</span><span class="n">centroid</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span><span class="n">tmp</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">ordered_sets</span> <span class="o">=</span> <span class="n">stationary_fs</span><span class="o">.</span><span class="n">set_ordered</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">)</span>
|
||||
|
||||
<div class="viewcode-block" id="SimpleNonStationaryPartitioner.build"><a class="viewcode-back" href="../../../../pyFTS.models.nonstationary.html#pyFTS.models.nonstationary.partitioners.SimpleNonStationaryPartitioner.build">[docs]</a> <span class="k">def</span> <span class="nf">build</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="p">{}</span></div></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="simplenonstationary_gridpartitioner_builder"><a class="viewcode-back" href="../../../../pyFTS.models.nonstationary.html#pyFTS.models.nonstationary.partitioners.simplenonstationary_gridpartitioner_builder">[docs]</a><span class="k">def</span> <span class="nf">simplenonstationary_gridpartitioner_builder</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">npart</span><span class="p">,</span> <span class="n">transformation</span><span class="p">):</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.partitioners</span> <span class="kn">import</span> <span class="n">Grid</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.models.nonstationary</span> <span class="kn">import</span> <span class="n">perturbation</span><span class="p">,</span> <span class="n">partitioners</span>
|
||||
|
||||
<span class="n">tmp_fs</span> <span class="o">=</span> <span class="n">Grid</span><span class="o">.</span><span class="n">GridPartitioner</span><span class="p">(</span><span class="n">data</span><span class="o">=</span><span class="n">data</span><span class="p">,</span> <span class="n">npart</span><span class="o">=</span><span class="n">npart</span><span class="p">,</span> <span class="n">transformation</span><span class="o">=</span><span class="n">transformation</span><span class="p">)</span>
|
||||
<span class="n">fs</span> <span class="o">=</span> <span class="n">partitioners</span><span class="o">.</span><span class="n">SimpleNonStationaryPartitioner</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">tmp_fs</span><span class="p">,</span>
|
||||
<span class="n">location</span><span class="o">=</span><span class="n">perturbation</span><span class="o">.</span><span class="n">polynomial</span><span class="p">,</span>
|
||||
<span class="n">location_params</span><span class="o">=</span><span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">],</span>
|
||||
<span class="n">location_roots</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span>
|
||||
<span class="n">width</span><span class="o">=</span><span class="n">perturbation</span><span class="o">.</span><span class="n">polynomial</span><span class="p">,</span>
|
||||
<span class="n">width_params</span><span class="o">=</span><span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">],</span>
|
||||
<span class="n">width_roots</span><span class="o">=</span><span class="mi">0</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">fs</span></div>
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../../index.html">
|
||||
<img class="logo" src="../../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.models.nonstationary.partitioners</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,113 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.models.nonstationary.perturbation — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../../" id="documentation_options" src="../../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../../_static/jquery.js"></script>
|
||||
<script src="../../../../_static/underscore.js"></script>
|
||||
<script src="../../../../_static/doctools.js"></script>
|
||||
<script src="../../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.models.nonstationary.perturbation</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.models.nonstationary.perturbation</h1><div class="highlight"><pre>
|
||||
<span></span><span class="sd">"""</span>
|
||||
<span class="sd">Pertubation functions for Non Stationary Fuzzy Sets</span>
|
||||
<span class="sd">"""</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS</span> <span class="kn">import</span> <span class="o">*</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.common</span> <span class="kn">import</span> <span class="n">FuzzySet</span><span class="p">,</span> <span class="n">Membership</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="linear"><a class="viewcode-back" href="../../../../pyFTS.models.nonstationary.html#pyFTS.models.nonstationary.perturbation.linear">[docs]</a><span class="k">def</span> <span class="nf">linear</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">parameters</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">polyval</span><span class="p">(</span><span class="n">parameters</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="polynomial"><a class="viewcode-back" href="../../../../pyFTS.models.nonstationary.html#pyFTS.models.nonstationary.perturbation.polynomial">[docs]</a><span class="k">def</span> <span class="nf">polynomial</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">parameters</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">polyval</span><span class="p">(</span><span class="n">parameters</span><span class="p">,</span> <span class="n">x</span><span class="p">)</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="exponential"><a class="viewcode-back" href="../../../../pyFTS.models.nonstationary.html#pyFTS.models.nonstationary.perturbation.exponential">[docs]</a><span class="k">def</span> <span class="nf">exponential</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">parameters</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">exp</span><span class="p">(</span><span class="n">x</span><span class="o">*</span><span class="n">parameters</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="periodic"><a class="viewcode-back" href="../../../../pyFTS.models.nonstationary.html#pyFTS.models.nonstationary.perturbation.periodic">[docs]</a><span class="k">def</span> <span class="nf">periodic</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">parameters</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="n">parameters</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">*</span> <span class="n">np</span><span class="o">.</span><span class="n">sin</span><span class="p">(</span><span class="n">x</span> <span class="o">*</span> <span class="n">parameters</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span></div>
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../../index.html">
|
||||
<img class="logo" src="../../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.models.nonstationary.perturbation</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,292 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.models.seasonal.SeasonalIndexer — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../../" id="documentation_options" src="../../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../../_static/jquery.js"></script>
|
||||
<script src="../../../../_static/underscore.js"></script>
|
||||
<script src="../../../../_static/doctools.js"></script>
|
||||
<script src="../../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.models.seasonal.SeasonalIndexer</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.models.seasonal.SeasonalIndexer</h1><div class="highlight"><pre>
|
||||
<span></span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
<span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.models.seasonal</span> <span class="kn">import</span> <span class="n">common</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="SeasonalIndexer"><a class="viewcode-back" href="../../../../pyFTS.models.seasonal.html#pyFTS.models.seasonal.SeasonalIndexer.SeasonalIndexer">[docs]</a><span class="k">class</span> <span class="nc">SeasonalIndexer</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Seasonal Indexer. Responsible to find the seasonal index of a data point inside its data set</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">num_seasons</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">num_seasons</span> <span class="o">=</span> <span class="n">num_seasons</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"name"</span><span class="p">,</span><span class="s2">""</span><span class="p">)</span>
|
||||
|
||||
<div class="viewcode-block" id="SeasonalIndexer.get_season_of_data"><a class="viewcode-back" href="../../../../pyFTS.models.seasonal.html#pyFTS.models.seasonal.SeasonalIndexer.SeasonalIndexer.get_season_of_data">[docs]</a> <span class="k">def</span> <span class="nf">get_season_of_data</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">data</span><span class="p">):</span>
|
||||
<span class="k">pass</span></div>
|
||||
|
||||
<div class="viewcode-block" id="SeasonalIndexer.get_season_by_index"><a class="viewcode-back" href="../../../../pyFTS.models.seasonal.html#pyFTS.models.seasonal.SeasonalIndexer.SeasonalIndexer.get_season_by_index">[docs]</a> <span class="k">def</span> <span class="nf">get_season_by_index</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">inde</span><span class="p">):</span>
|
||||
<span class="k">pass</span></div>
|
||||
|
||||
<div class="viewcode-block" id="SeasonalIndexer.get_data_by_season"><a class="viewcode-back" href="../../../../pyFTS.models.seasonal.html#pyFTS.models.seasonal.SeasonalIndexer.SeasonalIndexer.get_data_by_season">[docs]</a> <span class="k">def</span> <span class="nf">get_data_by_season</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">indexes</span><span class="p">):</span>
|
||||
<span class="k">pass</span></div>
|
||||
|
||||
<div class="viewcode-block" id="SeasonalIndexer.get_index_by_season"><a class="viewcode-back" href="../../../../pyFTS.models.seasonal.html#pyFTS.models.seasonal.SeasonalIndexer.SeasonalIndexer.get_index_by_season">[docs]</a> <span class="k">def</span> <span class="nf">get_index_by_season</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">indexes</span><span class="p">):</span>
|
||||
<span class="k">pass</span></div>
|
||||
|
||||
<div class="viewcode-block" id="SeasonalIndexer.get_data"><a class="viewcode-back" href="../../../../pyFTS.models.seasonal.html#pyFTS.models.seasonal.SeasonalIndexer.SeasonalIndexer.get_data">[docs]</a> <span class="k">def</span> <span class="nf">get_data</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
|
||||
<span class="k">pass</span></div>
|
||||
|
||||
<div class="viewcode-block" id="SeasonalIndexer.get_index"><a class="viewcode-back" href="../../../../pyFTS.models.seasonal.html#pyFTS.models.seasonal.SeasonalIndexer.SeasonalIndexer.get_index">[docs]</a> <span class="k">def</span> <span class="nf">get_index</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
|
||||
<span class="k">pass</span></div></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="LinearSeasonalIndexer"><a class="viewcode-back" href="../../../../pyFTS.models.seasonal.html#pyFTS.models.seasonal.SeasonalIndexer.LinearSeasonalIndexer">[docs]</a><span class="k">class</span> <span class="nc">LinearSeasonalIndexer</span><span class="p">(</span><span class="n">SeasonalIndexer</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""Use the data array/list position to index the seasonality """</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">seasons</span><span class="p">,</span> <span class="n">units</span><span class="p">,</span> <span class="n">ignore</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Indexer for array/list position</span>
|
||||
<span class="sd"> :param seasons: A list with the season group (i.e: 7 for week, 30 for month, etc)</span>
|
||||
<span class="sd"> :param units: A list with the units used for each season group, the default is 1 for each</span>
|
||||
<span class="sd"> :param ignore:</span>
|
||||
<span class="sd"> :param kwargs:</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">LinearSeasonalIndexer</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">seasons</span><span class="p">),</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">seasons</span> <span class="o">=</span> <span class="n">seasons</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">units</span> <span class="o">=</span> <span class="n">units</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">ignore</span> <span class="o">=</span> <span class="n">ignore</span>
|
||||
|
||||
<div class="viewcode-block" id="LinearSeasonalIndexer.get_season_of_data"><a class="viewcode-back" href="../../../../pyFTS.models.seasonal.html#pyFTS.models.seasonal.SeasonalIndexer.LinearSeasonalIndexer.get_season_of_data">[docs]</a> <span class="k">def</span> <span class="nf">get_season_of_data</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">data</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_season_by_index</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">))</span><span class="o">.</span><span class="n">tolist</span><span class="p">())</span></div>
|
||||
|
||||
<div class="viewcode-block" id="LinearSeasonalIndexer.get_season_by_index"><a class="viewcode-back" href="../../../../pyFTS.models.seasonal.html#pyFTS.models.seasonal.SeasonalIndexer.LinearSeasonalIndexer.get_season_by_index">[docs]</a> <span class="k">def</span> <span class="nf">get_season_by_index</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">index</span><span class="p">):</span>
|
||||
<span class="n">ret</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">index</span><span class="p">,</span> <span class="p">(</span><span class="nb">list</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">)):</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">num_seasons</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
|
||||
<span class="n">season</span> <span class="o">=</span> <span class="p">(</span><span class="n">index</span> <span class="o">//</span> <span class="bp">self</span><span class="o">.</span><span class="n">units</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">seasons</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">season</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">ct</span><span class="p">,</span> <span class="n">seasonality</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">seasons</span><span class="p">,</span> <span class="n">start</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="p">(</span><span class="n">index</span> <span class="o">//</span> <span class="bp">self</span><span class="o">.</span><span class="n">units</span><span class="p">[</span><span class="n">ct</span><span class="p">])</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">seasons</span><span class="p">[</span><span class="n">ct</span><span class="p">]</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">ignore</span><span class="p">[</span><span class="n">ct</span><span class="p">]:</span>
|
||||
<span class="n">season</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">tmp</span><span class="p">)</span>
|
||||
<span class="n">ret</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">season</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="k">for</span> <span class="n">ix</span> <span class="ow">in</span> <span class="n">index</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">num_seasons</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
|
||||
<span class="n">season</span> <span class="o">=</span> <span class="p">(</span><span class="n">ix</span> <span class="o">//</span> <span class="bp">self</span><span class="o">.</span><span class="n">units</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">seasons</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">season</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">ct</span><span class="p">,</span> <span class="n">seasonality</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">seasons</span><span class="p">,</span> <span class="n">start</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="p">(</span><span class="n">ix</span> <span class="o">//</span> <span class="bp">self</span><span class="o">.</span><span class="n">units</span><span class="p">[</span><span class="n">ct</span><span class="p">])</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">seasons</span><span class="p">[</span><span class="n">ct</span><span class="p">]</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">ignore</span><span class="p">[</span><span class="n">ct</span><span class="p">]:</span>
|
||||
<span class="n">season</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">tmp</span><span class="p">)</span>
|
||||
<span class="n">ret</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">season</span><span class="p">)</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">ret</span></div>
|
||||
|
||||
<div class="viewcode-block" id="LinearSeasonalIndexer.get_index_by_season"><a class="viewcode-back" href="../../../../pyFTS.models.seasonal.html#pyFTS.models.seasonal.SeasonalIndexer.LinearSeasonalIndexer.get_index_by_season">[docs]</a> <span class="k">def</span> <span class="nf">get_index_by_season</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">indexes</span><span class="p">):</span>
|
||||
<span class="n">ix</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">count</span><span class="p">,</span><span class="n">season</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">seasons</span><span class="p">):</span>
|
||||
<span class="n">ix</span> <span class="o">+=</span> <span class="n">season</span><span class="o">*</span><span class="p">(</span><span class="n">indexes</span><span class="p">[</span><span class="n">count</span><span class="p">])</span>
|
||||
|
||||
<span class="c1">#ix += indexes[-1]</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">ix</span></div>
|
||||
|
||||
<div class="viewcode-block" id="LinearSeasonalIndexer.get_data"><a class="viewcode-back" href="../../../../pyFTS.models.seasonal.html#pyFTS.models.seasonal.SeasonalIndexer.LinearSeasonalIndexer.get_data">[docs]</a> <span class="k">def</span> <span class="nf">get_data</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="n">data</span></div></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="DataFrameSeasonalIndexer"><a class="viewcode-back" href="../../../../pyFTS.models.seasonal.html#pyFTS.models.seasonal.SeasonalIndexer.DataFrameSeasonalIndexer">[docs]</a><span class="k">class</span> <span class="nc">DataFrameSeasonalIndexer</span><span class="p">(</span><span class="n">SeasonalIndexer</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""Use the Pandas.DataFrame index position to index the seasonality """</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">index_fields</span><span class="p">,</span><span class="n">index_seasons</span><span class="p">,</span> <span class="n">data_field</span><span class="p">,</span><span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
|
||||
<span class="sd"> :param index_fields: DataFrame field to use as index</span>
|
||||
<span class="sd"> :param index_seasons: A list with the season group, i. e., multiples of positions that are considered a season (i.e: 7 for week, 30 for month, etc)</span>
|
||||
<span class="sd"> :param data_fields: DataFrame field to use as data</span>
|
||||
<span class="sd"> :param kwargs:</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">DataFrameSeasonalIndexer</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">index_seasons</span><span class="p">),</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">fields</span> <span class="o">=</span> <span class="n">index_fields</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">seasons</span> <span class="o">=</span> <span class="n">index_seasons</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">data_field</span> <span class="o">=</span> <span class="n">data_field</span>
|
||||
|
||||
<div class="viewcode-block" id="DataFrameSeasonalIndexer.get_season_of_data"><a class="viewcode-back" href="../../../../pyFTS.models.seasonal.html#pyFTS.models.seasonal.SeasonalIndexer.DataFrameSeasonalIndexer.get_season_of_data">[docs]</a> <span class="k">def</span> <span class="nf">get_season_of_data</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">data</span><span class="p">):</span>
|
||||
<span class="c1">#data = data.copy()</span>
|
||||
<span class="n">ret</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">ix</span> <span class="ow">in</span> <span class="n">data</span><span class="o">.</span><span class="n">index</span><span class="p">:</span>
|
||||
<span class="n">season</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">c</span><span class="p">,</span> <span class="n">f</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">fields</span><span class="p">,</span> <span class="n">start</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">seasons</span><span class="p">[</span><span class="n">c</span><span class="p">]</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">season</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="n">f</span><span class="p">][</span><span class="n">ix</span><span class="p">])</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">a</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="n">f</span><span class="p">][</span><span class="n">ix</span><span class="p">]</span>
|
||||
<span class="n">season</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">a</span> <span class="o">//</span> <span class="bp">self</span><span class="o">.</span><span class="n">seasons</span><span class="p">[</span><span class="n">c</span><span class="p">])</span>
|
||||
<span class="n">ret</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">season</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">ret</span></div>
|
||||
|
||||
<div class="viewcode-block" id="DataFrameSeasonalIndexer.get_season_by_index"><a class="viewcode-back" href="../../../../pyFTS.models.seasonal.html#pyFTS.models.seasonal.SeasonalIndexer.DataFrameSeasonalIndexer.get_season_by_index">[docs]</a> <span class="k">def</span> <span class="nf">get_season_by_index</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">index</span><span class="p">):</span>
|
||||
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s2">"Operation not available!"</span><span class="p">)</span></div>
|
||||
|
||||
<div class="viewcode-block" id="DataFrameSeasonalIndexer.get_data_by_season"><a class="viewcode-back" href="../../../../pyFTS.models.seasonal.html#pyFTS.models.seasonal.SeasonalIndexer.DataFrameSeasonalIndexer.get_data_by_season">[docs]</a> <span class="k">def</span> <span class="nf">get_data_by_season</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">indexes</span><span class="p">):</span>
|
||||
<span class="k">for</span> <span class="n">season</span> <span class="ow">in</span> <span class="n">indexes</span><span class="p">:</span>
|
||||
<span class="k">for</span> <span class="n">c</span><span class="p">,</span> <span class="n">f</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">fields</span><span class="p">,</span> <span class="n">start</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">seasons</span><span class="p">[</span><span class="n">c</span><span class="p">]</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">data</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="n">data</span><span class="p">[</span><span class="n">f</span><span class="p">]</span><span class="o">==</span> <span class="n">season</span><span class="p">[</span><span class="n">c</span><span class="p">]]</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">data</span> <span class="o">=</span> <span class="n">data</span><span class="p">[(</span><span class="n">data</span><span class="p">[</span><span class="n">f</span><span class="p">]</span> <span class="o">//</span> <span class="bp">self</span><span class="o">.</span><span class="n">seasons</span><span class="p">[</span><span class="n">c</span><span class="p">])</span> <span class="o">==</span> <span class="n">season</span><span class="p">[</span><span class="n">c</span><span class="p">]]</span>
|
||||
<span class="k">return</span> <span class="n">data</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">data_field</span><span class="p">]</span></div>
|
||||
|
||||
<div class="viewcode-block" id="DataFrameSeasonalIndexer.get_index_by_season"><a class="viewcode-back" href="../../../../pyFTS.models.seasonal.html#pyFTS.models.seasonal.SeasonalIndexer.DataFrameSeasonalIndexer.get_index_by_season">[docs]</a> <span class="k">def</span> <span class="nf">get_index_by_season</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">indexes</span><span class="p">):</span>
|
||||
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s2">"Operation not available!"</span><span class="p">)</span></div>
|
||||
|
||||
<div class="viewcode-block" id="DataFrameSeasonalIndexer.get_data"><a class="viewcode-back" href="../../../../pyFTS.models.seasonal.html#pyFTS.models.seasonal.SeasonalIndexer.DataFrameSeasonalIndexer.get_data">[docs]</a> <span class="k">def</span> <span class="nf">get_data</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="n">data</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">data_field</span><span class="p">]</span><span class="o">.</span><span class="n">tolist</span><span class="p">()</span></div>
|
||||
|
||||
<div class="viewcode-block" id="DataFrameSeasonalIndexer.set_data"><a class="viewcode-back" href="../../../../pyFTS.models.seasonal.html#pyFTS.models.seasonal.SeasonalIndexer.DataFrameSeasonalIndexer.set_data">[docs]</a> <span class="k">def</span> <span class="nf">set_data</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
|
||||
<span class="n">data</span><span class="o">.</span><span class="n">loc</span><span class="p">[:,</span><span class="bp">self</span><span class="o">.</span><span class="n">data_field</span><span class="p">]</span> <span class="o">=</span> <span class="n">value</span>
|
||||
<span class="k">return</span> <span class="n">data</span></div></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="DateTimeSeasonalIndexer"><a class="viewcode-back" href="../../../../pyFTS.models.seasonal.html#pyFTS.models.seasonal.SeasonalIndexer.DateTimeSeasonalIndexer">[docs]</a><span class="k">class</span> <span class="nc">DateTimeSeasonalIndexer</span><span class="p">(</span><span class="n">SeasonalIndexer</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""Use a Pandas.DataFrame date field to index the seasonality """</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">date_field</span><span class="p">,</span> <span class="n">index_fields</span><span class="p">,</span> <span class="n">index_seasons</span><span class="p">,</span> <span class="n">data_field</span><span class="p">,</span><span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
|
||||
<span class="sd"> :param date_field: DataFrame field that contains the datetime field used on index</span>
|
||||
<span class="sd"> :param index_fields: List with commom.DataTime fields</span>
|
||||
<span class="sd"> :param index_seasons: Multiples of index_fields, the default is 1</span>
|
||||
<span class="sd"> :param data_field: DataFrame field with the time series data</span>
|
||||
<span class="sd"> :param kwargs:</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">DateTimeSeasonalIndexer</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">index_seasons</span><span class="p">),</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">fields</span> <span class="o">=</span> <span class="n">index_fields</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">seasons</span> <span class="o">=</span> <span class="n">index_seasons</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">data_field</span> <span class="o">=</span> <span class="n">data_field</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">date_field</span> <span class="o">=</span> <span class="n">date_field</span>
|
||||
|
||||
<div class="viewcode-block" id="DateTimeSeasonalIndexer.get_season_of_data"><a class="viewcode-back" href="../../../../pyFTS.models.seasonal.html#pyFTS.models.seasonal.SeasonalIndexer.DateTimeSeasonalIndexer.get_season_of_data">[docs]</a> <span class="k">def</span> <span class="nf">get_season_of_data</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
|
||||
|
||||
<span class="n">ret</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
|
||||
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">):</span>
|
||||
<span class="k">for</span> <span class="n">ix</span> <span class="ow">in</span> <span class="n">data</span><span class="o">.</span><span class="n">index</span><span class="p">:</span>
|
||||
<span class="n">date</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">date_field</span><span class="p">][</span><span class="n">ix</span><span class="p">]</span>
|
||||
<span class="n">season</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">c</span><span class="p">,</span> <span class="n">f</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">fields</span><span class="p">,</span> <span class="n">start</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">common</span><span class="o">.</span><span class="n">strip_datepart</span><span class="p">(</span><span class="n">date</span><span class="p">,</span> <span class="n">f</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">seasons</span><span class="p">[</span><span class="n">c</span><span class="p">]</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">tmp</span> <span class="o">//</span> <span class="bp">self</span><span class="o">.</span><span class="n">seasons</span><span class="p">[</span><span class="n">c</span><span class="p">]</span>
|
||||
<span class="n">season</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">tmp</span><span class="p">)</span>
|
||||
<span class="n">ret</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">season</span><span class="p">)</span>
|
||||
|
||||
<span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">pd</span><span class="o">.</span><span class="n">Series</span><span class="p">):</span>
|
||||
<span class="n">date</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">date_field</span><span class="p">]</span>
|
||||
<span class="n">season</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">c</span><span class="p">,</span> <span class="n">f</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">fields</span><span class="p">,</span> <span class="n">start</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span>
|
||||
<span class="n">season</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">common</span><span class="o">.</span><span class="n">strip_datepart</span><span class="p">(</span><span class="n">date</span><span class="p">,</span> <span class="n">f</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">seasons</span><span class="p">[</span><span class="n">c</span><span class="p">]))</span>
|
||||
<span class="n">ret</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">season</span><span class="p">)</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">ret</span></div>
|
||||
|
||||
<div class="viewcode-block" id="DateTimeSeasonalIndexer.get_season_by_index"><a class="viewcode-back" href="../../../../pyFTS.models.seasonal.html#pyFTS.models.seasonal.SeasonalIndexer.DateTimeSeasonalIndexer.get_season_by_index">[docs]</a> <span class="k">def</span> <span class="nf">get_season_by_index</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">index</span><span class="p">):</span>
|
||||
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s2">"Operation not available!"</span><span class="p">)</span></div>
|
||||
|
||||
<div class="viewcode-block" id="DateTimeSeasonalIndexer.get_data_by_season"><a class="viewcode-back" href="../../../../pyFTS.models.seasonal.html#pyFTS.models.seasonal.SeasonalIndexer.DateTimeSeasonalIndexer.get_data_by_season">[docs]</a> <span class="k">def</span> <span class="nf">get_data_by_season</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">indexes</span><span class="p">):</span>
|
||||
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s2">"Operation not available!"</span><span class="p">)</span></div>
|
||||
|
||||
<div class="viewcode-block" id="DateTimeSeasonalIndexer.get_index_by_season"><a class="viewcode-back" href="../../../../pyFTS.models.seasonal.html#pyFTS.models.seasonal.SeasonalIndexer.DateTimeSeasonalIndexer.get_index_by_season">[docs]</a> <span class="k">def</span> <span class="nf">get_index_by_season</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">indexes</span><span class="p">):</span>
|
||||
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s2">"Operation not available!"</span><span class="p">)</span></div>
|
||||
|
||||
<div class="viewcode-block" id="DateTimeSeasonalIndexer.get_data"><a class="viewcode-back" href="../../../../pyFTS.models.seasonal.html#pyFTS.models.seasonal.SeasonalIndexer.DateTimeSeasonalIndexer.get_data">[docs]</a> <span class="k">def</span> <span class="nf">get_data</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="n">data</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">data_field</span><span class="p">]</span><span class="o">.</span><span class="n">tolist</span><span class="p">()</span></div>
|
||||
|
||||
<div class="viewcode-block" id="DateTimeSeasonalIndexer.get_index"><a class="viewcode-back" href="../../../../pyFTS.models.seasonal.html#pyFTS.models.seasonal.SeasonalIndexer.DateTimeSeasonalIndexer.get_index">[docs]</a> <span class="k">def</span> <span class="nf">get_index</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="n">data</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">date_field</span><span class="p">]</span><span class="o">.</span><span class="n">tolist</span><span class="p">()</span> <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">pd</span><span class="o">.</span><span class="n">DataFrame</span><span class="p">)</span> <span class="k">else</span> <span class="n">data</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">date_field</span><span class="p">]</span></div>
|
||||
|
||||
<div class="viewcode-block" id="DateTimeSeasonalIndexer.set_data"><a class="viewcode-back" href="../../../../pyFTS.models.seasonal.html#pyFTS.models.seasonal.SeasonalIndexer.DateTimeSeasonalIndexer.set_data">[docs]</a> <span class="k">def</span> <span class="nf">set_data</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
|
||||
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s2">"Operation not available!"</span><span class="p">)</span></div></div>
|
||||
|
||||
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../../index.html">
|
||||
<img class="logo" src="../../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.models.seasonal.SeasonalIndexer</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,204 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.models.seasonal.common — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../../" id="documentation_options" src="../../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../../_static/jquery.js"></script>
|
||||
<script src="../../../../_static/underscore.js"></script>
|
||||
<script src="../../../../_static/doctools.js"></script>
|
||||
<script src="../../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.models.seasonal.common</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.models.seasonal.common</h1><div class="highlight"><pre>
|
||||
<span></span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
<span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span>
|
||||
<span class="kn">from</span> <span class="nn">enum</span> <span class="kn">import</span> <span class="n">Enum</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.common</span> <span class="kn">import</span> <span class="n">FuzzySet</span><span class="p">,</span> <span class="n">Membership</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.partitioners</span> <span class="kn">import</span> <span class="n">partitioner</span><span class="p">,</span> <span class="n">Grid</span>
|
||||
<span class="kn">from</span> <span class="nn">datetime</span> <span class="kn">import</span> <span class="n">date</span> <span class="k">as</span> <span class="n">dt</span><span class="p">,</span> <span class="n">datetime</span> <span class="k">as</span> <span class="n">dtm</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="DateTime"><a class="viewcode-back" href="../../../../pyFTS.models.seasonal.html#pyFTS.models.seasonal.common.DateTime">[docs]</a><span class="k">class</span> <span class="nc">DateTime</span><span class="p">(</span><span class="n">Enum</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Data and Time granularity for time granularity and seasonality identification</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">year</span> <span class="o">=</span> <span class="mi">1</span>
|
||||
<span class="n">half</span> <span class="o">=</span> <span class="mi">2</span> <span class="c1"># six months</span>
|
||||
<span class="n">third</span> <span class="o">=</span> <span class="mi">3</span> <span class="c1"># four months</span>
|
||||
<span class="n">quarter</span> <span class="o">=</span> <span class="mi">4</span> <span class="c1"># three months</span>
|
||||
<span class="n">sixth</span> <span class="o">=</span> <span class="mi">6</span> <span class="c1"># two months</span>
|
||||
<span class="n">month</span> <span class="o">=</span> <span class="mi">12</span>
|
||||
<span class="n">day_of_month</span> <span class="o">=</span> <span class="mi">30</span>
|
||||
<span class="n">day_of_year</span> <span class="o">=</span> <span class="mi">364</span>
|
||||
<span class="n">day_of_week</span> <span class="o">=</span> <span class="mi">7</span>
|
||||
<span class="n">hour</span> <span class="o">=</span> <span class="mi">24</span>
|
||||
<span class="n">minute</span> <span class="o">=</span> <span class="mi">60</span>
|
||||
<span class="n">second</span> <span class="o">=</span> <span class="mi">60</span>
|
||||
<span class="n">hour_of_day</span> <span class="o">=</span> <span class="mi">24</span>
|
||||
<span class="n">hour_of_week</span> <span class="o">=</span> <span class="mi">168</span>
|
||||
<span class="n">hour_of_month</span> <span class="o">=</span> <span class="mi">744</span>
|
||||
<span class="n">hour_of_year</span> <span class="o">=</span> <span class="mi">8736</span>
|
||||
<span class="n">minute_of_hour</span> <span class="o">=</span> <span class="mi">60</span>
|
||||
<span class="n">minute_of_day</span> <span class="o">=</span> <span class="mi">1440</span>
|
||||
<span class="n">minute_of_week</span> <span class="o">=</span> <span class="mi">10080</span>
|
||||
<span class="n">minute_of_month</span> <span class="o">=</span> <span class="mi">44640</span>
|
||||
<span class="n">minute_of_year</span> <span class="o">=</span> <span class="mi">524160</span>
|
||||
<span class="n">second_of_minute</span> <span class="o">=</span> <span class="mf">60.00001</span>
|
||||
<span class="n">second_of_hour</span> <span class="o">=</span> <span class="mi">3600</span>
|
||||
<span class="n">second_of_day</span> <span class="o">=</span> <span class="mi">86400</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="strip_datepart"><a class="viewcode-back" href="../../../../pyFTS.models.seasonal.html#pyFTS.models.seasonal.common.strip_datepart">[docs]</a><span class="k">def</span> <span class="nf">strip_datepart</span><span class="p">(</span><span class="n">date</span><span class="p">,</span> <span class="n">date_part</span><span class="p">,</span> <span class="n">mask</span><span class="o">=</span><span class="s1">''</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">date</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span>
|
||||
<span class="n">date</span> <span class="o">=</span> <span class="n">dtm</span><span class="o">.</span><span class="n">strptime</span><span class="p">(</span><span class="n">date</span><span class="p">,</span> <span class="n">mask</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">date_part</span> <span class="o">==</span> <span class="n">DateTime</span><span class="o">.</span><span class="n">year</span><span class="p">:</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">date</span><span class="o">.</span><span class="n">year</span>
|
||||
<span class="k">elif</span> <span class="n">date_part</span> <span class="o">==</span> <span class="n">DateTime</span><span class="o">.</span><span class="n">month</span><span class="p">:</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">date</span><span class="o">.</span><span class="n">month</span>
|
||||
<span class="k">elif</span> <span class="n">date_part</span> <span class="ow">in</span> <span class="p">(</span><span class="n">DateTime</span><span class="o">.</span><span class="n">half</span><span class="p">,</span> <span class="n">DateTime</span><span class="o">.</span><span class="n">third</span><span class="p">,</span> <span class="n">DateTime</span><span class="o">.</span><span class="n">quarter</span><span class="p">,</span> <span class="n">DateTime</span><span class="o">.</span><span class="n">sixth</span><span class="p">):</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="p">(</span><span class="n">date</span><span class="o">.</span><span class="n">month</span> <span class="o">//</span> <span class="n">date_part</span><span class="o">.</span><span class="n">value</span><span class="p">)</span> <span class="o">+</span> <span class="mi">1</span>
|
||||
<span class="k">elif</span> <span class="n">date_part</span> <span class="o">==</span> <span class="n">DateTime</span><span class="o">.</span><span class="n">day_of_year</span><span class="p">:</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">date</span><span class="o">.</span><span class="n">timetuple</span><span class="p">()</span><span class="o">.</span><span class="n">tm_yday</span>
|
||||
<span class="k">elif</span> <span class="n">date_part</span> <span class="o">==</span> <span class="n">DateTime</span><span class="o">.</span><span class="n">day_of_month</span><span class="p">:</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">date</span><span class="o">.</span><span class="n">day</span>
|
||||
<span class="k">elif</span> <span class="n">date_part</span> <span class="o">==</span> <span class="n">DateTime</span><span class="o">.</span><span class="n">day_of_week</span><span class="p">:</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">date</span><span class="o">.</span><span class="n">weekday</span><span class="p">()</span>
|
||||
<span class="k">elif</span> <span class="n">date_part</span> <span class="o">==</span> <span class="n">DateTime</span><span class="o">.</span><span class="n">hour</span> <span class="ow">or</span> <span class="n">date_part</span> <span class="o">==</span> <span class="n">DateTime</span><span class="o">.</span><span class="n">hour_of_day</span><span class="p">:</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">date</span><span class="o">.</span><span class="n">hour</span>
|
||||
<span class="k">elif</span> <span class="n">date_part</span> <span class="o">==</span> <span class="n">DateTime</span><span class="o">.</span><span class="n">hour_of_week</span><span class="p">:</span>
|
||||
<span class="n">wk</span> <span class="o">=</span> <span class="p">(</span><span class="n">date</span><span class="o">.</span><span class="n">weekday</span><span class="p">()</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span> <span class="o">*</span> <span class="mi">24</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">date</span><span class="o">.</span><span class="n">hour</span> <span class="o">+</span> <span class="n">wk</span>
|
||||
<span class="k">elif</span> <span class="n">date_part</span> <span class="o">==</span> <span class="n">DateTime</span><span class="o">.</span><span class="n">hour_of_month</span><span class="p">:</span>
|
||||
<span class="n">wk</span> <span class="o">=</span> <span class="p">(</span><span class="n">date</span><span class="o">.</span><span class="n">day</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span> <span class="o">*</span> <span class="mi">24</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">date</span><span class="o">.</span><span class="n">hour</span> <span class="o">+</span> <span class="n">wk</span>
|
||||
<span class="k">elif</span> <span class="n">date_part</span> <span class="o">==</span> <span class="n">DateTime</span><span class="o">.</span><span class="n">hour_of_year</span><span class="p">:</span>
|
||||
<span class="n">wk</span> <span class="o">=</span> <span class="p">(</span><span class="n">date</span><span class="o">.</span><span class="n">timetuple</span><span class="p">()</span><span class="o">.</span><span class="n">tm_yday</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span> <span class="o">*</span> <span class="mi">24</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">date</span><span class="o">.</span><span class="n">hour</span> <span class="o">+</span> <span class="n">wk</span>
|
||||
<span class="k">elif</span> <span class="n">date_part</span> <span class="o">==</span> <span class="n">DateTime</span><span class="o">.</span><span class="n">minute</span> <span class="ow">or</span> <span class="n">date_part</span> <span class="o">==</span> <span class="n">DateTime</span><span class="o">.</span><span class="n">minute_of_hour</span><span class="p">:</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">date</span><span class="o">.</span><span class="n">minute</span>
|
||||
<span class="k">elif</span> <span class="n">date_part</span> <span class="o">==</span> <span class="n">DateTime</span><span class="o">.</span><span class="n">minute_of_day</span><span class="p">:</span>
|
||||
<span class="n">wk</span> <span class="o">=</span> <span class="n">date</span><span class="o">.</span><span class="n">hour</span> <span class="o">*</span> <span class="mi">60</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">date</span><span class="o">.</span><span class="n">minute</span> <span class="o">+</span> <span class="n">wk</span>
|
||||
<span class="k">elif</span> <span class="n">date_part</span> <span class="o">==</span> <span class="n">DateTime</span><span class="o">.</span><span class="n">minute_of_week</span><span class="p">:</span>
|
||||
<span class="n">wk1</span> <span class="o">=</span> <span class="p">(</span><span class="n">date</span><span class="o">.</span><span class="n">weekday</span><span class="p">()</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span> <span class="o">*</span> <span class="mi">1440</span> <span class="c1">#24 * 60</span>
|
||||
<span class="n">wk2</span> <span class="o">=</span> <span class="n">date</span><span class="o">.</span><span class="n">hour</span> <span class="o">*</span> <span class="mi">60</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">date</span><span class="o">.</span><span class="n">minute</span> <span class="o">+</span> <span class="n">wk1</span> <span class="o">+</span> <span class="n">wk2</span>
|
||||
<span class="k">elif</span> <span class="n">date_part</span> <span class="o">==</span> <span class="n">DateTime</span><span class="o">.</span><span class="n">minute_of_month</span><span class="p">:</span>
|
||||
<span class="n">wk1</span> <span class="o">=</span> <span class="p">(</span><span class="n">date</span><span class="o">.</span><span class="n">day</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> <span class="o">*</span> <span class="mi">1440</span> <span class="c1">#24 * 60</span>
|
||||
<span class="n">wk2</span> <span class="o">=</span> <span class="n">date</span><span class="o">.</span><span class="n">hour</span> <span class="o">*</span> <span class="mi">60</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">date</span><span class="o">.</span><span class="n">minute</span> <span class="o">+</span> <span class="n">wk1</span> <span class="o">+</span> <span class="n">wk2</span>
|
||||
<span class="k">elif</span> <span class="n">date_part</span> <span class="o">==</span> <span class="n">DateTime</span><span class="o">.</span><span class="n">minute_of_year</span><span class="p">:</span>
|
||||
<span class="n">wk1</span> <span class="o">=</span> <span class="p">(</span><span class="n">date</span><span class="o">.</span><span class="n">timetuple</span><span class="p">()</span><span class="o">.</span><span class="n">tm_yday</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span> <span class="o">*</span> <span class="mi">1440</span> <span class="c1">#24 * 60</span>
|
||||
<span class="n">wk2</span> <span class="o">=</span> <span class="n">date</span><span class="o">.</span><span class="n">hour</span> <span class="o">*</span> <span class="mi">60</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">date</span><span class="o">.</span><span class="n">minute</span> <span class="o">+</span> <span class="n">wk1</span> <span class="o">+</span> <span class="n">wk2</span>
|
||||
<span class="k">elif</span> <span class="n">date_part</span> <span class="o">==</span> <span class="n">DateTime</span><span class="o">.</span><span class="n">second</span> <span class="ow">or</span> <span class="n">date_part</span> <span class="o">==</span> <span class="n">DateTime</span><span class="o">.</span><span class="n">second_of_minute</span><span class="p">:</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">date</span><span class="o">.</span><span class="n">second</span>
|
||||
<span class="k">elif</span> <span class="n">date_part</span> <span class="o">==</span> <span class="n">DateTime</span><span class="o">.</span><span class="n">second_of_hour</span><span class="p">:</span>
|
||||
<span class="n">wk1</span> <span class="o">=</span> <span class="n">date</span><span class="o">.</span><span class="n">minute</span> <span class="o">*</span> <span class="mi">60</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">date</span><span class="o">.</span><span class="n">second</span> <span class="o">+</span> <span class="n">wk1</span>
|
||||
<span class="k">elif</span> <span class="n">date_part</span> <span class="o">==</span> <span class="n">DateTime</span><span class="o">.</span><span class="n">second_of_day</span><span class="p">:</span>
|
||||
<span class="n">wk1</span> <span class="o">=</span> <span class="n">date</span><span class="o">.</span><span class="n">hour</span> <span class="o">*</span> <span class="mi">3600</span> <span class="c1">#60 * 60</span>
|
||||
<span class="n">wk2</span> <span class="o">=</span> <span class="n">date</span><span class="o">.</span><span class="n">minute</span> <span class="o">*</span> <span class="mi">60</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">date</span><span class="o">.</span><span class="n">second</span> <span class="o">+</span> <span class="n">wk1</span> <span class="o">+</span> <span class="n">wk2</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s2">"Unknown DateTime value!"</span><span class="p">)</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">tmp</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="FuzzySet"><a class="viewcode-back" href="../../../../pyFTS.models.seasonal.html#pyFTS.models.seasonal.common.FuzzySet">[docs]</a><span class="k">class</span> <span class="nc">FuzzySet</span><span class="p">(</span><span class="n">FuzzySet</span><span class="o">.</span><span class="n">FuzzySet</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Temporal/Seasonal Fuzzy Set</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">datepart</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">mf</span><span class="p">,</span> <span class="n">parameters</span><span class="p">,</span> <span class="n">centroid</span><span class="p">,</span> <span class="n">alpha</span><span class="o">=</span><span class="mf">1.0</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">FuzzySet</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">mf</span><span class="p">,</span> <span class="n">parameters</span><span class="p">,</span> <span class="n">centroid</span><span class="p">,</span> <span class="n">alpha</span><span class="p">,</span>
|
||||
<span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">datepart</span> <span class="o">=</span> <span class="n">datepart</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">type</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'type'</span><span class="p">,</span> <span class="s1">'seasonal'</span><span class="p">)</span>
|
||||
|
||||
<div class="viewcode-block" id="FuzzySet.transform"><a class="viewcode-back" href="../../../../pyFTS.models.seasonal.html#pyFTS.models.seasonal.common.FuzzySet.transform">[docs]</a> <span class="k">def</span> <span class="nf">transform</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">x</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">type</span> <span class="o">==</span> <span class="s1">'seasonal'</span> <span class="ow">and</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="p">(</span><span class="n">dt</span><span class="p">,</span> <span class="n">pd</span><span class="o">.</span><span class="n">Timestamp</span><span class="p">)):</span>
|
||||
<span class="n">dp</span> <span class="o">=</span> <span class="n">strip_datepart</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">datepart</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">dp</span> <span class="o">=</span> <span class="n">x</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">dp</span></div></div>
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../../index.html">
|
||||
<img class="logo" src="../../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.models.seasonal.common</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,293 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.models.seasonal.partitioner — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../../" id="documentation_options" src="../../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../../_static/jquery.js"></script>
|
||||
<script src="../../../../_static/underscore.js"></script>
|
||||
<script src="../../../../_static/doctools.js"></script>
|
||||
<script src="../../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.models.seasonal.partitioner</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.models.seasonal.partitioner</h1><div class="highlight"><pre>
|
||||
<span></span><span class="kn">from</span> <span class="nn">pyFTS.common</span> <span class="kn">import</span> <span class="n">Membership</span><span class="p">,</span> <span class="n">FuzzySet</span> <span class="k">as</span> <span class="n">FS</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.common.Composite</span> <span class="kn">import</span> <span class="n">FuzzySet</span> <span class="k">as</span> <span class="n">Composite</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.partitioners</span> <span class="kn">import</span> <span class="n">partitioner</span><span class="p">,</span> <span class="n">Grid</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.models.seasonal.common</span> <span class="kn">import</span> <span class="n">DateTime</span><span class="p">,</span> <span class="n">FuzzySet</span><span class="p">,</span> <span class="n">strip_datepart</span>
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
<span class="kn">import</span> <span class="nn">matplotlib.pylab</span> <span class="k">as</span> <span class="nn">plt</span>
|
||||
<span class="kn">from</span> <span class="nn">scipy.spatial</span> <span class="kn">import</span> <span class="n">KDTree</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="TimeGridPartitioner"><a class="viewcode-back" href="../../../../pyFTS.models.seasonal.html#pyFTS.models.seasonal.partitioner.TimeGridPartitioner">[docs]</a><span class="k">class</span> <span class="nc">TimeGridPartitioner</span><span class="p">(</span><span class="n">partitioner</span><span class="o">.</span><span class="n">Partitioner</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""Even Length DateTime Grid Partitioner"""</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Even Length Grid Partitioner</span>
|
||||
<span class="sd"> :param seasonality: Time granularity, from pyFTS.models.seasonal.common.DateTime</span>
|
||||
<span class="sd"> :param data: Training data of which the universe of discourse will be extracted. The universe of discourse is the open interval between the minimum and maximum values of the training data.</span>
|
||||
<span class="sd"> :param npart: The number of universe of discourse partitions, i.e., the number of fuzzy sets that will be created</span>
|
||||
<span class="sd"> :param func: Fuzzy membership function (pyFTS.common.Membership)</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">TimeGridPartitioner</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s2">"TimeGrid"</span><span class="p">,</span> <span class="n">preprocess</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">season</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'seasonality'</span><span class="p">,</span> <span class="n">DateTime</span><span class="o">.</span><span class="n">day_of_year</span><span class="p">)</span>
|
||||
<span class="w"> </span><span class="sd">'''Seasonality, a pyFTS.models.seasonal.common.DateTime object'''</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">mask</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'mask'</span><span class="p">,</span> <span class="s1">'%Y-%m-</span><span class="si">%d</span><span class="s1"> %H:%M:%S'</span><span class="p">)</span>
|
||||
<span class="w"> </span><span class="sd">'''A string with datetime formating mask'''</span>
|
||||
|
||||
<span class="n">data</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'data'</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">season</span> <span class="o">==</span> <span class="n">DateTime</span><span class="o">.</span><span class="n">year</span><span class="p">:</span>
|
||||
<span class="n">ndata</span> <span class="o">=</span> <span class="p">[</span><span class="n">strip_datepart</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">season</span><span class="p">)</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">data</span><span class="p">]</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">min</span> <span class="o">=</span> <span class="nb">min</span><span class="p">(</span><span class="n">ndata</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">max</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="n">ndata</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">season</span><span class="o">.</span><span class="n">value</span> <span class="o">/</span> <span class="bp">self</span><span class="o">.</span><span class="n">partitions</span><span class="p">)</span> <span class="o">/</span> <span class="mi">2</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">min</span> <span class="o">=</span> <span class="n">tmp</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">max</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">season</span><span class="o">.</span><span class="n">value</span> <span class="o">+</span> <span class="n">tmp</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">type</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'type'</span><span class="p">,</span><span class="s1">'seasonal'</span><span class="p">)</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">sets</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">build</span><span class="p">(</span><span class="kc">None</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">ordered_sets</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">setnames</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">ordered_sets</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">setnames</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">ordered_sets</span> <span class="o">=</span> <span class="n">FS</span><span class="o">.</span><span class="n">set_ordered</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">)</span>
|
||||
|
||||
<div class="viewcode-block" id="TimeGridPartitioner.extractor"><a class="viewcode-back" href="../../../../pyFTS.models.seasonal.html#pyFTS.models.seasonal.partitioner.TimeGridPartitioner.extractor">[docs]</a> <span class="k">def</span> <span class="nf">extractor</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">x</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">type</span> <span class="o">==</span> <span class="s1">'seasonal'</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">strip_datepart</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">season</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">mask</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">x</span></div>
|
||||
|
||||
<div class="viewcode-block" id="TimeGridPartitioner.build"><a class="viewcode-back" href="../../../../pyFTS.models.seasonal.html#pyFTS.models.seasonal.partitioner.TimeGridPartitioner.build">[docs]</a> <span class="k">def</span> <span class="nf">build</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
|
||||
<span class="n">sets</span> <span class="o">=</span> <span class="p">{}</span>
|
||||
|
||||
<span class="n">kwargs</span> <span class="o">=</span> <span class="p">{</span><span class="s1">'variable'</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">variable</span><span class="p">,</span> <span class="s1">'type'</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">type</span> <span class="p">}</span>
|
||||
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">season</span> <span class="o">==</span> <span class="n">DateTime</span><span class="o">.</span><span class="n">year</span><span class="p">:</span>
|
||||
<span class="n">dlen</span> <span class="o">=</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">max</span> <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">min</span><span class="p">)</span>
|
||||
<span class="n">partlen</span> <span class="o">=</span> <span class="n">dlen</span> <span class="o">/</span> <span class="bp">self</span><span class="o">.</span><span class="n">partitions</span>
|
||||
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">season</span> <span class="o">==</span> <span class="n">DateTime</span><span class="o">.</span><span class="n">day_of_week</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">min</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">max</span><span class="p">,</span> <span class="n">partlen</span><span class="p">,</span> <span class="n">pl2</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">7</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span>
|
||||
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">season</span> <span class="o">==</span> <span class="n">DateTime</span><span class="o">.</span><span class="n">minute</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">min</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">max</span><span class="p">,</span> <span class="n">partlen</span><span class="p">,</span> <span class="n">pl2</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">60</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span>
|
||||
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">season</span> <span class="o">==</span> <span class="n">DateTime</span><span class="o">.</span><span class="n">hour</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">min</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">max</span><span class="p">,</span> <span class="n">partlen</span><span class="p">,</span> <span class="n">pl2</span> <span class="o">=</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">24</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span>
|
||||
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">season</span> <span class="o">==</span> <span class="n">DateTime</span><span class="o">.</span><span class="n">month</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">min</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">max</span><span class="p">,</span> <span class="n">partlen</span><span class="p">,</span> <span class="n">pl2</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">13</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span>
|
||||
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">season</span> <span class="ow">in</span> <span class="p">(</span><span class="n">DateTime</span><span class="o">.</span><span class="n">half</span><span class="p">,</span> <span class="n">DateTime</span><span class="o">.</span><span class="n">third</span><span class="p">,</span> <span class="n">DateTime</span><span class="o">.</span><span class="n">quarter</span><span class="p">,</span> <span class="n">DateTime</span><span class="o">.</span><span class="n">sixth</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">min</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">max</span><span class="p">,</span> <span class="n">partlen</span><span class="p">,</span> <span class="n">pl2</span> <span class="o">=</span> <span class="mi">1</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">season</span><span class="o">.</span><span class="n">value</span><span class="o">+</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">partlen</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">season</span><span class="o">.</span><span class="n">value</span> <span class="o">/</span> <span class="bp">self</span><span class="o">.</span><span class="n">partitions</span>
|
||||
<span class="n">pl2</span> <span class="o">=</span> <span class="n">partlen</span> <span class="o">/</span> <span class="mi">2</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">count</span><span class="p">,</span> <span class="n">midpoint</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">min</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">max</span><span class="p">,</span> <span class="n">partlen</span><span class="p">)):</span>
|
||||
<span class="n">set_name</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_name</span><span class="p">(</span><span class="n">count</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">membership_function</span> <span class="o">==</span> <span class="n">Membership</span><span class="o">.</span><span class="n">trimf</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="n">midpoint</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">min</span> <span class="ow">or</span> <span class="n">count</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">Composite</span><span class="p">(</span><span class="n">set_name</span><span class="p">,</span> <span class="n">superset</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
<span class="n">tmp</span><span class="o">.</span><span class="n">append_set</span><span class="p">(</span><span class="n">FuzzySet</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">season</span><span class="p">,</span> <span class="n">set_name</span><span class="p">,</span> <span class="n">Membership</span><span class="o">.</span><span class="n">trimf</span><span class="p">,</span>
|
||||
<span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">season</span><span class="o">.</span><span class="n">value</span> <span class="o">-</span> <span class="n">pl2</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">season</span><span class="o">.</span><span class="n">value</span><span class="p">,</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">season</span><span class="o">.</span><span class="n">value</span> <span class="o">+</span> <span class="n">pl2</span><span class="p">],</span> <span class="bp">self</span><span class="o">.</span><span class="n">season</span><span class="o">.</span><span class="n">value</span><span class="p">,</span> <span class="n">alpha</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span>
|
||||
<span class="o">**</span><span class="n">kwargs</span><span class="p">))</span>
|
||||
<span class="n">tmp</span><span class="o">.</span><span class="n">append_set</span><span class="p">(</span><span class="n">FuzzySet</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">season</span><span class="p">,</span> <span class="n">set_name</span><span class="p">,</span> <span class="n">Membership</span><span class="o">.</span><span class="n">trimf</span><span class="p">,</span>
|
||||
<span class="p">[</span><span class="n">midpoint</span> <span class="o">-</span> <span class="n">partlen</span><span class="p">,</span> <span class="n">midpoint</span><span class="p">,</span> <span class="n">midpoint</span> <span class="o">+</span> <span class="n">partlen</span><span class="p">],</span> <span class="n">midpoint</span><span class="p">,</span>
|
||||
<span class="o">**</span><span class="n">kwargs</span><span class="p">))</span>
|
||||
<span class="n">tmp</span><span class="o">.</span><span class="n">centroid</span> <span class="o">=</span> <span class="n">midpoint</span>
|
||||
<span class="n">sets</span><span class="p">[</span><span class="n">set_name</span><span class="p">]</span> <span class="o">=</span> <span class="n">tmp</span>
|
||||
<span class="k">elif</span> <span class="n">midpoint</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">max</span> <span class="o">-</span> <span class="n">partlen</span> <span class="ow">or</span> <span class="n">count</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">partitions</span> <span class="o">-</span> <span class="mi">1</span><span class="p">:</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">Composite</span><span class="p">(</span><span class="n">set_name</span><span class="p">,</span> <span class="n">superset</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
<span class="n">tmp</span><span class="o">.</span><span class="n">append_set</span><span class="p">(</span><span class="n">FuzzySet</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">season</span><span class="p">,</span> <span class="n">set_name</span><span class="p">,</span> <span class="n">Membership</span><span class="o">.</span><span class="n">trimf</span><span class="p">,</span>
|
||||
<span class="p">[</span><span class="o">-</span><span class="n">pl2</span><span class="p">,</span> <span class="mf">0.0</span><span class="p">,</span>
|
||||
<span class="n">pl2</span><span class="p">],</span> <span class="mf">0.0</span><span class="p">,</span> <span class="n">alpha</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span>
|
||||
<span class="o">**</span><span class="n">kwargs</span><span class="p">))</span>
|
||||
<span class="n">tmp</span><span class="o">.</span><span class="n">append_set</span><span class="p">(</span><span class="n">FuzzySet</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">season</span><span class="p">,</span> <span class="n">set_name</span><span class="p">,</span> <span class="n">Membership</span><span class="o">.</span><span class="n">trimf</span><span class="p">,</span>
|
||||
<span class="p">[</span><span class="n">midpoint</span> <span class="o">-</span> <span class="n">partlen</span><span class="p">,</span> <span class="n">midpoint</span><span class="p">,</span> <span class="n">midpoint</span> <span class="o">+</span> <span class="n">partlen</span><span class="p">],</span> <span class="n">midpoint</span><span class="p">,</span>
|
||||
<span class="o">**</span><span class="n">kwargs</span><span class="p">))</span>
|
||||
<span class="n">tmp</span><span class="o">.</span><span class="n">centroid</span> <span class="o">=</span> <span class="n">midpoint</span>
|
||||
<span class="n">sets</span><span class="p">[</span><span class="n">set_name</span><span class="p">]</span> <span class="o">=</span> <span class="n">tmp</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">sets</span><span class="p">[</span><span class="n">set_name</span><span class="p">]</span> <span class="o">=</span> <span class="n">FuzzySet</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">season</span><span class="p">,</span> <span class="n">set_name</span><span class="p">,</span> <span class="n">Membership</span><span class="o">.</span><span class="n">trimf</span><span class="p">,</span>
|
||||
<span class="p">[</span><span class="n">midpoint</span> <span class="o">-</span> <span class="n">partlen</span><span class="p">,</span> <span class="n">midpoint</span><span class="p">,</span> <span class="n">midpoint</span> <span class="o">+</span> <span class="n">partlen</span><span class="p">],</span> <span class="n">midpoint</span><span class="p">,</span>
|
||||
<span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">membership_function</span> <span class="o">==</span> <span class="n">Membership</span><span class="o">.</span><span class="n">gaussmf</span><span class="p">:</span>
|
||||
<span class="n">sets</span><span class="p">[</span><span class="n">set_name</span><span class="p">]</span> <span class="o">=</span> <span class="n">FuzzySet</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">season</span><span class="p">,</span> <span class="n">set_name</span><span class="p">,</span> <span class="n">Membership</span><span class="o">.</span><span class="n">gaussmf</span><span class="p">,</span> <span class="p">[</span><span class="n">midpoint</span><span class="p">,</span> <span class="n">partlen</span> <span class="o">/</span> <span class="mi">3</span><span class="p">],</span> <span class="n">midpoint</span><span class="p">,</span>
|
||||
<span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">membership_function</span> <span class="o">==</span> <span class="n">Membership</span><span class="o">.</span><span class="n">trapmf</span><span class="p">:</span>
|
||||
<span class="n">q</span> <span class="o">=</span> <span class="n">partlen</span> <span class="o">/</span> <span class="mi">4</span>
|
||||
<span class="k">if</span> <span class="n">midpoint</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">min</span><span class="p">:</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">Composite</span><span class="p">(</span><span class="n">set_name</span><span class="p">,</span> <span class="n">superset</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
|
||||
<span class="n">tmp</span><span class="o">.</span><span class="n">append_set</span><span class="p">(</span><span class="n">FuzzySet</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">season</span><span class="p">,</span> <span class="n">set_name</span><span class="p">,</span> <span class="n">Membership</span><span class="o">.</span><span class="n">trimf</span><span class="p">,</span>
|
||||
<span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">season</span><span class="o">.</span><span class="n">value</span> <span class="o">-</span> <span class="n">pl2</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">season</span><span class="o">.</span><span class="n">value</span><span class="p">,</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">season</span><span class="o">.</span><span class="n">value</span> <span class="o">+</span> <span class="mf">0.0000001</span><span class="p">],</span> <span class="mi">0</span><span class="p">,</span>
|
||||
<span class="o">**</span><span class="n">kwargs</span><span class="p">))</span>
|
||||
<span class="n">tmp</span><span class="o">.</span><span class="n">append_set</span><span class="p">(</span><span class="n">FuzzySet</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">season</span><span class="p">,</span> <span class="n">set_name</span><span class="p">,</span> <span class="n">Membership</span><span class="o">.</span><span class="n">trapmf</span><span class="p">,</span>
|
||||
<span class="p">[</span><span class="n">midpoint</span> <span class="o">-</span> <span class="n">partlen</span><span class="p">,</span> <span class="n">midpoint</span> <span class="o">-</span> <span class="n">q</span><span class="p">,</span> <span class="n">midpoint</span> <span class="o">+</span> <span class="n">q</span><span class="p">,</span> <span class="n">midpoint</span> <span class="o">+</span> <span class="n">partlen</span><span class="p">],</span> <span class="n">midpoint</span><span class="p">,</span>
|
||||
<span class="o">**</span><span class="n">kwargs</span><span class="p">))</span>
|
||||
<span class="n">tmp</span><span class="o">.</span><span class="n">centroid</span> <span class="o">=</span> <span class="n">midpoint</span>
|
||||
<span class="n">sets</span><span class="p">[</span><span class="n">set_name</span><span class="p">]</span> <span class="o">=</span> <span class="n">tmp</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">sets</span><span class="p">[</span><span class="n">set_name</span><span class="p">]</span> <span class="o">=</span> <span class="n">FuzzySet</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">season</span><span class="p">,</span> <span class="n">set_name</span><span class="p">,</span> <span class="n">Membership</span><span class="o">.</span><span class="n">trapmf</span><span class="p">,</span>
|
||||
<span class="p">[</span><span class="n">midpoint</span> <span class="o">-</span> <span class="n">partlen</span><span class="p">,</span> <span class="n">midpoint</span> <span class="o">-</span> <span class="n">q</span><span class="p">,</span> <span class="n">midpoint</span> <span class="o">+</span> <span class="n">q</span><span class="p">,</span> <span class="n">midpoint</span> <span class="o">+</span> <span class="n">partlen</span><span class="p">],</span> <span class="n">midpoint</span><span class="p">,</span>
|
||||
<span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
<span class="n">count</span> <span class="o">+=</span> <span class="mi">1</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">min</span> <span class="o">=</span> <span class="mi">0</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">sets</span></div>
|
||||
|
||||
<div class="viewcode-block" id="TimeGridPartitioner.build_index"><a class="viewcode-back" href="../../../../pyFTS.models.seasonal.html#pyFTS.models.seasonal.partitioner.TimeGridPartitioner.build_index">[docs]</a> <span class="k">def</span> <span class="nf">build_index</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="n">points</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
|
||||
<span class="n">fset</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">ordered_sets</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span>
|
||||
<span class="n">points</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">fset</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">lower</span><span class="p">,</span> <span class="n">fset</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">centroid</span><span class="p">,</span> <span class="n">fset</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">upper</span><span class="p">])</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">ct</span><span class="p">,</span> <span class="n">key</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">ordered_sets</span><span class="p">[</span><span class="mi">1</span><span class="p">:</span><span class="o">-</span><span class="mi">1</span><span class="p">]):</span>
|
||||
<span class="n">fset</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="n">key</span><span class="p">]</span>
|
||||
<span class="n">points</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">fset</span><span class="o">.</span><span class="n">lower</span><span class="p">,</span> <span class="n">fset</span><span class="o">.</span><span class="n">centroid</span><span class="p">,</span> <span class="n">fset</span><span class="o">.</span><span class="n">upper</span><span class="p">])</span>
|
||||
|
||||
<span class="n">fset</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">ordered_sets</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]]</span>
|
||||
<span class="n">points</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">fset</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">lower</span><span class="p">,</span> <span class="n">fset</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">centroid</span><span class="p">,</span> <span class="n">fset</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">upper</span><span class="p">])</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">sys</span>
|
||||
<span class="n">sys</span><span class="o">.</span><span class="n">setrecursionlimit</span><span class="p">(</span><span class="mi">100000</span><span class="p">)</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">kdtree</span> <span class="o">=</span> <span class="n">KDTree</span><span class="p">(</span><span class="n">points</span><span class="p">)</span>
|
||||
|
||||
<span class="n">sys</span><span class="o">.</span><span class="n">setrecursionlimit</span><span class="p">(</span><span class="mi">1000</span><span class="p">)</span></div>
|
||||
|
||||
<div class="viewcode-block" id="TimeGridPartitioner.search"><a class="viewcode-back" href="../../../../pyFTS.models.seasonal.html#pyFTS.models.seasonal.partitioner.TimeGridPartitioner.search">[docs]</a> <span class="k">def</span> <span class="nf">search</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">'''</span>
|
||||
<span class="sd"> Perform a search for the nearest fuzzy sets of the point 'data'. This function were designed to work with several</span>
|
||||
<span class="sd"> overlapped fuzzy sets.</span>
|
||||
|
||||
<span class="sd"> :param data: the value to search for the nearest fuzzy sets</span>
|
||||
<span class="sd"> :param type: the return type: 'index' for the fuzzy set indexes or 'name' for fuzzy set names.</span>
|
||||
<span class="sd"> :param results: the number of nearest fuzzy sets to return</span>
|
||||
<span class="sd"> :return: a list with the nearest fuzzy sets</span>
|
||||
<span class="sd"> '''</span>
|
||||
|
||||
<span class="nb">type</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'type'</span><span class="p">,</span><span class="s1">'index'</span><span class="p">)</span>
|
||||
<span class="n">results</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'results'</span><span class="p">,</span><span class="mi">3</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">kdtree</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">build_index</span><span class="p">()</span>
|
||||
|
||||
<span class="n">_</span><span class="p">,</span> <span class="n">ix</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">kdtree</span><span class="o">.</span><span class="n">query</span><span class="p">([</span><span class="n">data</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">data</span><span class="p">],</span> <span class="n">results</span><span class="p">)</span>
|
||||
|
||||
<span class="n">ix</span> <span class="o">=</span> <span class="n">ix</span><span class="o">.</span><span class="n">tolist</span><span class="p">()</span>
|
||||
|
||||
<span class="k">if</span> <span class="mi">0</span> <span class="ow">in</span> <span class="n">ix</span><span class="p">:</span>
|
||||
<span class="n">ix</span><span class="o">.</span><span class="n">insert</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">partitions</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
|
||||
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">partitions</span><span class="o">-</span><span class="mi">1</span> <span class="ow">in</span> <span class="n">ix</span><span class="p">:</span>
|
||||
<span class="n">ix</span><span class="o">.</span><span class="n">insert</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="nb">type</span> <span class="o">==</span> <span class="s1">'name'</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">ordered_sets</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">ix</span><span class="p">)]</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">ix</span><span class="p">)</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="TimeGridPartitioner.plot"><a class="viewcode-back" href="../../../../pyFTS.models.seasonal.html#pyFTS.models.seasonal.partitioner.TimeGridPartitioner.plot">[docs]</a> <span class="k">def</span> <span class="nf">plot</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ax</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Plot the</span>
|
||||
<span class="sd"> :param ax:</span>
|
||||
<span class="sd"> :return:</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">ax</span><span class="o">.</span><span class="n">set_title</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">)</span>
|
||||
<span class="n">ax</span><span class="o">.</span><span class="n">set_ylim</span><span class="p">([</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">])</span>
|
||||
<span class="n">ax</span><span class="o">.</span><span class="n">set_xlim</span><span class="p">([</span><span class="mi">0</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">season</span><span class="o">.</span><span class="n">value</span><span class="p">])</span>
|
||||
<span class="n">ticks</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="n">x</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
|
||||
<span class="n">s</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="n">key</span><span class="p">]</span>
|
||||
<span class="k">if</span> <span class="n">s</span><span class="o">.</span><span class="n">type</span> <span class="o">==</span> <span class="s1">'composite'</span><span class="p">:</span>
|
||||
<span class="k">for</span> <span class="n">ss</span> <span class="ow">in</span> <span class="n">s</span><span class="o">.</span><span class="n">sets</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">plot_set</span><span class="p">(</span><span class="n">ax</span><span class="p">,</span> <span class="n">ss</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">plot_set</span><span class="p">(</span><span class="n">ax</span><span class="p">,</span> <span class="n">s</span><span class="p">)</span>
|
||||
<span class="n">ticks</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="nb">round</span><span class="p">(</span><span class="n">s</span><span class="o">.</span><span class="n">centroid</span><span class="p">,</span> <span class="mi">0</span><span class="p">))</span> <span class="o">+</span> <span class="s1">'</span><span class="se">\n</span><span class="s1">'</span> <span class="o">+</span> <span class="n">s</span><span class="o">.</span><span class="n">name</span><span class="p">)</span>
|
||||
<span class="n">x</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">s</span><span class="o">.</span><span class="n">centroid</span><span class="p">)</span>
|
||||
<span class="n">ax</span><span class="o">.</span><span class="n">xaxis</span><span class="o">.</span><span class="n">set_ticklabels</span><span class="p">(</span><span class="n">ticks</span><span class="p">)</span>
|
||||
<span class="n">ax</span><span class="o">.</span><span class="n">xaxis</span><span class="o">.</span><span class="n">set_ticks</span><span class="p">(</span><span class="n">x</span><span class="p">)</span></div></div>
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../../index.html">
|
||||
<img class="logo" src="../../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.models.seasonal.partitioner</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,190 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.partitioners.CMeans — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../_static/jquery.js"></script>
|
||||
<script src="../../../_static/underscore.js"></script>
|
||||
<script src="../../../_static/doctools.js"></script>
|
||||
<script src="../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.partitioners.CMeans</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.partitioners.CMeans</h1><div class="highlight"><pre>
|
||||
<span></span><span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
<span class="kn">import</span> <span class="nn">math</span>
|
||||
<span class="kn">import</span> <span class="nn">random</span> <span class="k">as</span> <span class="nn">rnd</span>
|
||||
<span class="kn">import</span> <span class="nn">functools</span><span class="o">,</span> <span class="nn">operator</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.common</span> <span class="kn">import</span> <span class="n">FuzzySet</span><span class="p">,</span> <span class="n">Membership</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.partitioners</span> <span class="kn">import</span> <span class="n">partitioner</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="distance"><a class="viewcode-back" href="../../../pyFTS.partitioners.html#pyFTS.partitioners.CMeans.distance">[docs]</a><span class="k">def</span> <span class="nf">distance</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">functools</span><span class="o">.</span><span class="n">reduce</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">add</span><span class="p">,</span> <span class="p">[(</span><span class="n">x</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">-</span> <span class="n">y</span><span class="p">[</span><span class="n">k</span><span class="p">])</span> <span class="o">**</span> <span class="mi">2</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">x</span><span class="p">))])</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="p">(</span><span class="n">x</span> <span class="o">-</span> <span class="n">y</span><span class="p">)</span> <span class="o">**</span> <span class="mi">2</span>
|
||||
<span class="k">return</span> <span class="n">math</span><span class="o">.</span><span class="n">sqrt</span><span class="p">(</span><span class="n">tmp</span><span class="p">)</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="c_means"><a class="viewcode-back" href="../../../pyFTS.partitioners.html#pyFTS.partitioners.CMeans.c_means">[docs]</a><span class="k">def</span> <span class="nf">c_means</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="n">dados</span><span class="p">,</span> <span class="n">tam</span><span class="p">):</span>
|
||||
<span class="c1"># Inicializa as centróides escolhendo elementos aleatórios dos conjuntos</span>
|
||||
<span class="n">centroides</span> <span class="o">=</span> <span class="p">[</span><span class="n">dados</span><span class="p">[</span><span class="n">rnd</span><span class="o">.</span><span class="n">randint</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">dados</span><span class="p">)</span><span class="o">-</span><span class="mi">1</span><span class="p">)]</span> <span class="k">for</span> <span class="n">kk</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">k</span><span class="p">)]</span>
|
||||
|
||||
<span class="n">grupos</span> <span class="o">=</span> <span class="p">[</span><span class="o">-</span><span class="mi">1</span> <span class="k">for</span> <span class="n">x</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">dados</span><span class="p">))]</span>
|
||||
|
||||
<span class="n">it_semmodificacao</span> <span class="o">=</span> <span class="mi">0</span>
|
||||
|
||||
<span class="c1"># para cada instância</span>
|
||||
<span class="n">iteracoes</span> <span class="o">=</span> <span class="mi">0</span>
|
||||
<span class="k">while</span> <span class="n">iteracoes</span> <span class="o"><</span> <span class="mi">1000</span> <span class="ow">and</span> <span class="n">it_semmodificacao</span> <span class="o"><</span> <span class="mi">10</span><span class="p">:</span>
|
||||
<span class="n">inst_count</span> <span class="o">=</span> <span class="mi">0</span>
|
||||
|
||||
<span class="n">modificacao</span> <span class="o">=</span> <span class="kc">False</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">instancia</span> <span class="ow">in</span> <span class="n">dados</span><span class="p">:</span>
|
||||
|
||||
<span class="c1"># verifica a distância para cada centroide</span>
|
||||
<span class="n">grupo_count</span> <span class="o">=</span> <span class="mi">0</span>
|
||||
<span class="n">dist</span> <span class="o">=</span> <span class="mi">10000</span>
|
||||
|
||||
<span class="n">grupotmp</span> <span class="o">=</span> <span class="n">grupos</span><span class="p">[</span><span class="n">inst_count</span><span class="p">]</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">grupo</span> <span class="ow">in</span> <span class="n">centroides</span><span class="p">:</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">distance</span><span class="p">(</span><span class="n">instancia</span><span class="p">,</span> <span class="n">grupo</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">tmp</span> <span class="o"><</span> <span class="n">dist</span><span class="p">:</span>
|
||||
<span class="n">dist</span> <span class="o">=</span> <span class="n">tmp</span>
|
||||
<span class="c1"># associa a a centroide de menor distância à instância</span>
|
||||
<span class="n">grupos</span><span class="p">[</span><span class="n">inst_count</span><span class="p">]</span> <span class="o">=</span> <span class="n">grupo_count</span>
|
||||
<span class="n">grupo_count</span> <span class="o">=</span> <span class="n">grupo_count</span> <span class="o">+</span> <span class="mi">1</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">grupotmp</span> <span class="o">!=</span> <span class="n">grupos</span><span class="p">[</span><span class="n">inst_count</span><span class="p">]:</span>
|
||||
<span class="n">modificacao</span> <span class="o">=</span> <span class="kc">True</span>
|
||||
|
||||
<span class="n">inst_count</span> <span class="o">=</span> <span class="n">inst_count</span> <span class="o">+</span> <span class="mi">1</span>
|
||||
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="n">modificacao</span><span class="p">:</span>
|
||||
<span class="n">it_semmodificacao</span> <span class="o">=</span> <span class="n">it_semmodificacao</span> <span class="o">+</span> <span class="mi">1</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">it_semmodificacao</span> <span class="o">=</span> <span class="mi">0</span>
|
||||
|
||||
<span class="c1"># atualiza cada centroide com base nos valores médios de todas as instâncias à ela associadas</span>
|
||||
<span class="n">grupo_count</span> <span class="o">=</span> <span class="mi">0</span>
|
||||
<span class="k">for</span> <span class="n">grupo</span> <span class="ow">in</span> <span class="n">centroides</span><span class="p">:</span>
|
||||
<span class="n">total_inst</span> <span class="o">=</span> <span class="n">functools</span><span class="o">.</span><span class="n">reduce</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">add</span><span class="p">,</span> <span class="p">[</span><span class="mi">1</span> <span class="k">for</span> <span class="n">xx</span> <span class="ow">in</span> <span class="n">grupos</span> <span class="k">if</span> <span class="n">xx</span> <span class="o">==</span> <span class="n">grupo_count</span><span class="p">],</span> <span class="mi">0</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">total_inst</span> <span class="o">></span> <span class="mi">0</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="n">tam</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span>
|
||||
<span class="k">for</span> <span class="n">count</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">tam</span><span class="p">):</span>
|
||||
<span class="n">soma</span> <span class="o">=</span> <span class="n">functools</span><span class="o">.</span><span class="n">reduce</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">add</span><span class="p">,</span>
|
||||
<span class="p">[</span><span class="n">dados</span><span class="p">[</span><span class="n">kk</span><span class="p">][</span><span class="n">count</span><span class="p">]</span> <span class="k">for</span> <span class="n">kk</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">dados</span><span class="p">))</span> <span class="k">if</span>
|
||||
<span class="n">grupos</span><span class="p">[</span><span class="n">kk</span><span class="p">]</span> <span class="o">==</span> <span class="n">grupo_count</span><span class="p">])</span>
|
||||
<span class="n">centroides</span><span class="p">[</span><span class="n">grupo_count</span><span class="p">][</span><span class="n">count</span><span class="p">]</span> <span class="o">=</span> <span class="n">soma</span> <span class="o">/</span> <span class="n">total_inst</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">soma</span> <span class="o">=</span> <span class="n">functools</span><span class="o">.</span><span class="n">reduce</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">add</span><span class="p">,</span>
|
||||
<span class="p">[</span><span class="n">dados</span><span class="p">[</span><span class="n">kk</span><span class="p">]</span> <span class="k">for</span> <span class="n">kk</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">dados</span><span class="p">))</span> <span class="k">if</span> <span class="n">grupos</span><span class="p">[</span><span class="n">kk</span><span class="p">]</span> <span class="o">==</span> <span class="n">grupo_count</span><span class="p">])</span>
|
||||
<span class="n">centroides</span><span class="p">[</span><span class="n">grupo_count</span><span class="p">]</span> <span class="o">=</span> <span class="n">soma</span> <span class="o">/</span> <span class="n">total_inst</span>
|
||||
<span class="n">grupo_count</span> <span class="o">=</span> <span class="n">grupo_count</span> <span class="o">+</span> <span class="mi">1</span>
|
||||
|
||||
<span class="n">iteracoes</span> <span class="o">=</span> <span class="n">iteracoes</span> <span class="o">+</span> <span class="mi">1</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">centroides</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="CMeansPartitioner"><a class="viewcode-back" href="../../../pyFTS.partitioners.html#pyFTS.partitioners.CMeans.CMeansPartitioner">[docs]</a><span class="k">class</span> <span class="nc">CMeansPartitioner</span><span class="p">(</span><span class="n">partitioner</span><span class="o">.</span><span class="n">Partitioner</span><span class="p">):</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">CMeansPartitioner</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s2">"CMeans"</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
|
||||
<div class="viewcode-block" id="CMeansPartitioner.build"><a class="viewcode-back" href="../../../pyFTS.partitioners.html#pyFTS.partitioners.CMeans.CMeansPartitioner.build">[docs]</a> <span class="k">def</span> <span class="nf">build</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
|
||||
<span class="n">sets</span> <span class="o">=</span> <span class="p">{}</span>
|
||||
|
||||
<span class="n">kwargs</span> <span class="o">=</span> <span class="p">{</span><span class="s1">'type'</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">type</span><span class="p">,</span> <span class="s1">'variable'</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">variable</span><span class="p">}</span>
|
||||
|
||||
<span class="n">centroides</span> <span class="o">=</span> <span class="n">c_means</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">partitions</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
|
||||
<span class="n">centroides</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">max</span><span class="p">)</span>
|
||||
<span class="n">centroides</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">min</span><span class="p">)</span>
|
||||
<span class="n">centroides</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="nb">set</span><span class="p">(</span><span class="n">centroides</span><span class="p">))</span>
|
||||
<span class="n">centroides</span><span class="o">.</span><span class="n">sort</span><span class="p">()</span>
|
||||
<span class="k">for</span> <span class="n">c</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">centroides</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span><span class="p">):</span>
|
||||
<span class="n">_name</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_name</span><span class="p">(</span><span class="n">c</span><span class="p">)</span>
|
||||
<span class="n">sets</span><span class="p">[</span><span class="n">_name</span><span class="p">]</span> <span class="o">=</span> <span class="n">FuzzySet</span><span class="o">.</span><span class="n">FuzzySet</span><span class="p">(</span><span class="n">_name</span><span class="p">,</span> <span class="n">Membership</span><span class="o">.</span><span class="n">trimf</span><span class="p">,</span>
|
||||
<span class="p">[</span><span class="nb">round</span><span class="p">(</span><span class="n">centroides</span><span class="p">[</span><span class="n">c</span> <span class="o">-</span> <span class="mi">1</span><span class="p">],</span> <span class="mi">3</span><span class="p">),</span> <span class="nb">round</span><span class="p">(</span><span class="n">centroides</span><span class="p">[</span><span class="n">c</span><span class="p">],</span> <span class="mi">3</span><span class="p">),</span> <span class="nb">round</span><span class="p">(</span><span class="n">centroides</span><span class="p">[</span><span class="n">c</span> <span class="o">+</span> <span class="mi">1</span><span class="p">],</span> <span class="mi">3</span><span class="p">)],</span>
|
||||
<span class="nb">round</span><span class="p">(</span><span class="n">centroides</span><span class="p">[</span><span class="n">c</span><span class="p">],</span> <span class="mi">3</span><span class="p">),</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">sets</span></div></div>
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../index.html">
|
||||
<img class="logo" src="../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.partitioners.CMeans</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,126 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.partitioners.Class — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../_static/jquery.js"></script>
|
||||
<script src="../../../_static/underscore.js"></script>
|
||||
<script src="../../../_static/doctools.js"></script>
|
||||
<script src="../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.partitioners.Class</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.partitioners.Class</h1><div class="highlight"><pre>
|
||||
<span></span><span class="sd">"""Class Partitioner with Singleton Fuzzy Sets"""</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
<span class="kn">import</span> <span class="nn">math</span>
|
||||
<span class="kn">import</span> <span class="nn">random</span> <span class="k">as</span> <span class="nn">rnd</span>
|
||||
<span class="kn">import</span> <span class="nn">functools</span><span class="o">,</span> <span class="nn">operator</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.common</span> <span class="kn">import</span> <span class="n">FuzzySet</span><span class="p">,</span> <span class="n">Membership</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.partitioners</span> <span class="kn">import</span> <span class="n">partitioner</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="ClassPartitioner"><a class="viewcode-back" href="../../../pyFTS.partitioners.html#pyFTS.partitioners.Class.ClassPartitioner">[docs]</a><span class="k">class</span> <span class="nc">ClassPartitioner</span><span class="p">(</span><span class="n">partitioner</span><span class="o">.</span><span class="n">Partitioner</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""Class Partitioner: Given a dictionary with class/values pairs, create singleton fuzzy sets for each class"""</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Class Partitioner</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">ClassPartitioner</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s2">"Class"</span><span class="p">,</span> <span class="n">preprocess</span> <span class="o">=</span> <span class="kc">False</span><span class="p">)</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">ordered_sets</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">min</span> <span class="o">=</span> <span class="mi">0</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">max</span> <span class="o">=</span> <span class="mi">0</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">partitions</span> <span class="o">=</span> <span class="mi">0</span>
|
||||
|
||||
<span class="n">classes</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"classes"</span><span class="p">,</span> <span class="p">{})</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">k</span><span class="p">,</span><span class="n">v</span> <span class="ow">in</span> <span class="n">classes</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">min</span> <span class="o">=</span> <span class="nb">min</span><span class="p">([</span><span class="bp">self</span><span class="o">.</span><span class="n">min</span><span class="p">,</span> <span class="n">v</span><span class="p">])</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">max</span> <span class="o">=</span> <span class="nb">max</span><span class="p">([</span><span class="bp">self</span><span class="o">.</span><span class="n">max</span><span class="p">,</span> <span class="n">v</span><span class="p">])</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">partitions</span> <span class="o">+=</span> <span class="mi">1</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">=</span> <span class="n">FuzzySet</span><span class="o">.</span><span class="n">FuzzySet</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="n">Membership</span><span class="o">.</span><span class="n">singleton</span><span class="p">,</span> <span class="p">[</span><span class="n">v</span><span class="p">],</span> <span class="n">v</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">ordered_sets</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">k</span><span class="p">)</span>
|
||||
|
||||
<div class="viewcode-block" id="ClassPartitioner.build"><a class="viewcode-back" href="../../../pyFTS.partitioners.html#pyFTS.partitioners.Class.ClassPartitioner.build">[docs]</a> <span class="k">def</span> <span class="nf">build</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span> <span class="p">:</span> <span class="nb">list</span><span class="p">):</span>
|
||||
<span class="k">pass</span></div></div>
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../index.html">
|
||||
<img class="logo" src="../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.partitioners.Class</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,126 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.partitioners.ClassPartitioner — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../_static/jquery.js"></script>
|
||||
<script src="../../../_static/underscore.js"></script>
|
||||
<script src="../../../_static/doctools.js"></script>
|
||||
<script src="../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.partitioners.ClassPartitioner</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.partitioners.ClassPartitioner</h1><div class="highlight"><pre>
|
||||
<span></span><span class="sd">"""Class Partitioner with Singleton Fuzzy Sets"""</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
<span class="kn">import</span> <span class="nn">math</span>
|
||||
<span class="kn">import</span> <span class="nn">random</span> <span class="k">as</span> <span class="nn">rnd</span>
|
||||
<span class="kn">import</span> <span class="nn">functools</span><span class="o">,</span> <span class="nn">operator</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.common</span> <span class="kn">import</span> <span class="n">FuzzySet</span><span class="p">,</span> <span class="n">Membership</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.partitioners</span> <span class="kn">import</span> <span class="n">partitioner</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="ClassPartitioner"><a class="viewcode-back" href="../../../pyFTS.partitioners.html#pyFTS.partitioners.ClassPartitioner.ClassPartitioner">[docs]</a><span class="k">class</span> <span class="nc">ClassPartitioner</span><span class="p">(</span><span class="n">partitioner</span><span class="o">.</span><span class="n">Partitioner</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""Class Partitioner: Given a dictionary with class/values pairs, create singleton fuzzy sets for each class"""</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Class Partitioner</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">ClassPartitioner</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s2">"Class"</span><span class="p">,</span> <span class="n">preprocess</span> <span class="o">=</span> <span class="kc">False</span><span class="p">)</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">ordered_sets</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">min</span> <span class="o">=</span> <span class="mi">0</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">max</span> <span class="o">=</span> <span class="mi">0</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">partitions</span> <span class="o">=</span> <span class="mi">0</span>
|
||||
|
||||
<span class="n">classes</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"classes"</span><span class="p">,</span> <span class="p">{})</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">k</span><span class="p">,</span><span class="n">v</span> <span class="ow">in</span> <span class="n">classes</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">min</span> <span class="o">=</span> <span class="nb">min</span><span class="p">([</span><span class="bp">self</span><span class="o">.</span><span class="n">min</span><span class="p">,</span> <span class="n">v</span><span class="p">])</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">max</span> <span class="o">=</span> <span class="nb">max</span><span class="p">([</span><span class="bp">self</span><span class="o">.</span><span class="n">max</span><span class="p">,</span> <span class="n">v</span><span class="p">])</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">partitions</span> <span class="o">+=</span> <span class="mi">1</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">=</span> <span class="n">FuzzySet</span><span class="o">.</span><span class="n">FuzzySet</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="n">Membership</span><span class="o">.</span><span class="n">singleton</span><span class="p">,</span> <span class="p">[</span><span class="n">v</span><span class="p">],</span> <span class="n">v</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">ordered_sets</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">k</span><span class="p">)</span>
|
||||
|
||||
<div class="viewcode-block" id="ClassPartitioner.build"><a class="viewcode-back" href="../../../pyFTS.partitioners.html#pyFTS.partitioners.ClassPartitioner.ClassPartitioner.build">[docs]</a> <span class="k">def</span> <span class="nf">build</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span> <span class="p">:</span> <span class="nb">list</span><span class="p">):</span>
|
||||
<span class="k">pass</span></div></div>
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../index.html">
|
||||
<img class="logo" src="../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.partitioners.ClassPartitioner</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,200 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.partitioners.Entropy — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../_static/jquery.js"></script>
|
||||
<script src="../../../_static/underscore.js"></script>
|
||||
<script src="../../../_static/doctools.js"></script>
|
||||
<script src="../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.partitioners.Entropy</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.partitioners.Entropy</h1><div class="highlight"><pre>
|
||||
<span></span><span class="sd">"""</span>
|
||||
<span class="sd">C. H. Cheng, R. J. Chang, and C. A. Yeh, “Entropy-based and trapezoidal fuzzification-based fuzzy time series approach for forecasting IT project cost,”</span>
|
||||
<span class="sd">Technol. Forecast. Social Change, vol. 73, no. 5, pp. 524–542, Jun. 2006.</span>
|
||||
<span class="sd">"""</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
<span class="kn">import</span> <span class="nn">math</span>
|
||||
<span class="kn">import</span> <span class="nn">random</span> <span class="k">as</span> <span class="nn">rnd</span>
|
||||
<span class="kn">import</span> <span class="nn">functools</span><span class="o">,</span> <span class="nn">operator</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.common</span> <span class="kn">import</span> <span class="n">FuzzySet</span><span class="p">,</span> <span class="n">Membership</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.partitioners</span> <span class="kn">import</span> <span class="n">partitioner</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="splitBelow"><a class="viewcode-back" href="../../../pyFTS.partitioners.html#pyFTS.partitioners.Entropy.splitBelow">[docs]</a><span class="k">def</span> <span class="nf">splitBelow</span><span class="p">(</span><span class="n">data</span><span class="p">,</span><span class="n">threshold</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="p">[</span><span class="n">k</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">data</span> <span class="k">if</span> <span class="n">k</span> <span class="o"><=</span> <span class="n">threshold</span><span class="p">]</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="splitAbove"><a class="viewcode-back" href="../../../pyFTS.partitioners.html#pyFTS.partitioners.Entropy.splitAbove">[docs]</a><span class="k">def</span> <span class="nf">splitAbove</span><span class="p">(</span><span class="n">data</span><span class="p">,</span><span class="n">threshold</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="p">[</span><span class="n">k</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">data</span> <span class="k">if</span> <span class="n">k</span> <span class="o">></span> <span class="n">threshold</span><span class="p">]</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="PMF"><a class="viewcode-back" href="../../../pyFTS.partitioners.html#pyFTS.partitioners.Entropy.PMF">[docs]</a><span class="k">def</span> <span class="nf">PMF</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">threshold</span><span class="p">):</span>
|
||||
<span class="n">a</span> <span class="o">=</span> <span class="nb">sum</span><span class="p">([</span><span class="mf">1.0</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">splitBelow</span><span class="p">(</span><span class="n">data</span><span class="p">,</span><span class="n">threshold</span><span class="p">)])</span>
|
||||
<span class="n">b</span> <span class="o">=</span> <span class="nb">sum</span><span class="p">([</span><span class="mf">1.0</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">splitAbove</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">threshold</span><span class="p">)])</span>
|
||||
<span class="n">l</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="p">[</span><span class="n">a</span> <span class="o">/</span> <span class="n">l</span><span class="p">,</span> <span class="n">b</span> <span class="o">/</span> <span class="n">l</span><span class="p">]</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="entropy"><a class="viewcode-back" href="../../../pyFTS.partitioners.html#pyFTS.partitioners.Entropy.entropy">[docs]</a><span class="k">def</span> <span class="nf">entropy</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">threshold</span><span class="p">):</span>
|
||||
<span class="n">pmf</span> <span class="o">=</span> <span class="n">PMF</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">threshold</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">pmf</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="mi">0</span> <span class="ow">or</span> <span class="n">pmf</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="mi">1</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="o">-</span> <span class="nb">sum</span><span class="p">([</span><span class="n">pmf</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">*</span> <span class="n">math</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">pmf</span><span class="p">[</span><span class="mi">0</span><span class="p">]),</span> <span class="n">pmf</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">*</span> <span class="n">math</span><span class="o">.</span><span class="n">log</span><span class="p">(</span><span class="n">pmf</span><span class="p">[</span><span class="mi">1</span><span class="p">])])</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="informationGain"><a class="viewcode-back" href="../../../pyFTS.partitioners.html#pyFTS.partitioners.Entropy.informationGain">[docs]</a><span class="k">def</span> <span class="nf">informationGain</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">thres1</span><span class="p">,</span> <span class="n">thres2</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="n">entropy</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">thres1</span><span class="p">)</span> <span class="o">-</span> <span class="n">entropy</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">thres2</span><span class="p">)</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="bestSplit"><a class="viewcode-back" href="../../../pyFTS.partitioners.html#pyFTS.partitioners.Entropy.bestSplit">[docs]</a><span class="k">def</span> <span class="nf">bestSplit</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">npart</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">)</span> <span class="o"><</span> <span class="mi">2</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="p">[]</span>
|
||||
<span class="n">count</span> <span class="o">=</span> <span class="mi">1</span>
|
||||
<span class="n">ndata</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="nb">set</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">data</span><span class="p">)</span><span class="o">.</span><span class="n">flatten</span><span class="p">()))</span>
|
||||
<span class="n">ndata</span><span class="o">.</span><span class="n">sort</span><span class="p">()</span>
|
||||
<span class="n">l</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">ndata</span><span class="p">)</span>
|
||||
<span class="n">threshold</span> <span class="o">=</span> <span class="mi">0</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="k">while</span> <span class="n">count</span> <span class="o"><</span> <span class="n">l</span> <span class="ow">and</span> <span class="n">informationGain</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">ndata</span><span class="p">[</span><span class="n">count</span> <span class="o">-</span> <span class="mi">1</span><span class="p">],</span> <span class="n">ndata</span><span class="p">[</span><span class="n">count</span><span class="p">])</span> <span class="o"><=</span> <span class="mi">0</span><span class="p">:</span>
|
||||
<span class="n">threshold</span> <span class="o">=</span> <span class="n">ndata</span><span class="p">[</span><span class="n">count</span><span class="p">]</span>
|
||||
<span class="n">count</span> <span class="o">+=</span> <span class="mi">1</span>
|
||||
<span class="k">except</span> <span class="ne">IndexError</span><span class="p">:</span>
|
||||
<span class="nb">print</span><span class="p">(</span><span class="n">threshold</span><span class="p">)</span>
|
||||
<span class="nb">print</span> <span class="p">(</span><span class="n">ndata</span><span class="p">)</span>
|
||||
<span class="nb">print</span> <span class="p">(</span><span class="n">count</span><span class="p">)</span>
|
||||
|
||||
<span class="n">rem</span> <span class="o">=</span> <span class="n">npart</span> <span class="o">%</span> <span class="mi">2</span>
|
||||
|
||||
<span class="k">if</span> <span class="p">(</span><span class="n">npart</span> <span class="o">-</span> <span class="n">rem</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span>
|
||||
<span class="n">p1</span> <span class="o">=</span> <span class="n">splitBelow</span><span class="p">(</span><span class="n">data</span><span class="p">,</span><span class="n">threshold</span><span class="p">)</span>
|
||||
<span class="n">p2</span> <span class="o">=</span> <span class="n">splitAbove</span><span class="p">(</span><span class="n">data</span><span class="p">,</span><span class="n">threshold</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">p1</span><span class="p">)</span> <span class="o">></span> <span class="nb">len</span><span class="p">(</span><span class="n">p2</span><span class="p">):</span>
|
||||
<span class="n">np1</span> <span class="o">=</span> <span class="p">(</span><span class="n">npart</span> <span class="o">-</span> <span class="n">rem</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span> <span class="o">+</span> <span class="n">rem</span>
|
||||
<span class="n">np2</span> <span class="o">=</span> <span class="p">(</span><span class="n">npart</span> <span class="o">-</span> <span class="n">rem</span><span class="p">)</span><span class="o">/</span><span class="mi">2</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">np1</span> <span class="o">=</span> <span class="p">(</span><span class="n">npart</span> <span class="o">-</span> <span class="n">rem</span><span class="p">)</span> <span class="o">/</span> <span class="mi">2</span>
|
||||
<span class="n">np2</span> <span class="o">=</span> <span class="p">(</span><span class="n">npart</span> <span class="o">-</span> <span class="n">rem</span><span class="p">)</span> <span class="o">/</span> <span class="mi">2</span> <span class="o">+</span> <span class="n">rem</span>
|
||||
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="p">[</span><span class="n">threshold</span><span class="p">]</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">bestSplit</span><span class="p">(</span><span class="n">p1</span><span class="p">,</span> <span class="n">np1</span> <span class="p">):</span> <span class="n">tmp</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">k</span><span class="p">)</span>
|
||||
<span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">bestSplit</span><span class="p">(</span><span class="n">p2</span><span class="p">,</span> <span class="n">np2</span> <span class="p">):</span> <span class="n">tmp</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">k</span><span class="p">)</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">tmp</span>
|
||||
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="p">[</span><span class="n">threshold</span><span class="p">]</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="EntropyPartitioner"><a class="viewcode-back" href="../../../pyFTS.partitioners.html#pyFTS.partitioners.Entropy.EntropyPartitioner">[docs]</a><span class="k">class</span> <span class="nc">EntropyPartitioner</span><span class="p">(</span><span class="n">partitioner</span><span class="o">.</span><span class="n">Partitioner</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""Huarng Entropy Partitioner"""</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">EntropyPartitioner</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s2">"Entropy"</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
|
||||
<div class="viewcode-block" id="EntropyPartitioner.build"><a class="viewcode-back" href="../../../pyFTS.partitioners.html#pyFTS.partitioners.Entropy.EntropyPartitioner.build">[docs]</a> <span class="k">def</span> <span class="nf">build</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
|
||||
<span class="n">sets</span> <span class="o">=</span> <span class="p">{}</span>
|
||||
|
||||
<span class="n">kwargs</span> <span class="o">=</span> <span class="p">{</span><span class="s1">'type'</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">type</span><span class="p">,</span> <span class="s1">'variable'</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">variable</span><span class="p">}</span>
|
||||
|
||||
<span class="n">partitions</span> <span class="o">=</span> <span class="n">bestSplit</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">partitions</span><span class="p">)</span>
|
||||
<span class="n">partitions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">min</span><span class="p">)</span>
|
||||
<span class="n">partitions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">max</span><span class="p">)</span>
|
||||
<span class="n">partitions</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="nb">set</span><span class="p">(</span><span class="n">partitions</span><span class="p">))</span>
|
||||
<span class="n">partitions</span><span class="o">.</span><span class="n">sort</span><span class="p">()</span>
|
||||
<span class="k">for</span> <span class="n">c</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">partitions</span><span class="p">)</span><span class="o">-</span><span class="mi">1</span><span class="p">):</span>
|
||||
<span class="n">_name</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_name</span><span class="p">(</span><span class="n">c</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">membership_function</span> <span class="o">==</span> <span class="n">Membership</span><span class="o">.</span><span class="n">trimf</span><span class="p">:</span>
|
||||
<span class="n">sets</span><span class="p">[</span><span class="n">_name</span><span class="p">]</span> <span class="o">=</span> <span class="n">FuzzySet</span><span class="o">.</span><span class="n">FuzzySet</span><span class="p">(</span><span class="n">_name</span><span class="p">,</span> <span class="n">Membership</span><span class="o">.</span><span class="n">trimf</span><span class="p">,</span>
|
||||
<span class="p">[</span><span class="n">partitions</span><span class="p">[</span><span class="n">c</span> <span class="o">-</span> <span class="mi">1</span><span class="p">],</span> <span class="n">partitions</span><span class="p">[</span><span class="n">c</span><span class="p">],</span> <span class="n">partitions</span><span class="p">[</span><span class="n">c</span> <span class="o">+</span> <span class="mi">1</span><span class="p">]],</span><span class="n">partitions</span><span class="p">[</span><span class="n">c</span><span class="p">],</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">membership_function</span> <span class="o">==</span> <span class="n">Membership</span><span class="o">.</span><span class="n">trapmf</span><span class="p">:</span>
|
||||
<span class="n">b1</span> <span class="o">=</span> <span class="p">(</span><span class="n">partitions</span><span class="p">[</span><span class="n">c</span><span class="p">]</span> <span class="o">-</span> <span class="n">partitions</span><span class="p">[</span><span class="n">c</span> <span class="o">-</span> <span class="mi">1</span><span class="p">])</span><span class="o">/</span><span class="mi">2</span>
|
||||
<span class="n">b2</span> <span class="o">=</span> <span class="p">(</span><span class="n">partitions</span><span class="p">[</span><span class="n">c</span> <span class="o">+</span> <span class="mi">1</span><span class="p">]</span> <span class="o">-</span> <span class="n">partitions</span><span class="p">[</span><span class="n">c</span><span class="p">])</span> <span class="o">/</span> <span class="mi">2</span>
|
||||
<span class="n">sets</span><span class="p">[</span><span class="n">_name</span><span class="p">]</span> <span class="o">=</span> <span class="n">FuzzySet</span><span class="o">.</span><span class="n">FuzzySet</span><span class="p">(</span><span class="n">_name</span><span class="p">,</span> <span class="n">Membership</span><span class="o">.</span><span class="n">trapmf</span><span class="p">,</span>
|
||||
<span class="p">[</span><span class="n">partitions</span><span class="p">[</span><span class="n">c</span> <span class="o">-</span> <span class="mi">1</span><span class="p">],</span> <span class="n">partitions</span><span class="p">[</span><span class="n">c</span><span class="p">]</span> <span class="o">-</span> <span class="n">b1</span><span class="p">,</span>
|
||||
<span class="n">partitions</span><span class="p">[</span><span class="n">c</span><span class="p">]</span> <span class="o">+</span> <span class="n">b2</span><span class="p">,</span> <span class="n">partitions</span><span class="p">[</span><span class="n">c</span> <span class="o">+</span> <span class="mi">1</span><span class="p">]],</span>
|
||||
<span class="n">partitions</span><span class="p">[</span><span class="n">c</span><span class="p">],</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">sets</span></div></div>
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../index.html">
|
||||
<img class="logo" src="../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.partitioners.Entropy</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
216
docs/build/html/_modules/pyFTS/partitioners/FCM.html
vendored
216
docs/build/html/_modules/pyFTS/partitioners/FCM.html
vendored
@ -1,216 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.partitioners.FCM — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../_static/jquery.js"></script>
|
||||
<script src="../../../_static/underscore.js"></script>
|
||||
<script src="../../../_static/doctools.js"></script>
|
||||
<script src="../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.partitioners.FCM</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.partitioners.FCM</h1><div class="highlight"><pre>
|
||||
<span></span><span class="sd">"""</span>
|
||||
<span class="sd">S. T. Li, Y. C. Cheng, and S. Y. Lin, “A FCM-based deterministic forecasting model for fuzzy time series,”</span>
|
||||
<span class="sd">Comput. Math. Appl., vol. 56, no. 12, pp. 3052–3063, Dec. 2008. DOI: 10.1016/j.camwa.2008.07.033.</span>
|
||||
<span class="sd">"""</span>
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
<span class="kn">import</span> <span class="nn">pandas</span> <span class="k">as</span> <span class="nn">pd</span>
|
||||
<span class="kn">import</span> <span class="nn">math</span>
|
||||
<span class="kn">import</span> <span class="nn">random</span> <span class="k">as</span> <span class="nn">rnd</span>
|
||||
<span class="kn">import</span> <span class="nn">functools</span><span class="o">,</span> <span class="nn">operator</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.common</span> <span class="kn">import</span> <span class="n">FuzzySet</span><span class="p">,</span> <span class="n">Membership</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.partitioners</span> <span class="kn">import</span> <span class="n">partitioner</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="fuzzy_distance"><a class="viewcode-back" href="../../../pyFTS.partitioners.html#pyFTS.partitioners.FCM.fuzzy_distance">[docs]</a><span class="k">def</span> <span class="nf">fuzzy_distance</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="p">(</span><span class="nb">list</span><span class="p">,</span> <span class="nb">tuple</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">)):</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="n">functools</span><span class="o">.</span><span class="n">reduce</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">add</span><span class="p">,</span> <span class="p">[(</span><span class="n">x</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="o">-</span> <span class="n">y</span><span class="p">[</span><span class="n">k</span><span class="p">])</span> <span class="o">**</span> <span class="mi">2</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">x</span><span class="p">))])</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="p">(</span><span class="n">x</span> <span class="o">-</span> <span class="n">y</span><span class="p">)</span> <span class="o">**</span> <span class="mi">2</span>
|
||||
<span class="k">return</span> <span class="n">math</span><span class="o">.</span><span class="n">sqrt</span><span class="p">(</span><span class="n">tmp</span><span class="p">)</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="membership"><a class="viewcode-back" href="../../../pyFTS.partitioners.html#pyFTS.partitioners.FCM.membership">[docs]</a><span class="k">def</span> <span class="nf">membership</span><span class="p">(</span><span class="n">val</span><span class="p">,</span> <span class="n">vals</span><span class="p">):</span>
|
||||
<span class="n">soma</span> <span class="o">=</span> <span class="mi">0</span>
|
||||
<span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">vals</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="n">k</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
|
||||
<span class="n">k</span> <span class="o">=</span> <span class="mi">1</span>
|
||||
<span class="n">soma</span> <span class="o">=</span> <span class="n">soma</span> <span class="o">+</span> <span class="p">(</span><span class="n">val</span> <span class="o">/</span> <span class="n">k</span><span class="p">)</span> <span class="o">**</span> <span class="mi">2</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">soma</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="fuzzy_cmeans"><a class="viewcode-back" href="../../../pyFTS.partitioners.html#pyFTS.partitioners.FCM.fuzzy_cmeans">[docs]</a><span class="k">def</span> <span class="nf">fuzzy_cmeans</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">size</span><span class="p">,</span> <span class="n">m</span><span class="p">,</span> <span class="n">deltadist</span><span class="o">=</span><span class="mf">0.001</span><span class="p">):</span>
|
||||
<span class="n">data_length</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
|
||||
|
||||
<span class="c1"># Centroid initialization</span>
|
||||
<span class="n">centroids</span> <span class="o">=</span> <span class="p">[</span><span class="n">data</span><span class="p">[</span><span class="n">rnd</span><span class="o">.</span><span class="n">randint</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">data_length</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)]</span> <span class="k">for</span> <span class="n">kk</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">k</span><span class="p">)]</span>
|
||||
|
||||
<span class="c1"># Membership table</span>
|
||||
<span class="n">membership_table</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">((</span><span class="n">k</span><span class="p">,</span> <span class="n">data_length</span><span class="p">))</span> <span class="c1">#[[0 for kk in range(0, k)] for xx in range(0, data_length)]</span>
|
||||
|
||||
<span class="n">mean_change</span> <span class="o">=</span> <span class="mi">1000</span>
|
||||
|
||||
<span class="n">m_exp</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">/</span> <span class="p">(</span><span class="n">m</span> <span class="o">-</span> <span class="mi">1</span><span class="p">)</span>
|
||||
|
||||
<span class="n">iterations</span> <span class="o">=</span> <span class="mi">0</span>
|
||||
|
||||
<span class="k">while</span> <span class="n">iterations</span> <span class="o"><</span> <span class="mi">1000</span> <span class="ow">and</span> <span class="n">mean_change</span> <span class="o">></span> <span class="n">deltadist</span><span class="p">:</span>
|
||||
|
||||
<span class="n">mean_change</span> <span class="o">=</span> <span class="mi">0</span>
|
||||
<span class="n">inst_count</span> <span class="o">=</span> <span class="mi">0</span>
|
||||
<span class="k">for</span> <span class="n">instance</span> <span class="ow">in</span> <span class="n">data</span><span class="p">:</span>
|
||||
|
||||
<span class="n">dist_groups</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">k</span><span class="p">)</span> <span class="c1">#[0 for xx in range(0, k)]</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">group_count</span><span class="p">,</span> <span class="n">group</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">centroids</span><span class="p">):</span>
|
||||
<span class="n">dist_groups</span><span class="p">[</span><span class="n">group_count</span><span class="p">]</span> <span class="o">=</span> <span class="n">fuzzy_distance</span><span class="p">(</span><span class="n">group</span><span class="p">,</span> <span class="n">instance</span><span class="p">)</span>
|
||||
|
||||
<span class="n">dist_groups_total</span> <span class="o">=</span> <span class="n">functools</span><span class="o">.</span><span class="n">reduce</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">add</span><span class="p">,</span> <span class="p">[</span><span class="n">xk</span> <span class="k">for</span> <span class="n">xk</span> <span class="ow">in</span> <span class="n">dist_groups</span><span class="p">])</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">grp</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">k</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="n">dist_groups</span><span class="p">[</span><span class="n">grp</span><span class="p">]</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
|
||||
<span class="n">membership_table</span><span class="p">[</span><span class="n">inst_count</span><span class="p">][</span><span class="n">grp</span><span class="p">]</span> <span class="o">=</span> <span class="mi">1</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">membership_table</span><span class="p">[</span><span class="n">inst_count</span><span class="p">][</span><span class="n">grp</span><span class="p">]</span> <span class="o">=</span> <span class="mi">1</span> <span class="o">/</span> <span class="n">membership</span><span class="p">(</span><span class="n">dist_groups</span><span class="p">[</span><span class="n">grp</span><span class="p">],</span> <span class="n">dist_groups</span><span class="p">)</span>
|
||||
<span class="c1"># membership_table[inst_count][grp] = 1/(dist_groups[grp] / dist_grupos_total)</span>
|
||||
<span class="c1"># membership_table[inst_count][grp] = (1/(dist_groups[grp]**2))**m_exp / (1/(dist_grupos_total**2))**m_exp</span>
|
||||
|
||||
<span class="n">inst_count</span> <span class="o">=</span> <span class="n">inst_count</span> <span class="o">+</span> <span class="mi">1</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">group_count</span><span class="p">,</span> <span class="n">group</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">centroids</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="n">size</span> <span class="o">></span> <span class="mi">1</span><span class="p">:</span>
|
||||
<span class="n">oldgrp</span> <span class="o">=</span> <span class="p">[</span><span class="n">xx</span> <span class="k">for</span> <span class="n">xx</span> <span class="ow">in</span> <span class="n">group</span><span class="p">]</span>
|
||||
<span class="k">for</span> <span class="n">atr</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">size</span><span class="p">):</span>
|
||||
<span class="n">soma</span> <span class="o">=</span> <span class="n">functools</span><span class="o">.</span><span class="n">reduce</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">add</span><span class="p">,</span>
|
||||
<span class="p">[</span><span class="n">membership_table</span><span class="p">[</span><span class="n">xk</span><span class="p">][</span><span class="n">group_count</span><span class="p">]</span> <span class="o">*</span> <span class="n">data</span><span class="p">[</span><span class="n">xk</span><span class="p">][</span><span class="n">atr</span><span class="p">]</span> <span class="k">for</span> <span class="n">xk</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">data_length</span><span class="p">)])</span>
|
||||
<span class="n">norm</span> <span class="o">=</span> <span class="n">functools</span><span class="o">.</span><span class="n">reduce</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">add</span><span class="p">,</span> <span class="p">[</span><span class="n">membership_table</span><span class="p">[</span><span class="n">xk</span><span class="p">][</span><span class="n">group_count</span><span class="p">]</span> <span class="k">for</span> <span class="n">xk</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">data_length</span><span class="p">)])</span>
|
||||
<span class="n">centroids</span><span class="p">[</span><span class="n">group_count</span><span class="p">][</span><span class="n">atr</span><span class="p">]</span> <span class="o">=</span> <span class="n">soma</span> <span class="o">/</span> <span class="n">norm</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">oldgrp</span> <span class="o">=</span> <span class="n">group</span>
|
||||
<span class="n">soma</span> <span class="o">=</span> <span class="n">functools</span><span class="o">.</span><span class="n">reduce</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">add</span><span class="p">,</span>
|
||||
<span class="p">[</span><span class="n">membership_table</span><span class="p">[</span><span class="n">xk</span><span class="p">][</span><span class="n">group_count</span><span class="p">]</span> <span class="o">*</span> <span class="n">data</span><span class="p">[</span><span class="n">xk</span><span class="p">]</span> <span class="k">for</span> <span class="n">xk</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">data_length</span><span class="p">)])</span>
|
||||
<span class="n">norm</span> <span class="o">=</span> <span class="n">functools</span><span class="o">.</span><span class="n">reduce</span><span class="p">(</span><span class="n">operator</span><span class="o">.</span><span class="n">add</span><span class="p">,</span> <span class="p">[</span><span class="n">membership_table</span><span class="p">[</span><span class="n">xk</span><span class="p">][</span><span class="n">group_count</span><span class="p">]</span> <span class="k">for</span> <span class="n">xk</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">data_length</span><span class="p">)])</span>
|
||||
<span class="n">centroids</span><span class="p">[</span><span class="n">group_count</span><span class="p">]</span> <span class="o">=</span> <span class="n">soma</span> <span class="o">/</span> <span class="n">norm</span>
|
||||
|
||||
<span class="n">mean_change</span> <span class="o">=</span> <span class="n">mean_change</span> <span class="o">+</span> <span class="n">fuzzy_distance</span><span class="p">(</span><span class="n">oldgrp</span><span class="p">,</span> <span class="n">group</span><span class="p">)</span>
|
||||
|
||||
<span class="n">mean_change</span> <span class="o">=</span> <span class="n">mean_change</span> <span class="o">/</span> <span class="n">k</span>
|
||||
<span class="n">iterations</span> <span class="o">=</span> <span class="n">iterations</span> <span class="o">+</span> <span class="mi">1</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">centroids</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="FCMPartitioner"><a class="viewcode-back" href="../../../pyFTS.partitioners.html#pyFTS.partitioners.FCM.FCMPartitioner">[docs]</a><span class="k">class</span> <span class="nc">FCMPartitioner</span><span class="p">(</span><span class="n">partitioner</span><span class="o">.</span><span class="n">Partitioner</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> </span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">FCMPartitioner</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s2">"FCM"</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
|
||||
<div class="viewcode-block" id="FCMPartitioner.build"><a class="viewcode-back" href="../../../pyFTS.partitioners.html#pyFTS.partitioners.FCM.FCMPartitioner.build">[docs]</a> <span class="k">def</span> <span class="nf">build</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
|
||||
<span class="n">sets</span> <span class="o">=</span> <span class="p">{}</span>
|
||||
|
||||
<span class="n">kwargs</span> <span class="o">=</span> <span class="p">{</span><span class="s1">'type'</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">type</span><span class="p">,</span> <span class="s1">'variable'</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">variable</span><span class="p">}</span>
|
||||
|
||||
<span class="n">centroids</span> <span class="o">=</span> <span class="n">fuzzy_cmeans</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">partitions</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">)</span>
|
||||
<span class="n">centroids</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">max</span><span class="p">)</span>
|
||||
<span class="n">centroids</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">min</span><span class="p">)</span>
|
||||
<span class="n">centroids</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="nb">set</span><span class="p">(</span><span class="n">centroids</span><span class="p">))</span>
|
||||
<span class="n">centroids</span><span class="o">.</span><span class="n">sort</span><span class="p">()</span>
|
||||
<span class="k">for</span> <span class="n">c</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">centroids</span><span class="p">)</span> <span class="o">-</span> <span class="mi">1</span><span class="p">):</span>
|
||||
<span class="n">_name</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_name</span><span class="p">(</span><span class="n">c</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">membership_function</span> <span class="o">==</span> <span class="n">Membership</span><span class="o">.</span><span class="n">trimf</span><span class="p">:</span>
|
||||
<span class="n">sets</span><span class="p">[</span><span class="n">_name</span><span class="p">]</span> <span class="o">=</span> <span class="n">FuzzySet</span><span class="o">.</span><span class="n">FuzzySet</span><span class="p">(</span><span class="n">_name</span><span class="p">,</span> <span class="n">Membership</span><span class="o">.</span><span class="n">trimf</span><span class="p">,</span>
|
||||
<span class="p">[</span><span class="nb">round</span><span class="p">(</span><span class="n">centroids</span><span class="p">[</span><span class="n">c</span> <span class="o">-</span> <span class="mi">1</span><span class="p">],</span> <span class="mi">3</span><span class="p">),</span> <span class="nb">round</span><span class="p">(</span><span class="n">centroids</span><span class="p">[</span><span class="n">c</span><span class="p">],</span> <span class="mi">3</span><span class="p">),</span>
|
||||
<span class="nb">round</span><span class="p">(</span><span class="n">centroids</span><span class="p">[</span><span class="n">c</span> <span class="o">+</span> <span class="mi">1</span><span class="p">],</span> <span class="mi">3</span><span class="p">)],</span>
|
||||
<span class="nb">round</span><span class="p">(</span><span class="n">centroids</span><span class="p">[</span><span class="n">c</span><span class="p">],</span> <span class="mi">3</span><span class="p">),</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">membership_function</span> <span class="o">==</span> <span class="n">Membership</span><span class="o">.</span><span class="n">trapmf</span><span class="p">:</span>
|
||||
<span class="n">q1</span> <span class="o">=</span> <span class="p">(</span><span class="nb">round</span><span class="p">(</span><span class="n">centroids</span><span class="p">[</span><span class="n">c</span><span class="p">],</span> <span class="mi">3</span><span class="p">)</span> <span class="o">-</span> <span class="nb">round</span><span class="p">(</span><span class="n">centroids</span><span class="p">[</span><span class="n">c</span> <span class="o">-</span> <span class="mi">1</span><span class="p">],</span> <span class="mi">3</span><span class="p">))</span> <span class="o">/</span> <span class="mi">2</span>
|
||||
<span class="n">q2</span> <span class="o">=</span> <span class="p">(</span><span class="nb">round</span><span class="p">(</span><span class="n">centroids</span><span class="p">[</span><span class="n">c</span> <span class="o">+</span> <span class="mi">1</span><span class="p">],</span> <span class="mi">3</span><span class="p">)</span> <span class="o">-</span> <span class="nb">round</span><span class="p">(</span><span class="n">centroids</span><span class="p">[</span><span class="n">c</span><span class="p">],</span> <span class="mi">3</span><span class="p">))</span> <span class="o">/</span> <span class="mi">2</span>
|
||||
<span class="n">sets</span><span class="p">[</span><span class="n">_name</span><span class="p">]</span> <span class="o">=</span> <span class="n">FuzzySet</span><span class="o">.</span><span class="n">FuzzySet</span><span class="p">(</span><span class="n">_name</span><span class="p">,</span> <span class="n">Membership</span><span class="o">.</span><span class="n">trimf</span><span class="p">,</span>
|
||||
<span class="p">[</span><span class="nb">round</span><span class="p">(</span><span class="n">centroids</span><span class="p">[</span><span class="n">c</span> <span class="o">-</span> <span class="mi">1</span><span class="p">],</span> <span class="mi">3</span><span class="p">),</span> <span class="nb">round</span><span class="p">(</span><span class="n">centroids</span><span class="p">[</span><span class="n">c</span><span class="p">],</span> <span class="mi">3</span><span class="p">)</span> <span class="o">-</span> <span class="n">q1</span><span class="p">,</span>
|
||||
<span class="nb">round</span><span class="p">(</span><span class="n">centroids</span><span class="p">[</span><span class="n">c</span><span class="p">],</span> <span class="mi">3</span><span class="p">)</span> <span class="o">+</span> <span class="n">q2</span><span class="p">,</span> <span class="nb">round</span><span class="p">(</span><span class="n">centroids</span><span class="p">[</span><span class="n">c</span> <span class="o">+</span> <span class="mi">1</span><span class="p">],</span> <span class="mi">3</span><span class="p">)],</span>
|
||||
<span class="nb">round</span><span class="p">(</span><span class="n">centroids</span><span class="p">[</span><span class="n">c</span><span class="p">],</span> <span class="mi">3</span><span class="p">),</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">sets</span></div></div>
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../index.html">
|
||||
<img class="logo" src="../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.partitioners.FCM</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,166 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.partitioners.Grid — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../_static/jquery.js"></script>
|
||||
<script src="../../../_static/underscore.js"></script>
|
||||
<script src="../../../_static/doctools.js"></script>
|
||||
<script src="../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.partitioners.Grid</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.partitioners.Grid</h1><div class="highlight"><pre>
|
||||
<span></span><span class="sd">"""Even Length Grid Partitioner"""</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
<span class="kn">import</span> <span class="nn">math</span>
|
||||
<span class="kn">import</span> <span class="nn">random</span> <span class="k">as</span> <span class="nn">rnd</span>
|
||||
<span class="kn">import</span> <span class="nn">functools</span><span class="o">,</span> <span class="nn">operator</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.common</span> <span class="kn">import</span> <span class="n">FuzzySet</span><span class="p">,</span> <span class="n">Membership</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.partitioners</span> <span class="kn">import</span> <span class="n">partitioner</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="GridPartitioner"><a class="viewcode-back" href="../../../pyFTS.partitioners.html#pyFTS.partitioners.Grid.GridPartitioner">[docs]</a><span class="k">class</span> <span class="nc">GridPartitioner</span><span class="p">(</span><span class="n">partitioner</span><span class="o">.</span><span class="n">Partitioner</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""Even Length Grid Partitioner"""</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Even Length Grid Partitioner</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">GridPartitioner</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s2">"Grid"</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
|
||||
<div class="viewcode-block" id="GridPartitioner.build"><a class="viewcode-back" href="../../../pyFTS.partitioners.html#pyFTS.partitioners.Grid.GridPartitioner.build">[docs]</a> <span class="k">def</span> <span class="nf">build</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
|
||||
<span class="n">sets</span> <span class="o">=</span> <span class="p">{}</span>
|
||||
|
||||
<span class="n">kwargs</span> <span class="o">=</span> <span class="p">{</span><span class="s1">'type'</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">type</span><span class="p">,</span> <span class="s1">'variable'</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">variable</span><span class="p">}</span>
|
||||
|
||||
<span class="c1">#dlen = self.max - self.min</span>
|
||||
<span class="c1">#partlen = dlen / self.partitions</span>
|
||||
|
||||
<span class="n">count</span> <span class="o">=</span> <span class="mi">0</span>
|
||||
<span class="n">centers</span><span class="p">,</span> <span class="n">partlen</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">linspace</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">min</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">max</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">partitions</span><span class="p">,</span> <span class="n">retstep</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
|
||||
<span class="k">for</span> <span class="n">c</span> <span class="ow">in</span> <span class="n">centers</span><span class="p">:</span>
|
||||
<span class="n">_name</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_name</span><span class="p">(</span><span class="n">count</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">membership_function</span> <span class="o">==</span> <span class="n">Membership</span><span class="o">.</span><span class="n">trimf</span><span class="p">:</span>
|
||||
<span class="n">sets</span><span class="p">[</span><span class="n">_name</span><span class="p">]</span> <span class="o">=</span> <span class="n">FuzzySet</span><span class="o">.</span><span class="n">FuzzySet</span><span class="p">(</span><span class="n">_name</span><span class="p">,</span> <span class="n">Membership</span><span class="o">.</span><span class="n">trimf</span><span class="p">,</span> <span class="p">[</span><span class="n">c</span> <span class="o">-</span> <span class="n">partlen</span><span class="p">,</span> <span class="n">c</span><span class="p">,</span> <span class="n">c</span> <span class="o">+</span> <span class="n">partlen</span><span class="p">],</span><span class="n">c</span><span class="p">,</span><span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">membership_function</span> <span class="o">==</span> <span class="n">Membership</span><span class="o">.</span><span class="n">gaussmf</span><span class="p">:</span>
|
||||
<span class="n">sets</span><span class="p">[</span><span class="n">_name</span><span class="p">]</span> <span class="o">=</span> <span class="n">FuzzySet</span><span class="o">.</span><span class="n">FuzzySet</span><span class="p">(</span><span class="n">_name</span><span class="p">,</span> <span class="n">Membership</span><span class="o">.</span><span class="n">gaussmf</span><span class="p">,</span> <span class="p">[</span><span class="n">c</span><span class="p">,</span> <span class="n">partlen</span> <span class="o">/</span> <span class="mi">3</span><span class="p">],</span> <span class="n">c</span><span class="p">,</span><span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">membership_function</span> <span class="o">==</span> <span class="n">Membership</span><span class="o">.</span><span class="n">trapmf</span><span class="p">:</span>
|
||||
<span class="n">q</span> <span class="o">=</span> <span class="n">partlen</span> <span class="o">/</span> <span class="mi">2</span>
|
||||
<span class="n">sets</span><span class="p">[</span><span class="n">_name</span><span class="p">]</span> <span class="o">=</span> <span class="n">FuzzySet</span><span class="o">.</span><span class="n">FuzzySet</span><span class="p">(</span><span class="n">_name</span><span class="p">,</span> <span class="n">Membership</span><span class="o">.</span><span class="n">trapmf</span><span class="p">,</span> <span class="p">[</span><span class="n">c</span> <span class="o">-</span> <span class="n">partlen</span><span class="p">,</span> <span class="n">c</span> <span class="o">-</span> <span class="n">q</span><span class="p">,</span> <span class="n">c</span> <span class="o">+</span> <span class="n">q</span><span class="p">,</span> <span class="n">c</span> <span class="o">+</span> <span class="n">partlen</span><span class="p">],</span> <span class="n">c</span><span class="p">,</span><span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
<span class="n">count</span> <span class="o">+=</span> <span class="mi">1</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">min</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">min</span> <span class="o">-</span> <span class="n">partlen</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">sets</span></div></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="PreFixedGridPartitioner"><a class="viewcode-back" href="../../../pyFTS.partitioners.html#pyFTS.partitioners.Grid.PreFixedGridPartitioner">[docs]</a><span class="k">class</span> <span class="nc">PreFixedGridPartitioner</span><span class="p">(</span><span class="n">GridPartitioner</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""Prefixed UoD with Even Length Grid Partitioner"""</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Fixed UoD with Even Length Grid Partitioner</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="n">kwargs</span><span class="p">[</span><span class="s1">'preprocess'</span><span class="p">]</span> <span class="o">=</span> <span class="kc">False</span>
|
||||
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">GridPartitioner</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s2">"Grid"</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">max</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'max'</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">min</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'min'</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">max</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">or</span> <span class="bp">self</span><span class="o">.</span><span class="n">min</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s2">"It is mandatory to inform the max and min parameters!"</span><span class="p">)</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">sets</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">build</span><span class="p">(</span><span class="kc">None</span><span class="p">)</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">partitions</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">ordered_sets</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">setnames</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">ordered_sets</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">setnames</span><span class="p">[:</span><span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">)]</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">ordered_sets</span> <span class="o">=</span> <span class="n">FuzzySet</span><span class="o">.</span><span class="n">set_ordered</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">)</span></div>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../index.html">
|
||||
<img class="logo" src="../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.partitioners.Grid</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,177 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.partitioners.Simple — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../_static/jquery.js"></script>
|
||||
<script src="../../../_static/underscore.js"></script>
|
||||
<script src="../../../_static/doctools.js"></script>
|
||||
<script src="../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.partitioners.Simple</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.partitioners.Simple</h1><div class="highlight"><pre>
|
||||
<span></span><span class="sd">"""Simple Partitioner for manually informed fuzzy sets"""</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
<span class="kn">import</span> <span class="nn">math</span>
|
||||
<span class="kn">import</span> <span class="nn">random</span> <span class="k">as</span> <span class="nn">rnd</span>
|
||||
<span class="kn">import</span> <span class="nn">functools</span><span class="o">,</span> <span class="nn">operator</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.common</span> <span class="kn">import</span> <span class="n">FuzzySet</span><span class="p">,</span> <span class="n">Membership</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.partitioners</span> <span class="kn">import</span> <span class="n">partitioner</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="SimplePartitioner"><a class="viewcode-back" href="../../../pyFTS.partitioners.html#pyFTS.partitioners.Simple.SimplePartitioner">[docs]</a><span class="k">class</span> <span class="nc">SimplePartitioner</span><span class="p">(</span><span class="n">partitioner</span><span class="o">.</span><span class="n">Partitioner</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""Simple Partitioner for manually informed fuzzy sets"""</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Simple Partitioner - the fuzzy sets are informed manually</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">kwargs</span><span class="p">[</span><span class="s1">'preprocess'</span><span class="p">]</span> <span class="o">=</span> <span class="kc">False</span>
|
||||
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">SimplePartitioner</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s2">"Simple"</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">partitions</span> <span class="o">=</span> <span class="mi">0</span>
|
||||
|
||||
<div class="viewcode-block" id="SimplePartitioner.append_complex"><a class="viewcode-back" href="../../../pyFTS.partitioners.html#pyFTS.partitioners.Simple.SimplePartitioner.append_complex">[docs]</a> <span class="k">def</span> <span class="nf">append_complex</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fs</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="n">fs</span><span class="o">.</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="n">fs</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">partitions</span> <span class="o">+=</span> <span class="mi">1</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">ordered_sets</span> <span class="o">=</span> <span class="p">[</span><span class="n">key</span> <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="nb">sorted</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="o">.</span><span class="n">keys</span><span class="p">(),</span> <span class="n">key</span><span class="o">=</span><span class="k">lambda</span> <span class="n">k</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="n">k</span><span class="p">]</span><span class="o">.</span><span class="n">centroid</span><span class="p">)]</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">min</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">ordered_sets</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span><span class="o">.</span><span class="n">lower</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">max</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">ordered_sets</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]]</span><span class="o">.</span><span class="n">upper</span></div>
|
||||
|
||||
<div class="viewcode-block" id="SimplePartitioner.append"><a class="viewcode-back" href="../../../pyFTS.partitioners.html#pyFTS.partitioners.Simple.SimplePartitioner.append">[docs]</a> <span class="k">def</span> <span class="nf">append</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">mf</span><span class="p">,</span> <span class="n">parameters</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Append a new partition (fuzzy set) to the partitioner</span>
|
||||
|
||||
<span class="sd"> :param name: Fuzzy set name</span>
|
||||
<span class="sd"> :param mf: One of the pyFTS.common.Membership functions</span>
|
||||
<span class="sd"> :param parameters: A list with the parameters for the membership function</span>
|
||||
<span class="sd"> :param kwargs: Optional arguments for the fuzzy set</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">if</span> <span class="n">name</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">or</span> <span class="nb">len</span><span class="p">(</span><span class="n">name</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"The name of the fuzzy set cannot be empty"</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">name</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"This name has already been used"</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">mf</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">or</span> <span class="n">mf</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">(</span><span class="n">Membership</span><span class="o">.</span><span class="n">trimf</span><span class="p">,</span> <span class="n">Membership</span><span class="o">.</span><span class="n">gaussmf</span><span class="p">,</span>
|
||||
<span class="n">Membership</span><span class="o">.</span><span class="n">trapmf</span><span class="p">,</span> <span class="n">Membership</span><span class="o">.</span><span class="n">singleton</span><span class="p">,</span>
|
||||
<span class="n">Membership</span><span class="o">.</span><span class="n">sigmf</span><span class="p">):</span>
|
||||
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"The mf parameter should be one of pyFTS.common.Membership functions, not </span><span class="si">{}</span><span class="s2">"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">mf</span><span class="p">))</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">mf</span> <span class="o">==</span> <span class="n">Membership</span><span class="o">.</span><span class="n">trimf</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">parameters</span><span class="p">)</span> <span class="o">!=</span> <span class="mi">3</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"Incorrect number of parameters for the Membership.trimf"</span><span class="p">)</span>
|
||||
|
||||
<span class="n">centroid</span> <span class="o">=</span> <span class="n">parameters</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
|
||||
<span class="k">elif</span> <span class="n">mf</span> <span class="o">==</span> <span class="n">Membership</span><span class="o">.</span><span class="n">gaussmf</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">parameters</span><span class="p">)</span> <span class="o">!=</span> <span class="mi">2</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"Incorrect number of parameters for the Membership.gaussmf"</span><span class="p">)</span>
|
||||
|
||||
<span class="n">centroid</span> <span class="o">=</span> <span class="n">parameters</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
|
||||
<span class="k">elif</span> <span class="n">mf</span> <span class="o">==</span> <span class="n">Membership</span><span class="o">.</span><span class="n">trapmf</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">parameters</span><span class="p">)</span> <span class="o">!=</span> <span class="mi">4</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"Incorrect number of parameters for the Membership.trapmf"</span><span class="p">)</span>
|
||||
|
||||
<span class="n">centroid</span> <span class="o">=</span> <span class="p">(</span><span class="n">parameters</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">+</span><span class="n">parameters</span><span class="p">[</span><span class="mi">2</span><span class="p">])</span><span class="o">/</span><span class="mi">2</span>
|
||||
<span class="k">elif</span> <span class="n">mf</span> <span class="o">==</span> <span class="n">Membership</span><span class="o">.</span><span class="n">singleton</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">parameters</span><span class="p">)</span> <span class="o">!=</span> <span class="mi">1</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"Incorrect number of parameters for the Membership.singleton"</span><span class="p">)</span>
|
||||
|
||||
<span class="n">centroid</span> <span class="o">=</span> <span class="n">parameters</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
|
||||
<span class="k">elif</span> <span class="n">mf</span> <span class="o">==</span> <span class="n">Membership</span><span class="o">.</span><span class="n">sigmf</span><span class="p">:</span>
|
||||
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">parameters</span><span class="p">)</span> <span class="o">!=</span> <span class="mi">2</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"Incorrect number of parameters for the Membership.sigmf"</span><span class="p">)</span>
|
||||
|
||||
<span class="n">centroid</span> <span class="o">=</span> <span class="n">parameters</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="p">(</span><span class="n">parameters</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">/</span> <span class="p">(</span><span class="mi">2</span> <span class="o">*</span> <span class="n">parameters</span><span class="p">[</span><span class="mi">0</span><span class="p">]))</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="n">FuzzySet</span><span class="o">.</span><span class="n">FuzzySet</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">mf</span><span class="p">,</span> <span class="n">parameters</span><span class="p">,</span> <span class="n">centroid</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">partitions</span> <span class="o">+=</span> <span class="mi">1</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">ordered_sets</span> <span class="o">=</span> <span class="p">[</span><span class="n">key</span> <span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="nb">sorted</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="o">.</span><span class="n">keys</span><span class="p">(),</span> <span class="n">key</span><span class="o">=</span><span class="k">lambda</span> <span class="n">k</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="n">k</span><span class="p">]</span><span class="o">.</span><span class="n">centroid</span><span class="p">)]</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">min</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">ordered_sets</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span><span class="o">.</span><span class="n">lower</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">max</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">ordered_sets</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]]</span><span class="o">.</span><span class="n">upper</span></div></div>
|
||||
|
||||
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../index.html">
|
||||
<img class="logo" src="../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.partitioners.Simple</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,119 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.partitioners.Singleton — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../_static/jquery.js"></script>
|
||||
<script src="../../../_static/underscore.js"></script>
|
||||
<script src="../../../_static/doctools.js"></script>
|
||||
<script src="../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.partitioners.Singleton</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.partitioners.Singleton</h1><div class="highlight"><pre>
|
||||
<span></span><span class="sd">"""Even Length Grid Partitioner"""</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
<span class="kn">import</span> <span class="nn">math</span>
|
||||
<span class="kn">import</span> <span class="nn">random</span> <span class="k">as</span> <span class="nn">rnd</span>
|
||||
<span class="kn">import</span> <span class="nn">functools</span><span class="o">,</span> <span class="nn">operator</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.common</span> <span class="kn">import</span> <span class="n">FuzzySet</span><span class="p">,</span> <span class="n">Membership</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.partitioners</span> <span class="kn">import</span> <span class="n">partitioner</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="SingletonPartitioner"><a class="viewcode-back" href="../../../pyFTS.partitioners.html#pyFTS.partitioners.Singleton.SingletonPartitioner">[docs]</a><span class="k">class</span> <span class="nc">SingletonPartitioner</span><span class="p">(</span><span class="n">partitioner</span><span class="o">.</span><span class="n">Partitioner</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""Singleton Partitioner: Create singleton fuzzy sets for each distinct value in UoD"""</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Singleton Partitioner</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">SingletonPartitioner</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s2">"Singleton"</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
|
||||
<div class="viewcode-block" id="SingletonPartitioner.build"><a class="viewcode-back" href="../../../pyFTS.partitioners.html#pyFTS.partitioners.Singleton.SingletonPartitioner.build">[docs]</a> <span class="k">def</span> <span class="nf">build</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span> <span class="p">:</span> <span class="nb">list</span><span class="p">):</span>
|
||||
<span class="n">sets</span> <span class="o">=</span> <span class="p">{}</span>
|
||||
|
||||
<span class="n">kwargs</span> <span class="o">=</span> <span class="p">{</span><span class="s1">'type'</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">type</span><span class="p">,</span> <span class="s1">'variable'</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">variable</span><span class="p">}</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">count</span><span class="p">,</span> <span class="n">instance</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="nb">set</span><span class="p">(</span><span class="n">data</span><span class="p">)):</span>
|
||||
<span class="n">_name</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_name</span><span class="p">(</span><span class="n">count</span><span class="p">)</span>
|
||||
<span class="n">sets</span><span class="p">[</span><span class="n">_name</span><span class="p">]</span> <span class="o">=</span> <span class="n">FuzzySet</span><span class="o">.</span><span class="n">FuzzySet</span><span class="p">(</span><span class="n">_name</span><span class="p">,</span> <span class="n">Membership</span><span class="o">.</span><span class="n">singleton</span><span class="p">,</span> <span class="p">[</span><span class="n">instance</span><span class="p">],</span> <span class="n">instance</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">sets</span></div></div>
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../index.html">
|
||||
<img class="logo" src="../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.partitioners.Singleton</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,186 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.partitioners.SubClust — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../_static/jquery.js"></script>
|
||||
<script src="../../../_static/underscore.js"></script>
|
||||
<script src="../../../_static/doctools.js"></script>
|
||||
<script src="../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.partitioners.SubClust</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.partitioners.SubClust</h1><div class="highlight"><pre>
|
||||
<span></span><span class="sd">"""</span>
|
||||
<span class="sd">Chiu, Stephen L. "Fuzzy model identification based on cluster estimation." Journal of Intelligent & fuzzy systems 2.3 (1994): 267-278.</span>
|
||||
<span class="sd">"""</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
<span class="kn">import</span> <span class="nn">math</span>
|
||||
<span class="kn">import</span> <span class="nn">random</span> <span class="k">as</span> <span class="nn">rnd</span>
|
||||
<span class="kn">import</span> <span class="nn">functools</span><span class="o">,</span> <span class="nn">operator</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.common</span> <span class="kn">import</span> <span class="n">FuzzySet</span><span class="p">,</span> <span class="n">Membership</span>
|
||||
<span class="kn">from</span> <span class="nn">pyFTS.partitioners</span> <span class="kn">import</span> <span class="n">partitioner</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="imax"><a class="viewcode-back" href="../../../pyFTS.partitioners.html#pyFTS.partitioners.SubClust.imax">[docs]</a><span class="k">def</span> <span class="nf">imax</span><span class="p">(</span><span class="n">vec</span><span class="p">):</span>
|
||||
<span class="n">i</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">argmax</span><span class="p">(</span><span class="n">vec</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">vec</span><span class="p">[</span><span class="n">i</span><span class="p">])</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="subclust"><a class="viewcode-back" href="../../../pyFTS.partitioners.html#pyFTS.partitioners.SubClust.subclust">[docs]</a><span class="k">def</span> <span class="nf">subclust</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="n">ra</span><span class="p">,</span> <span class="n">rb</span><span class="p">,</span> <span class="n">eps_sup</span><span class="p">,</span> <span class="n">eps_inf</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="o">.</span><span class="n">shape</span><span class="p">)</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
|
||||
<span class="n">data</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">reshape</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="p">(</span><span class="n">data</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="mi">1</span><span class="p">))</span>
|
||||
|
||||
<span class="n">centers</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">((</span><span class="mi">0</span><span class="p">,</span> <span class="n">data</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">1</span><span class="p">]))</span>
|
||||
|
||||
<span class="c1"># Initial potentials</span>
|
||||
<span class="n">alpha</span> <span class="o">=</span> <span class="mi">4</span><span class="o">/</span><span class="n">ra</span><span class="o">**</span><span class="mi">2</span>
|
||||
<span class="n">beta</span> <span class="o">=</span> <span class="mi">4</span><span class="o">/</span><span class="n">rb</span><span class="o">**</span><span class="mi">2</span>
|
||||
|
||||
<span class="n">pot</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="n">data</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
|
||||
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">data</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">]):</span>
|
||||
<span class="n">pot</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">sum</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">exp</span><span class="p">(</span><span class="o">-</span><span class="n">alpha</span><span class="o">*</span><span class="n">np</span><span class="o">.</span><span class="n">linalg</span><span class="o">.</span><span class="n">norm</span><span class="p">(</span><span class="n">data</span> <span class="o">-</span> <span class="n">data</span><span class="p">[</span><span class="n">i</span><span class="p">,:],</span> <span class="n">axis</span><span class="o">=</span><span class="mi">1</span><span class="p">)</span><span class="o">**</span><span class="mi">2</span><span class="p">))</span>
|
||||
|
||||
<span class="n">pot_max_i</span><span class="p">,</span> <span class="n">pot_max</span> <span class="o">=</span> <span class="n">imax</span><span class="p">(</span><span class="n">pot</span><span class="p">)</span>
|
||||
|
||||
<span class="n">current_pot_max</span> <span class="o">=</span> <span class="n">pot_max</span>
|
||||
<span class="k">while</span> <span class="n">current_pot_max</span><span class="p">:</span>
|
||||
<span class="n">x_star</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="n">pot_max_i</span><span class="p">,:]</span>
|
||||
<span class="n">accept</span> <span class="o">=</span> <span class="kc">False</span>
|
||||
<span class="k">if</span> <span class="n">current_pot_max</span> <span class="o">></span> <span class="n">eps_sup</span> <span class="o">*</span> <span class="n">pot_max</span><span class="p">:</span>
|
||||
<span class="c1"># Accept xk as a cluster center and continue</span>
|
||||
<span class="n">accept</span> <span class="o">=</span> <span class="kc">True</span>
|
||||
<span class="k">elif</span> <span class="n">current_pot_max</span> <span class="o"><=</span> <span class="n">eps_inf</span> <span class="o">*</span> <span class="n">pot_max</span><span class="p">:</span>
|
||||
<span class="c1"># Reject xk and end the clustering process</span>
|
||||
<span class="k">break</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">d_min</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">min</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">linalg</span><span class="o">.</span><span class="n">norm</span><span class="p">(</span><span class="n">x_star</span> <span class="o">-</span> <span class="n">centers</span><span class="p">))</span>
|
||||
<span class="k">if</span> <span class="n">d_min</span><span class="o">/</span><span class="n">ra</span> <span class="o">+</span> <span class="n">current_pot_max</span><span class="o">/</span><span class="n">pot_max</span> <span class="o">>=</span> <span class="mi">1</span><span class="p">:</span>
|
||||
<span class="n">accept</span> <span class="o">=</span> <span class="kc">True</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">pot</span><span class="p">[</span><span class="n">pot_max_i</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span>
|
||||
<span class="n">pot_max_i</span><span class="p">,</span> <span class="n">current_pot_max</span> <span class="o">=</span> <span class="n">imax</span><span class="p">(</span><span class="n">pot</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">accept</span><span class="p">:</span>
|
||||
<span class="n">centers</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">vstack</span><span class="p">((</span><span class="n">centers</span><span class="p">,</span> <span class="n">x_star</span><span class="p">))</span>
|
||||
<span class="c1"># Recompute potentials</span>
|
||||
<span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">data</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">]):</span>
|
||||
<span class="n">new_pot</span> <span class="o">=</span> <span class="n">pot</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">-</span> <span class="n">current_pot_max</span><span class="o">*</span><span class="n">np</span><span class="o">.</span><span class="n">exp</span><span class="p">(</span><span class="o">-</span><span class="n">beta</span><span class="o">*</span><span class="n">np</span><span class="o">.</span><span class="n">linalg</span><span class="o">.</span><span class="n">norm</span><span class="p">(</span><span class="n">x_star</span> <span class="o">-</span> <span class="n">data</span><span class="p">[</span><span class="n">i</span><span class="p">,:])</span><span class="o">**</span><span class="mi">2</span><span class="p">)</span>
|
||||
<span class="n">new_pot</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="n">new_pot</span><span class="p">)</span>
|
||||
<span class="n">pot</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="o">=</span> <span class="n">new_pot</span>
|
||||
<span class="n">pot_max_i</span><span class="p">,</span> <span class="n">current_pot_max</span> <span class="o">=</span> <span class="n">imax</span><span class="p">(</span><span class="n">pot</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">centers</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="SubClustPartitioner"><a class="viewcode-back" href="../../../pyFTS.partitioners.html#pyFTS.partitioners.SubClust.SubClustPartitioner">[docs]</a><span class="k">class</span> <span class="nc">SubClustPartitioner</span><span class="p">(</span><span class="n">partitioner</span><span class="o">.</span><span class="n">Partitioner</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""Subtractive Clustering Partitioner"""</span>
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">ra</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'ra'</span><span class="p">,</span> <span class="mf">0.8</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">rb</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'rb'</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">ra</span> <span class="o">*</span> <span class="mf">1.5</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">eps_sup</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'eps_sup'</span><span class="p">,</span> <span class="mf">0.5</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">eps_inf</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'eps_inf'</span><span class="p">,</span> <span class="mf">0.15</span><span class="p">)</span>
|
||||
<span class="nb">super</span><span class="p">(</span><span class="n">SubClustPartitioner</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="fm">__init__</span><span class="p">(</span><span class="n">name</span><span class="o">=</span><span class="s2">"SubClust"</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
|
||||
<div class="viewcode-block" id="SubClustPartitioner.build"><a class="viewcode-back" href="../../../pyFTS.partitioners.html#pyFTS.partitioners.SubClust.SubClustPartitioner.build">[docs]</a> <span class="k">def</span> <span class="nf">build</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
|
||||
<span class="n">sets</span> <span class="o">=</span> <span class="p">{}</span>
|
||||
|
||||
<span class="n">kwargs</span> <span class="o">=</span> <span class="p">{</span><span class="s1">'type'</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">type</span><span class="p">,</span> <span class="s1">'variable'</span><span class="p">:</span> <span class="bp">self</span><span class="o">.</span><span class="n">variable</span><span class="p">}</span>
|
||||
|
||||
<span class="n">partitions</span> <span class="o">=</span> <span class="n">subclust</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">ra</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">rb</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">epssup</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">epsinf</span><span class="p">)</span>
|
||||
<span class="n">partitions</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">reshape</span><span class="p">(</span><span class="n">partitions</span><span class="p">,</span> <span class="n">partitions</span><span class="o">.</span><span class="n">shape</span><span class="p">[</span><span class="mi">0</span><span class="p">]))</span>
|
||||
<span class="n">partitions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">min</span><span class="p">)</span>
|
||||
<span class="n">partitions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">max</span><span class="p">)</span>
|
||||
<span class="n">partitions</span> <span class="o">=</span> <span class="nb">list</span><span class="p">(</span><span class="nb">set</span><span class="p">(</span><span class="n">partitions</span><span class="p">))</span>
|
||||
<span class="n">partitions</span><span class="o">.</span><span class="n">sort</span><span class="p">()</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">partitions</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">partitions</span><span class="p">)</span>
|
||||
<span class="k">for</span> <span class="n">c</span> <span class="ow">in</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">partitions</span><span class="p">)</span><span class="o">-</span><span class="mi">1</span><span class="p">):</span>
|
||||
<span class="n">_name</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">get_name</span><span class="p">(</span><span class="n">c</span><span class="o">-</span><span class="mi">1</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">membership_function</span> <span class="o">==</span> <span class="n">Membership</span><span class="o">.</span><span class="n">trimf</span><span class="p">:</span>
|
||||
<span class="n">sets</span><span class="p">[</span><span class="n">_name</span><span class="p">]</span> <span class="o">=</span> <span class="n">FuzzySet</span><span class="o">.</span><span class="n">FuzzySet</span><span class="p">(</span><span class="n">_name</span><span class="p">,</span> <span class="n">Membership</span><span class="o">.</span><span class="n">trimf</span><span class="p">,</span>
|
||||
<span class="p">[</span><span class="n">partitions</span><span class="p">[</span><span class="n">c</span> <span class="o">-</span> <span class="mi">1</span><span class="p">],</span> <span class="n">partitions</span><span class="p">[</span><span class="n">c</span><span class="p">],</span> <span class="n">partitions</span><span class="p">[</span><span class="n">c</span> <span class="o">+</span> <span class="mi">1</span><span class="p">]],</span><span class="n">partitions</span><span class="p">[</span><span class="n">c</span><span class="p">],</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
<span class="k">elif</span> <span class="bp">self</span><span class="o">.</span><span class="n">membership_function</span> <span class="o">==</span> <span class="n">Membership</span><span class="o">.</span><span class="n">trapmf</span><span class="p">:</span>
|
||||
<span class="n">b1</span> <span class="o">=</span> <span class="p">(</span><span class="n">partitions</span><span class="p">[</span><span class="n">c</span><span class="p">]</span> <span class="o">-</span> <span class="n">partitions</span><span class="p">[</span><span class="n">c</span> <span class="o">-</span> <span class="mi">1</span><span class="p">])</span><span class="o">/</span><span class="mi">2</span>
|
||||
<span class="n">b2</span> <span class="o">=</span> <span class="p">(</span><span class="n">partitions</span><span class="p">[</span><span class="n">c</span> <span class="o">+</span> <span class="mi">1</span><span class="p">]</span> <span class="o">-</span> <span class="n">partitions</span><span class="p">[</span><span class="n">c</span><span class="p">])</span> <span class="o">/</span> <span class="mi">2</span>
|
||||
<span class="n">sets</span><span class="p">[</span><span class="n">_name</span><span class="p">]</span> <span class="o">=</span> <span class="n">FuzzySet</span><span class="o">.</span><span class="n">FuzzySet</span><span class="p">(</span><span class="n">_name</span><span class="p">,</span> <span class="n">Membership</span><span class="o">.</span><span class="n">trapmf</span><span class="p">,</span>
|
||||
<span class="p">[</span><span class="n">partitions</span><span class="p">[</span><span class="n">c</span> <span class="o">-</span> <span class="mi">1</span><span class="p">],</span> <span class="n">partitions</span><span class="p">[</span><span class="n">c</span><span class="p">]</span> <span class="o">-</span> <span class="n">b1</span><span class="p">,</span>
|
||||
<span class="n">partitions</span><span class="p">[</span><span class="n">c</span><span class="p">]</span> <span class="o">+</span> <span class="n">b2</span><span class="p">,</span> <span class="n">partitions</span><span class="p">[</span><span class="n">c</span> <span class="o">+</span> <span class="mi">1</span><span class="p">]],</span>
|
||||
<span class="n">partitions</span><span class="p">[</span><span class="n">c</span><span class="p">],</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
|
||||
<span class="k">return</span> <span class="n">sets</span></div></div>
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../index.html">
|
||||
<img class="logo" src="../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.partitioners.SubClust</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
@ -1,436 +0,0 @@
|
||||
|
||||
|
||||
<!doctype html>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>pyFTS.partitioners.partitioner — pyFTS 1.7 documentation</title>
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
|
||||
<link rel="stylesheet" type="text/css" href="../../../_static/bizstyle.css" />
|
||||
|
||||
<script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
|
||||
<script src="../../../_static/jquery.js"></script>
|
||||
<script src="../../../_static/underscore.js"></script>
|
||||
<script src="../../../_static/doctools.js"></script>
|
||||
<script src="../../../_static/bizstyle.js"></script>
|
||||
<link rel="index" title="Index" href="../../../genindex.html" />
|
||||
<link rel="search" title="Search" href="../../../search.html" />
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
||||
<!--[if lt IE 9]>
|
||||
<script src="_static/css3-mediaqueries.js"></script>
|
||||
<![endif]-->
|
||||
</head><body>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
accesskey="I">index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" accesskey="U">Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.partitioners.partitioner</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="document">
|
||||
<div class="documentwrapper">
|
||||
<div class="bodywrapper">
|
||||
<div class="body" role="main">
|
||||
|
||||
<h1>Source code for pyFTS.partitioners.partitioner</h1><div class="highlight"><pre>
|
||||
<span></span><span class="kn">from</span> <span class="nn">pyFTS.common</span> <span class="kn">import</span> <span class="n">FuzzySet</span><span class="p">,</span> <span class="n">Membership</span>
|
||||
<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
|
||||
<span class="kn">from</span> <span class="nn">scipy.spatial</span> <span class="kn">import</span> <span class="n">KDTree</span>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="Partitioner"><a class="viewcode-back" href="../../../pyFTS.partitioners.html#pyFTS.partitioners.partitioner.Partitioner">[docs]</a><span class="k">class</span> <span class="nc">Partitioner</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Universe of Discourse partitioner. Split data on several fuzzy sets</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Universe of Discourse partitioner scheme. Split data on several fuzzy sets</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'name'</span><span class="p">,</span><span class="s2">""</span><span class="p">)</span>
|
||||
<span class="w"> </span><span class="sd">"""partitioner name"""</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">partitions</span> <span class="p">:</span> <span class="nb">int</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'npart'</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span>
|
||||
<span class="w"> </span><span class="sd">"""The number of universe of discourse partitions, i.e., the number of fuzzy sets that will be created"""</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">sets</span> <span class="p">:</span> <span class="nb">dict</span> <span class="o">=</span> <span class="p">{}</span>
|
||||
<span class="w"> </span><span class="sd">"""The fuzzy sets dictionary"""</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">membership_function</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'func'</span><span class="p">,</span> <span class="n">Membership</span><span class="o">.</span><span class="n">trimf</span><span class="p">)</span>
|
||||
<span class="w"> </span><span class="sd">"""Fuzzy membership function (pyFTS.common.Membership)"""</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">setnames</span> <span class="p">:</span> <span class="nb">list</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'names'</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
|
||||
<span class="w"> </span><span class="sd">"""list of partitions names. If None is given the partitions will be auto named with prefix"""</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">prefix</span> <span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'prefix'</span><span class="p">,</span> <span class="s1">'A'</span><span class="p">)</span>
|
||||
<span class="w"> </span><span class="sd">"""prefix of auto generated partition names"""</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">transformation</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'transformation'</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
|
||||
<span class="w"> </span><span class="sd">"""data transformation to be applied on data"""</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">indexer</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'indexer'</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">variable</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'variable'</span><span class="p">,</span> <span class="kc">None</span><span class="p">)</span>
|
||||
<span class="w"> </span><span class="sd">"""In a multivariate context, the variable that contains this partitioner"""</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">type</span> <span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'type'</span><span class="p">,</span> <span class="s1">'common'</span><span class="p">)</span>
|
||||
<span class="w"> </span><span class="sd">"""The type of fuzzy sets that are generated by this partitioner"""</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">ordered_sets</span> <span class="p">:</span> <span class="nb">list</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
<span class="w"> </span><span class="sd">"""A ordered list of the fuzzy sets names, sorted by their middle point"""</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">kdtree</span> <span class="p">:</span> <span class="n">KDTree</span> <span class="o">=</span> <span class="kc">None</span>
|
||||
<span class="w"> </span><span class="sd">"""A spatial index to help in fuzzyfication"""</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">margin</span> <span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"margin"</span><span class="p">,</span> <span class="mf">0.1</span><span class="p">)</span>
|
||||
<span class="w"> </span><span class="sd">"""The upper and lower exceeding margins for the known UoD. The default value is .1"""</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">lower_margin</span> <span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"lower_margin"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">margin</span><span class="p">)</span>
|
||||
<span class="w"> </span><span class="sd">"""Specific lower exceeding margins for the known UoD. The default value is the self.margin parameter"""</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">upper_margin</span> <span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s2">"lower_margin"</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">margin</span><span class="p">)</span>
|
||||
<span class="w"> </span><span class="sd">"""Specific upper exceeding margins for the known UoD. The default value is the self.margin parameter"""</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'preprocess'</span><span class="p">,</span><span class="kc">True</span><span class="p">):</span>
|
||||
|
||||
<span class="n">data</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'data'</span><span class="p">,[</span><span class="kc">None</span><span class="p">])</span>
|
||||
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">indexer</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">ndata</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">indexer</span><span class="o">.</span><span class="n">get_data</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">ndata</span> <span class="o">=</span> <span class="n">data</span>
|
||||
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">transformation</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">ndata</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">transformation</span><span class="o">.</span><span class="n">apply</span><span class="p">(</span><span class="n">ndata</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="n">ndata</span> <span class="o">=</span> <span class="n">data</span>
|
||||
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">indexer</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="n">ndata</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">indexer</span><span class="o">.</span><span class="n">get_data</span><span class="p">(</span><span class="n">ndata</span><span class="p">)</span>
|
||||
|
||||
<span class="n">_min</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">nanmin</span><span class="p">(</span><span class="n">ndata</span><span class="p">)</span>
|
||||
<span class="k">if</span> <span class="n">_min</span> <span class="o">==</span> <span class="o">-</span><span class="n">np</span><span class="o">.</span><span class="n">inf</span><span class="p">:</span>
|
||||
<span class="n">ndata</span><span class="p">[</span><span class="n">ndata</span> <span class="o">==</span> <span class="o">-</span><span class="n">np</span><span class="o">.</span><span class="n">inf</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span>
|
||||
<span class="n">_min</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">nanmin</span><span class="p">(</span><span class="n">ndata</span><span class="p">)</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">min</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">_min</span> <span class="o">*</span> <span class="p">(</span><span class="mi">1</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">lower_margin</span><span class="p">)</span> <span class="k">if</span> <span class="n">_min</span> <span class="o"><</span> <span class="mi">0</span> <span class="k">else</span> <span class="n">_min</span> <span class="o">*</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">lower_margin</span><span class="p">))</span>
|
||||
|
||||
<span class="n">_max</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">nanmax</span><span class="p">(</span><span class="n">ndata</span><span class="p">)</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">max</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">_max</span> <span class="o">*</span> <span class="p">(</span><span class="mi">1</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">upper_margin</span><span class="p">)</span> <span class="k">if</span> <span class="n">_max</span> <span class="o">></span> <span class="mi">0</span> <span class="k">else</span> <span class="n">_max</span> <span class="o">*</span> <span class="p">(</span><span class="mi">1</span> <span class="o">-</span> <span class="bp">self</span><span class="o">.</span><span class="n">upper_margin</span><span class="p">))</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">sets</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">build</span><span class="p">(</span><span class="n">ndata</span><span class="p">)</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">partitions</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">ordered_sets</span> <span class="ow">is</span> <span class="kc">None</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">setnames</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">ordered_sets</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">setnames</span><span class="p">[:</span><span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">)]</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">ordered_sets</span> <span class="o">=</span> <span class="n">FuzzySet</span><span class="o">.</span><span class="n">set_ordered</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">)</span>
|
||||
|
||||
<span class="k">del</span><span class="p">(</span><span class="n">ndata</span><span class="p">)</span>
|
||||
|
||||
<div class="viewcode-block" id="Partitioner.extractor"><a class="viewcode-back" href="../../../pyFTS.partitioners.html#pyFTS.partitioners.partitioner.Partitioner.extractor">[docs]</a> <span class="k">def</span> <span class="nf">extractor</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span><span class="n">x</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""Extract a single primitive type from an structured instance"""</span>
|
||||
<span class="k">return</span> <span class="n">x</span></div>
|
||||
|
||||
<div class="viewcode-block" id="Partitioner.build"><a class="viewcode-back" href="../../../pyFTS.partitioners.html#pyFTS.partitioners.partitioner.Partitioner.build">[docs]</a> <span class="k">def</span> <span class="nf">build</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Perform the partitioning of the Universe of Discourse</span>
|
||||
|
||||
<span class="sd"> :param data: training data</span>
|
||||
<span class="sd"> :return: </span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">pass</span></div>
|
||||
|
||||
<div class="viewcode-block" id="Partitioner.get_name"><a class="viewcode-back" href="../../../pyFTS.partitioners.html#pyFTS.partitioners.partitioner.Partitioner.get_name">[docs]</a> <span class="k">def</span> <span class="nf">get_name</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">counter</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Find the name of the fuzzy set given its counter id.</span>
|
||||
|
||||
<span class="sd"> :param counter: The number of the fuzzy set</span>
|
||||
<span class="sd"> :return: String</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">prefix</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">counter</span><span class="p">)</span> <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">setnames</span> <span class="ow">is</span> <span class="kc">None</span> <span class="k">else</span> <span class="bp">self</span><span class="o">.</span><span class="n">setnames</span><span class="p">[</span><span class="n">counter</span><span class="p">]</span></div>
|
||||
|
||||
<div class="viewcode-block" id="Partitioner.lower_set"><a class="viewcode-back" href="../../../pyFTS.partitioners.html#pyFTS.partitioners.partitioner.Partitioner.lower_set">[docs]</a> <span class="k">def</span> <span class="nf">lower_set</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Return the fuzzy set on lower bound of the universe of discourse.</span>
|
||||
|
||||
<span class="sd"> :return: Fuzzy Set</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">ordered_sets</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span></div>
|
||||
|
||||
<div class="viewcode-block" id="Partitioner.upper_set"><a class="viewcode-back" href="../../../pyFTS.partitioners.html#pyFTS.partitioners.partitioner.Partitioner.upper_set">[docs]</a> <span class="k">def</span> <span class="nf">upper_set</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Return the fuzzy set on upper bound of the universe of discourse.</span>
|
||||
|
||||
<span class="sd"> :return: Fuzzy Set</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">ordered_sets</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]]</span></div>
|
||||
|
||||
<div class="viewcode-block" id="Partitioner.build_index"><a class="viewcode-back" href="../../../pyFTS.partitioners.html#pyFTS.partitioners.partitioner.Partitioner.build_index">[docs]</a> <span class="k">def</span> <span class="nf">build_index</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="n">points</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
|
||||
<span class="c1">#self.index = {}</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">ct</span><span class="p">,</span> <span class="n">key</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">ordered_sets</span><span class="p">):</span>
|
||||
<span class="n">fset</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="n">key</span><span class="p">]</span>
|
||||
<span class="n">points</span><span class="o">.</span><span class="n">append</span><span class="p">([</span><span class="n">fset</span><span class="o">.</span><span class="n">lower</span><span class="p">,</span> <span class="n">fset</span><span class="o">.</span><span class="n">centroid</span><span class="p">,</span> <span class="n">fset</span><span class="o">.</span><span class="n">upper</span><span class="p">])</span>
|
||||
<span class="c1">#self.index[ct] = fset.name</span>
|
||||
|
||||
<span class="kn">import</span> <span class="nn">sys</span>
|
||||
<span class="n">sys</span><span class="o">.</span><span class="n">setrecursionlimit</span><span class="p">(</span><span class="mi">100000</span><span class="p">)</span>
|
||||
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">kdtree</span> <span class="o">=</span> <span class="n">KDTree</span><span class="p">(</span><span class="n">points</span><span class="p">)</span>
|
||||
|
||||
<span class="n">sys</span><span class="o">.</span><span class="n">setrecursionlimit</span><span class="p">(</span><span class="mi">1000</span><span class="p">)</span></div>
|
||||
|
||||
<div class="viewcode-block" id="Partitioner.fuzzyfy"><a class="viewcode-back" href="../../../pyFTS.partitioners.html#pyFTS.partitioners.partitioner.Partitioner.fuzzyfy">[docs]</a> <span class="k">def</span> <span class="nf">fuzzyfy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Fuzzyfy the input data according to this partitioner fuzzy sets.</span>
|
||||
|
||||
<span class="sd"> :param data: input value to be fuzzyfied</span>
|
||||
<span class="sd"> :keyword alpha_cut: the minimal membership value to be considered on fuzzyfication (only for mode='sets')</span>
|
||||
<span class="sd"> :keyword method: the fuzzyfication method (fuzzy: all fuzzy memberships, maximum: only the maximum membership)</span>
|
||||
<span class="sd"> :keyword mode: the fuzzyfication mode (sets: return the fuzzy sets names, vector: return a vector with the membership</span>
|
||||
<span class="sd"> values for all fuzzy sets, both: return a list with tuples (fuzzy set, membership value) )</span>
|
||||
|
||||
<span class="sd"> :returns a list with the fuzzyfied values, depending on the mode</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="p">(</span><span class="nb">tuple</span><span class="p">,</span> <span class="nb">list</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">ndarray</span><span class="p">)):</span>
|
||||
<span class="n">ret</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">inst</span> <span class="ow">in</span> <span class="n">data</span><span class="p">:</span>
|
||||
<span class="n">mv</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">fuzzyfy</span><span class="p">(</span><span class="n">inst</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
|
||||
<span class="n">ret</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">mv</span><span class="p">)</span>
|
||||
<span class="k">return</span> <span class="n">ret</span>
|
||||
|
||||
<span class="n">alpha_cut</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'alpha_cut'</span><span class="p">,</span> <span class="mf">0.</span><span class="p">)</span>
|
||||
<span class="n">mode</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'mode'</span><span class="p">,</span> <span class="s1">'sets'</span><span class="p">)</span>
|
||||
<span class="n">method</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'method'</span><span class="p">,</span> <span class="s1">'fuzzy'</span><span class="p">)</span>
|
||||
|
||||
<span class="n">nearest</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">search</span><span class="p">(</span><span class="n">data</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="s1">'index'</span><span class="p">)</span>
|
||||
<span class="n">mv</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">partitions</span><span class="p">)</span>
|
||||
|
||||
<span class="k">for</span> <span class="n">ix</span> <span class="ow">in</span> <span class="n">nearest</span><span class="p">:</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="bp">self</span><span class="p">[</span><span class="n">ix</span><span class="p">]</span><span class="o">.</span><span class="n">membership</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
|
||||
<span class="n">mv</span><span class="p">[</span><span class="n">ix</span><span class="p">]</span> <span class="o">=</span> <span class="n">tmp</span> <span class="k">if</span> <span class="n">tmp</span> <span class="o">>=</span> <span class="n">alpha_cut</span> <span class="k">else</span> <span class="mf">0.</span>
|
||||
|
||||
|
||||
<span class="n">ix</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">ravel</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">argwhere</span><span class="p">(</span><span class="n">mv</span> <span class="o">></span> <span class="mf">0.</span><span class="p">))</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">ix</span><span class="o">.</span><span class="n">size</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
|
||||
<span class="n">mv</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">check_bounds</span><span class="p">(</span><span class="n">data</span><span class="p">)]</span> <span class="o">=</span> <span class="mf">1.</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">method</span> <span class="o">==</span> <span class="s1">'fuzzy'</span> <span class="ow">and</span> <span class="n">mode</span> <span class="o">==</span> <span class="s1">'vector'</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">mv</span>
|
||||
<span class="k">elif</span> <span class="n">method</span> <span class="o">==</span> <span class="s1">'fuzzy'</span> <span class="ow">and</span> <span class="n">mode</span> <span class="o">==</span> <span class="s1">'sets'</span><span class="p">:</span>
|
||||
<span class="k">try</span><span class="p">:</span>
|
||||
<span class="n">ix</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">ravel</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">argwhere</span><span class="p">(</span><span class="n">mv</span> <span class="o">></span> <span class="mf">0.</span><span class="p">))</span>
|
||||
<span class="n">sets</span> <span class="o">=</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">ordered_sets</span><span class="p">[</span><span class="n">i</span><span class="p">]</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">ix</span> <span class="k">if</span> <span class="n">i</span> <span class="o"><</span> <span class="bp">self</span><span class="o">.</span><span class="n">partitions</span><span class="p">]</span>
|
||||
<span class="k">return</span> <span class="n">sets</span>
|
||||
<span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">ex</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="kc">None</span>
|
||||
<span class="k">elif</span> <span class="n">method</span> <span class="o">==</span> <span class="s1">'maximum'</span> <span class="ow">and</span> <span class="n">mode</span> <span class="o">==</span> <span class="s1">'sets'</span><span class="p">:</span>
|
||||
<span class="n">mx</span> <span class="o">=</span> <span class="nb">max</span><span class="p">(</span><span class="n">mv</span><span class="p">)</span>
|
||||
<span class="n">ix</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">ravel</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">argwhere</span><span class="p">(</span><span class="n">mv</span> <span class="o">==</span> <span class="n">mx</span><span class="p">))</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">ordered_sets</span><span class="p">[</span><span class="n">ix</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span>
|
||||
<span class="k">elif</span> <span class="n">mode</span> <span class="o">==</span> <span class="s1">'both'</span><span class="p">:</span>
|
||||
<span class="n">ix</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">ravel</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">argwhere</span><span class="p">(</span><span class="n">mv</span> <span class="o">></span> <span class="mf">0.</span><span class="p">))</span>
|
||||
<span class="n">sets</span> <span class="o">=</span> <span class="p">[(</span><span class="bp">self</span><span class="o">.</span><span class="n">ordered_sets</span><span class="p">[</span><span class="n">i</span><span class="p">],</span> <span class="n">mv</span><span class="p">[</span><span class="n">i</span><span class="p">])</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">ix</span><span class="p">]</span>
|
||||
<span class="k">return</span> <span class="n">sets</span></div>
|
||||
|
||||
<div class="viewcode-block" id="Partitioner.defuzzyfy"><a class="viewcode-back" href="../../../pyFTS.partitioners.html#pyFTS.partitioners.partitioner.Partitioner.defuzzyfy">[docs]</a> <span class="k">def</span> <span class="nf">defuzzyfy</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">values</span><span class="p">,</span> <span class="n">mode</span><span class="o">=</span><span class="s1">'both'</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">values</span><span class="p">,</span> <span class="nb">list</span><span class="p">):</span>
|
||||
<span class="n">values</span> <span class="o">=</span> <span class="p">[</span><span class="n">values</span><span class="p">]</span>
|
||||
|
||||
<span class="n">num</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="n">den</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">val</span> <span class="ow">in</span> <span class="n">values</span><span class="p">:</span>
|
||||
<span class="n">fset</span> <span class="o">=</span> <span class="n">val</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
|
||||
<span class="n">mv</span> <span class="o">=</span> <span class="n">val</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
|
||||
<span class="k">if</span> <span class="n">mode</span> <span class="o">==</span> <span class="s1">'both'</span><span class="p">:</span>
|
||||
<span class="n">num</span><span class="o">.</span><span class="n">append</span><span class="p">(</span> <span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="n">fset</span><span class="p">]</span><span class="o">.</span><span class="n">centroid</span> <span class="o">*</span> <span class="n">mv</span> <span class="p">)</span>
|
||||
<span class="n">den</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">mv</span><span class="p">)</span>
|
||||
<span class="k">elif</span> <span class="n">mode</span> <span class="o">==</span> <span class="s1">'sets'</span><span class="p">:</span>
|
||||
<span class="n">num</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="n">fset</span><span class="p">]</span><span class="o">.</span><span class="n">centroid</span><span class="p">)</span>
|
||||
<span class="k">elif</span> <span class="n">mode</span> <span class="o">==</span> <span class="s1">'vector'</span><span class="p">:</span>
|
||||
<span class="n">num</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">ordered_sets</span><span class="p">[</span><span class="n">fset</span><span class="p">]]</span><span class="o">.</span><span class="n">centroid</span> <span class="o">*</span> <span class="n">mv</span><span class="p">)</span>
|
||||
<span class="n">den</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">mv</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="ne">Exception</span><span class="p">(</span><span class="s1">'Unknown deffuzyfication mode'</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">mode</span> <span class="ow">in</span> <span class="p">(</span><span class="s1">'both'</span><span class="p">,</span><span class="s1">'vector'</span><span class="p">):</span>
|
||||
<span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">nansum</span><span class="p">(</span><span class="n">num</span><span class="p">)</span> <span class="o">/</span> <span class="n">np</span><span class="o">.</span><span class="n">nansum</span><span class="p">(</span><span class="n">den</span><span class="p">)</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">nanmean</span><span class="p">(</span><span class="n">num</span><span class="p">)</span></div>
|
||||
|
||||
<div class="viewcode-block" id="Partitioner.check_bounds"><a class="viewcode-back" href="../../../pyFTS.partitioners.html#pyFTS.partitioners.partitioner.Partitioner.check_bounds">[docs]</a> <span class="k">def</span> <span class="nf">check_bounds</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Check if the input data is outside the known Universe of Discourse and, if it is, round it to the closest</span>
|
||||
<span class="sd"> fuzzy set.</span>
|
||||
|
||||
<span class="sd"> :param data: input data to be verified</span>
|
||||
<span class="sd"> :return: the index of the closest fuzzy set when data is outside de universe of discourse or None if</span>
|
||||
<span class="sd"> the data is inside the UoD.</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="k">if</span> <span class="n">data</span> <span class="o"><</span> <span class="bp">self</span><span class="o">.</span><span class="n">min</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="mi">0</span>
|
||||
<span class="k">elif</span> <span class="n">data</span> <span class="o">></span> <span class="bp">self</span><span class="o">.</span><span class="n">max</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">partitions</span><span class="o">-</span><span class="mi">1</span></div>
|
||||
|
||||
<div class="viewcode-block" id="Partitioner.search"><a class="viewcode-back" href="../../../pyFTS.partitioners.html#pyFTS.partitioners.partitioner.Partitioner.search">[docs]</a> <span class="k">def</span> <span class="nf">search</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Perform a search for the nearest fuzzy sets of the point 'data'. This function were designed to work with several</span>
|
||||
<span class="sd"> overlapped fuzzy sets.</span>
|
||||
|
||||
<span class="sd"> :param data: the value to search for the nearest fuzzy sets</span>
|
||||
<span class="sd"> :param type: the return type: 'index' for the fuzzy set indexes or 'name' for fuzzy set names.</span>
|
||||
<span class="sd"> :param results: the number of nearest fuzzy sets to return</span>
|
||||
<span class="sd"> :return: a list with the nearest fuzzy sets</span>
|
||||
<span class="sd"> """</span>
|
||||
|
||||
<span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">kdtree</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">build_index</span><span class="p">()</span>
|
||||
|
||||
<span class="nb">type</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'type'</span><span class="p">,</span><span class="s1">'index'</span><span class="p">)</span>
|
||||
<span class="n">results</span> <span class="o">=</span> <span class="n">kwargs</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">'results'</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span>
|
||||
|
||||
<span class="n">_</span><span class="p">,</span> <span class="n">ix</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">kdtree</span><span class="o">.</span><span class="n">query</span><span class="p">([</span><span class="n">data</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">data</span><span class="p">],</span> <span class="n">results</span><span class="p">)</span>
|
||||
|
||||
<span class="k">if</span> <span class="nb">type</span> <span class="o">==</span> <span class="s1">'name'</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">ordered_sets</span><span class="p">[</span><span class="n">k</span><span class="p">]</span> <span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">ix</span><span class="p">)]</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="k">return</span> <span class="nb">sorted</span><span class="p">(</span><span class="n">ix</span><span class="p">)</span></div>
|
||||
|
||||
|
||||
<div class="viewcode-block" id="Partitioner.plot"><a class="viewcode-back" href="../../../pyFTS.partitioners.html#pyFTS.partitioners.partitioner.Partitioner.plot">[docs]</a> <span class="k">def</span> <span class="nf">plot</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ax</span><span class="p">,</span> <span class="n">rounding</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Plot the partitioning using the Matplotlib axis ax</span>
|
||||
|
||||
<span class="sd"> :param ax: Matplotlib axis</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">ax</span><span class="o">.</span><span class="n">set_title</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">)</span>
|
||||
<span class="n">ax</span><span class="o">.</span><span class="n">set_ylim</span><span class="p">([</span><span class="mi">0</span><span class="p">,</span> <span class="mf">1.1</span><span class="p">])</span>
|
||||
<span class="n">ax</span><span class="o">.</span><span class="n">set_xlim</span><span class="p">([</span><span class="bp">self</span><span class="o">.</span><span class="n">min</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">max</span><span class="p">])</span>
|
||||
<span class="n">ticks</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="n">x</span> <span class="o">=</span> <span class="p">[]</span>
|
||||
<span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
|
||||
<span class="n">s</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="n">key</span><span class="p">]</span>
|
||||
<span class="k">if</span> <span class="n">s</span><span class="o">.</span><span class="n">type</span> <span class="o">==</span> <span class="s1">'common'</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">plot_set</span><span class="p">(</span><span class="n">ax</span><span class="p">,</span> <span class="n">s</span><span class="p">)</span>
|
||||
<span class="k">elif</span> <span class="n">s</span><span class="o">.</span><span class="n">type</span> <span class="o">==</span> <span class="s1">'composite'</span><span class="p">:</span>
|
||||
<span class="k">for</span> <span class="n">ss</span> <span class="ow">in</span> <span class="n">s</span><span class="o">.</span><span class="n">sets</span><span class="p">:</span>
|
||||
<span class="bp">self</span><span class="o">.</span><span class="n">plot_set</span><span class="p">(</span><span class="n">ax</span><span class="p">,</span> <span class="n">ss</span><span class="p">)</span>
|
||||
<span class="n">ticks</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="nb">round</span><span class="p">(</span><span class="n">s</span><span class="o">.</span><span class="n">centroid</span><span class="p">,</span><span class="n">rounding</span><span class="p">))</span><span class="o">+</span><span class="s1">'</span><span class="se">\n</span><span class="s1">'</span><span class="o">+</span><span class="n">s</span><span class="o">.</span><span class="n">name</span><span class="p">)</span>
|
||||
<span class="n">x</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">s</span><span class="o">.</span><span class="n">centroid</span><span class="p">)</span>
|
||||
<span class="n">ax</span><span class="o">.</span><span class="n">xaxis</span><span class="o">.</span><span class="n">set_ticklabels</span><span class="p">(</span><span class="n">ticks</span><span class="p">)</span>
|
||||
<span class="n">ax</span><span class="o">.</span><span class="n">xaxis</span><span class="o">.</span><span class="n">set_ticks</span><span class="p">(</span><span class="n">x</span><span class="p">)</span></div>
|
||||
|
||||
<div class="viewcode-block" id="Partitioner.plot_set"><a class="viewcode-back" href="../../../pyFTS.partitioners.html#pyFTS.partitioners.partitioner.Partitioner.plot_set">[docs]</a> <span class="k">def</span> <span class="nf">plot_set</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ax</span><span class="p">,</span> <span class="n">s</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Plot an isolate fuzzy set on Matplotlib axis</span>
|
||||
|
||||
<span class="sd"> :param ax: Matplotlib axis</span>
|
||||
<span class="sd"> :param s: Fuzzy Set</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">if</span> <span class="n">s</span><span class="o">.</span><span class="n">mf</span> <span class="o">==</span> <span class="n">Membership</span><span class="o">.</span><span class="n">trimf</span><span class="p">:</span>
|
||||
<span class="n">ax</span><span class="o">.</span><span class="n">plot</span><span class="p">([</span><span class="n">s</span><span class="o">.</span><span class="n">parameters</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">s</span><span class="o">.</span><span class="n">parameters</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="n">s</span><span class="o">.</span><span class="n">parameters</span><span class="p">[</span><span class="mi">2</span><span class="p">]],</span> <span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="n">s</span><span class="o">.</span><span class="n">alpha</span><span class="p">,</span> <span class="mi">0</span><span class="p">])</span>
|
||||
<span class="k">elif</span> <span class="n">s</span><span class="o">.</span><span class="n">mf</span> <span class="ow">in</span> <span class="p">(</span><span class="n">Membership</span><span class="o">.</span><span class="n">gaussmf</span><span class="p">,</span> <span class="n">Membership</span><span class="o">.</span><span class="n">bellmf</span><span class="p">,</span> <span class="n">Membership</span><span class="o">.</span><span class="n">sigmf</span><span class="p">):</span>
|
||||
<span class="n">tmpx</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">linspace</span><span class="p">(</span><span class="n">s</span><span class="o">.</span><span class="n">lower</span><span class="p">,</span> <span class="n">s</span><span class="o">.</span><span class="n">upper</span><span class="p">,</span> <span class="mi">100</span><span class="p">)</span>
|
||||
<span class="n">tmpy</span> <span class="o">=</span> <span class="p">[</span><span class="n">s</span><span class="o">.</span><span class="n">membership</span><span class="p">(</span><span class="n">kk</span><span class="p">)</span> <span class="k">for</span> <span class="n">kk</span> <span class="ow">in</span> <span class="n">tmpx</span><span class="p">]</span>
|
||||
<span class="n">ax</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">tmpx</span><span class="p">,</span> <span class="n">tmpy</span><span class="p">)</span>
|
||||
<span class="k">elif</span> <span class="n">s</span><span class="o">.</span><span class="n">mf</span> <span class="o">==</span> <span class="n">Membership</span><span class="o">.</span><span class="n">trapmf</span><span class="p">:</span>
|
||||
<span class="n">ax</span><span class="o">.</span><span class="n">plot</span><span class="p">(</span><span class="n">s</span><span class="o">.</span><span class="n">parameters</span><span class="p">,</span> <span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="n">s</span><span class="o">.</span><span class="n">alpha</span><span class="p">,</span> <span class="n">s</span><span class="o">.</span><span class="n">alpha</span><span class="p">,</span> <span class="mi">0</span><span class="p">])</span>
|
||||
<span class="k">elif</span> <span class="n">s</span><span class="o">.</span><span class="n">mf</span> <span class="o">==</span> <span class="n">Membership</span><span class="o">.</span><span class="n">singleton</span><span class="p">:</span>
|
||||
<span class="n">ax</span><span class="o">.</span><span class="n">plot</span><span class="p">([</span><span class="n">s</span><span class="o">.</span><span class="n">parameters</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span><span class="n">s</span><span class="o">.</span><span class="n">parameters</span><span class="p">[</span><span class="mi">0</span><span class="p">]],</span> <span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="n">s</span><span class="o">.</span><span class="n">alpha</span><span class="p">])</span></div>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Return a string representation of the partitioner, the list of fuzzy sets and their parameters</span>
|
||||
|
||||
<span class="sd"> :return:</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="n">tmp</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">+</span> <span class="s2">":</span><span class="se">\n</span><span class="s2">"</span>
|
||||
<span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="o">.</span><span class="n">keys</span><span class="p">():</span>
|
||||
<span class="n">tmp</span> <span class="o">+=</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="n">key</span><span class="p">])</span><span class="o">+</span> <span class="s2">"</span><span class="se">\n</span><span class="s2">"</span>
|
||||
<span class="k">return</span> <span class="n">tmp</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__len__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Return the number of partitions</span>
|
||||
|
||||
<span class="sd"> :return: number of partitions</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">partitions</span>
|
||||
|
||||
<span class="k">def</span> <span class="fm">__getitem__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">item</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Return a fuzzy set by its order or its name.</span>
|
||||
|
||||
<span class="sd"> :param item: If item is an integer then it represents the fuzzy set index (order), if it was a string then</span>
|
||||
<span class="sd"> it represents the fuzzy set name.</span>
|
||||
<span class="sd"> :return: the fuzzy set</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="p">(</span><span class="nb">int</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">int8</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">int16</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">int32</span><span class="p">,</span> <span class="n">np</span><span class="o">.</span><span class="n">int64</span><span class="p">)):</span>
|
||||
<span class="k">if</span> <span class="n">item</span> <span class="o"><</span> <span class="mi">0</span> <span class="ow">or</span> <span class="n">item</span> <span class="o">>=</span> <span class="bp">self</span><span class="o">.</span><span class="n">partitions</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"The fuzzy set index must be between 0 and </span><span class="si">{}</span><span class="s2">."</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">partitions</span><span class="p">))</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">ordered_sets</span><span class="p">[</span><span class="n">item</span><span class="p">]]</span>
|
||||
<span class="k">elif</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="nb">str</span><span class="p">):</span>
|
||||
<span class="k">if</span> <span class="n">item</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"The fuzzy set with name </span><span class="si">{}</span><span class="s2"> does not exist."</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">item</span><span class="p">))</span>
|
||||
<span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="n">item</span><span class="p">]</span>
|
||||
<span class="k">else</span><span class="p">:</span>
|
||||
<span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">"The parameter 'item' must be an integer or a string and the value informed was </span><span class="si">{}</span><span class="s2"> of type </span><span class="si">{}</span><span class="s2">!"</span><span class="o">.</span><span class="n">format</span><span class="p">(</span><span class="n">item</span><span class="p">,</span> <span class="nb">type</span><span class="p">(</span><span class="n">item</span><span class="p">)))</span>
|
||||
|
||||
|
||||
<span class="k">def</span> <span class="fm">__iter__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
|
||||
<span class="w"> </span><span class="sd">"""</span>
|
||||
<span class="sd"> Iterate over the fuzzy sets, ordered by its midpoints.</span>
|
||||
|
||||
<span class="sd"> :return: An iterator over the fuzzy sets.</span>
|
||||
<span class="sd"> """</span>
|
||||
<span class="k">for</span> <span class="n">key</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">ordered_sets</span><span class="p">:</span>
|
||||
<span class="k">yield</span> <span class="bp">self</span><span class="o">.</span><span class="n">sets</span><span class="p">[</span><span class="n">key</span><span class="p">]</span></div>
|
||||
|
||||
</pre></div>
|
||||
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
|
||||
<div class="sphinxsidebarwrapper">
|
||||
<p class="logo"><a href="../../../index.html">
|
||||
<img class="logo" src="../../../_static/logo_heading2.png" alt="Logo"/>
|
||||
</a></p>
|
||||
<div id="searchbox" style="display: none" role="search">
|
||||
<h3 id="searchlabel">Quick search</h3>
|
||||
<div class="searchformwrapper">
|
||||
<form class="search" action="../../../search.html" method="get">
|
||||
<input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
|
||||
<input type="submit" value="Go" />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>$('#searchbox').show(0);</script>
|
||||
</div>
|
||||
</div>
|
||||
<div class="clearer"></div>
|
||||
</div>
|
||||
<div class="related" role="navigation" aria-label="related navigation">
|
||||
<h3>Navigation</h3>
|
||||
<ul>
|
||||
<li class="right" style="margin-right: 10px">
|
||||
<a href="../../../genindex.html" title="General Index"
|
||||
>index</a></li>
|
||||
<li class="right" >
|
||||
<a href="../../../py-modindex.html" title="Python Module Index"
|
||||
>modules</a> |</li>
|
||||
<li class="nav-item nav-item-0"><a href="../../../index.html">pyFTS 1.7 documentation</a> »</li>
|
||||
<li class="nav-item nav-item-1"><a href="../../index.html" >Module code</a> »</li>
|
||||
<li class="nav-item nav-item-this"><a href="">pyFTS.partitioners.partitioner</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="footer" role="contentinfo">
|
||||
© Copyright 2022, Machine Intelligence and Data Science Laboratory - UFMG - Brazil.
|
||||
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 4.3.2.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
16
docs/build/html/_sources/pyFTS.common.rst.txt
vendored
16
docs/build/html/_sources/pyFTS.common.rst.txt
vendored
@ -12,14 +12,6 @@ Module contents
|
||||
Submodules
|
||||
----------
|
||||
|
||||
pyFTS.common.Activations module
|
||||
-------------------------------
|
||||
|
||||
.. automodule:: pyFTS.common.Activations
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
pyFTS.common.Composite module
|
||||
-----------------------------
|
||||
|
||||
@ -60,6 +52,14 @@ pyFTS.common.SortedCollection module
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
pyFTS.common.Transformations module
|
||||
-----------------------------------
|
||||
|
||||
.. automodule:: pyFTS.common.Transformations
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
pyFTS.common.Util module
|
||||
------------------------
|
||||
|
||||
|
@ -1,95 +0,0 @@
|
||||
pyFTS.common.transformations package
|
||||
====================================
|
||||
|
||||
Module contents
|
||||
---------------
|
||||
|
||||
.. automodule:: pyFTS.common.transformations
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
Submodules
|
||||
----------
|
||||
|
||||
pyFTS.common.transformations.adapativeexpectation module
|
||||
--------------------------------------------------------
|
||||
|
||||
.. automodule:: pyFTS.common.transformations.adapativeexpectation
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
pyFTS.common.transformations.boxcox module
|
||||
------------------------------------------
|
||||
|
||||
.. automodule:: pyFTS.common.transformations.boxcox
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
pyFTS.common.transformations.differential module
|
||||
------------------------------------------------
|
||||
|
||||
.. automodule:: pyFTS.common.transformations.differential
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
pyFTS.common.transformations.normalization module
|
||||
-------------------------------------------------
|
||||
|
||||
.. automodule:: pyFTS.common.transformations.normalization
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
pyFTS.common.transformations.roi module
|
||||
---------------------------------------
|
||||
|
||||
.. automodule:: pyFTS.common.transformations.roi
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
pyFTS.common.transformations.scale module
|
||||
-----------------------------------------
|
||||
|
||||
.. automodule:: pyFTS.common.transformations.scale
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
pyFTS.common.transformations.smoothing module
|
||||
---------------------------------------------
|
||||
|
||||
.. automodule:: pyFTS.common.transformations.smoothing
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
pyFTS.common.transformations.som module
|
||||
---------------------------------------
|
||||
|
||||
.. automodule:: pyFTS.common.transformations.som
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
pyFTS.common.transformations.transformation module
|
||||
--------------------------------------------------
|
||||
|
||||
.. automodule:: pyFTS.common.transformations.transformation
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
pyFTS.common.transformations.trend module
|
||||
-----------------------------------------
|
||||
|
||||
.. automodule:: pyFTS.common.transformations.trend
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
|
@ -20,14 +20,6 @@ pyFTS.partitioners.partitioner module
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
pyFTS.partitioners.Class module
|
||||
-------------------------------
|
||||
|
||||
.. automodule:: pyFTS.partitioners.Class
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
pyFTS.partitioners.CMeans module
|
||||
--------------------------------
|
||||
|
||||
|
1
docs/build/html/_sources/pyFTS.rst.txt
vendored
1
docs/build/html/_sources/pyFTS.rst.txt
vendored
@ -8,7 +8,6 @@ Subpackages
|
||||
|
||||
pyFTS.benchmarks
|
||||
pyFTS.common
|
||||
pyFTS.common.transformations
|
||||
pyFTS.data
|
||||
pyFTS.distributed
|
||||
pyFTS.hyperparam
|
||||
|
BIN
docs/build/html/_static/ajax-loader.gif
vendored
Normal file
BIN
docs/build/html/_static/ajax-loader.gif
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 673 B |
116
docs/build/html/_static/basic.css
vendored
116
docs/build/html/_static/basic.css
vendored
@ -4,7 +4,7 @@
|
||||
*
|
||||
* Sphinx stylesheet -- basic theme.
|
||||
*
|
||||
* :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
* :copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||
* :license: BSD, see LICENSE for details.
|
||||
*
|
||||
*/
|
||||
@ -130,7 +130,7 @@ ul.search li a {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
ul.search li p.context {
|
||||
ul.search li div.context {
|
||||
color: #888;
|
||||
margin: 2px 0 0 30px;
|
||||
text-align: left;
|
||||
@ -277,25 +277,25 @@ p.rubric {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
img.align-left, figure.align-left, .figure.align-left, object.align-left {
|
||||
img.align-left, .figure.align-left, object.align-left {
|
||||
clear: left;
|
||||
float: left;
|
||||
margin-right: 1em;
|
||||
}
|
||||
|
||||
img.align-right, figure.align-right, .figure.align-right, object.align-right {
|
||||
img.align-right, .figure.align-right, object.align-right {
|
||||
clear: right;
|
||||
float: right;
|
||||
margin-left: 1em;
|
||||
}
|
||||
|
||||
img.align-center, figure.align-center, .figure.align-center, object.align-center {
|
||||
img.align-center, .figure.align-center, object.align-center {
|
||||
display: block;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
|
||||
img.align-default, figure.align-default, .figure.align-default {
|
||||
img.align-default, .figure.align-default {
|
||||
display: block;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
@ -319,8 +319,7 @@ img.align-default, figure.align-default, .figure.align-default {
|
||||
|
||||
/* -- sidebars -------------------------------------------------------------- */
|
||||
|
||||
div.sidebar,
|
||||
aside.sidebar {
|
||||
div.sidebar {
|
||||
margin: 0 0 0.5em 1em;
|
||||
border: 1px solid #ddb;
|
||||
padding: 7px;
|
||||
@ -378,14 +377,12 @@ div.body p.centered {
|
||||
/* -- content of sidebars/topics/admonitions -------------------------------- */
|
||||
|
||||
div.sidebar > :last-child,
|
||||
aside.sidebar > :last-child,
|
||||
div.topic > :last-child,
|
||||
div.admonition > :last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
div.sidebar::after,
|
||||
aside.sidebar::after,
|
||||
div.topic::after,
|
||||
div.admonition::after,
|
||||
blockquote::after {
|
||||
@ -458,22 +455,20 @@ td > :last-child {
|
||||
|
||||
/* -- figures --------------------------------------------------------------- */
|
||||
|
||||
div.figure, figure {
|
||||
div.figure {
|
||||
margin: 0.5em;
|
||||
padding: 0.5em;
|
||||
}
|
||||
|
||||
div.figure p.caption, figcaption {
|
||||
div.figure p.caption {
|
||||
padding: 0.3em;
|
||||
}
|
||||
|
||||
div.figure p.caption span.caption-number,
|
||||
figcaption span.caption-number {
|
||||
div.figure p.caption span.caption-number {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
div.figure p.caption span.caption-text,
|
||||
figcaption span.caption-text {
|
||||
div.figure p.caption span.caption-text {
|
||||
}
|
||||
|
||||
/* -- field list styles ----------------------------------------------------- */
|
||||
@ -508,63 +503,6 @@ table.hlist td {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
/* -- object description styles --------------------------------------------- */
|
||||
|
||||
.sig {
|
||||
font-family: 'Consolas', 'Menlo', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', monospace;
|
||||
}
|
||||
|
||||
.sig-name, code.descname {
|
||||
background-color: transparent;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.sig-name {
|
||||
font-size: 1.1em;
|
||||
}
|
||||
|
||||
code.descname {
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
.sig-prename, code.descclassname {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
.optional {
|
||||
font-size: 1.3em;
|
||||
}
|
||||
|
||||
.sig-paren {
|
||||
font-size: larger;
|
||||
}
|
||||
|
||||
.sig-param.n {
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
/* C++ specific styling */
|
||||
|
||||
.sig-inline.c-texpr,
|
||||
.sig-inline.cpp-texpr {
|
||||
font-family: unset;
|
||||
}
|
||||
|
||||
.sig.c .k, .sig.c .kt,
|
||||
.sig.cpp .k, .sig.cpp .kt {
|
||||
color: #0033B3;
|
||||
}
|
||||
|
||||
.sig.c .m,
|
||||
.sig.cpp .m {
|
||||
color: #1750EB;
|
||||
}
|
||||
|
||||
.sig.c .s, .sig.c .sc,
|
||||
.sig.cpp .s, .sig.cpp .sc {
|
||||
color: #067D17;
|
||||
}
|
||||
|
||||
|
||||
/* -- other body styles ----------------------------------------------------- */
|
||||
|
||||
@ -691,6 +629,14 @@ dl.glossary dt {
|
||||
font-size: 1.1em;
|
||||
}
|
||||
|
||||
.optional {
|
||||
font-size: 1.3em;
|
||||
}
|
||||
|
||||
.sig-paren {
|
||||
font-size: larger;
|
||||
}
|
||||
|
||||
.versionmodified {
|
||||
font-style: italic;
|
||||
}
|
||||
@ -731,9 +677,8 @@ dl.glossary dt {
|
||||
|
||||
.classifier:before {
|
||||
font-style: normal;
|
||||
margin: 0 0.5em;
|
||||
margin: 0.5em;
|
||||
content: ":";
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
abbr, acronym {
|
||||
@ -748,7 +693,7 @@ pre {
|
||||
overflow-y: hidden; /* fixes display issues on Chrome browsers */
|
||||
}
|
||||
|
||||
pre, div[class*="highlight-"] {
|
||||
pre, div[class|="highlight"] {
|
||||
clear: both;
|
||||
}
|
||||
|
||||
@ -759,7 +704,7 @@ span.pre {
|
||||
hyphens: none;
|
||||
}
|
||||
|
||||
div[class*="highlight-"] {
|
||||
div[class^="highlight-"] {
|
||||
margin: 1em 0;
|
||||
}
|
||||
|
||||
@ -819,13 +764,8 @@ div.code-block-caption code {
|
||||
}
|
||||
|
||||
table.highlighttable td.linenos,
|
||||
span.linenos,
|
||||
div.highlight span.gp { /* gp: Generic.Prompt */
|
||||
div.doctest > div.highlight span.gp { /* gp: Generic.Prompt */
|
||||
user-select: none;
|
||||
-webkit-user-select: text; /* Safari fallback only */
|
||||
-webkit-user-select: none; /* Chrome/Safari */
|
||||
-moz-user-select: none; /* Firefox */
|
||||
-ms-user-select: none; /* IE10+ */
|
||||
}
|
||||
|
||||
div.code-block-caption span.caption-number {
|
||||
@ -840,6 +780,16 @@ div.literal-block-wrapper {
|
||||
margin: 1em 0;
|
||||
}
|
||||
|
||||
code.descname {
|
||||
background-color: transparent;
|
||||
font-weight: bold;
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
code.descclassname {
|
||||
background-color: transparent;
|
||||
}
|
||||
|
||||
code.xref, a code {
|
||||
background-color: transparent;
|
||||
font-weight: bold;
|
||||
|
2
docs/build/html/_static/bizstyle.js
vendored
2
docs/build/html/_static/bizstyle.js
vendored
@ -36,6 +36,6 @@ $(window).resize(function(){
|
||||
$("li.nav-item-0 a").text("Top");
|
||||
}
|
||||
else {
|
||||
$("li.nav-item-0 a").text("pyFTS 1.7 documentation");
|
||||
$("li.nav-item-0 a").text("pyFTS 1.6 documentation");
|
||||
}
|
||||
});
|
BIN
docs/build/html/_static/comment-bright.png
vendored
Normal file
BIN
docs/build/html/_static/comment-bright.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 756 B |
BIN
docs/build/html/_static/comment-close.png
vendored
Normal file
BIN
docs/build/html/_static/comment-close.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 829 B |
BIN
docs/build/html/_static/comment.png
vendored
Normal file
BIN
docs/build/html/_static/comment.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 641 B |
1104
docs/build/html/_static/css3-mediaqueries_src.js
vendored
Normal file
1104
docs/build/html/_static/css3-mediaqueries_src.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
16
docs/build/html/_static/doctools.js
vendored
16
docs/build/html/_static/doctools.js
vendored
@ -4,7 +4,7 @@
|
||||
*
|
||||
* Sphinx JavaScript utilities for all documentation.
|
||||
*
|
||||
* :copyright: Copyright 2007-2021 by the Sphinx team, see AUTHORS.
|
||||
* :copyright: Copyright 2007-2020 by the Sphinx team, see AUTHORS.
|
||||
* :license: BSD, see LICENSE for details.
|
||||
*
|
||||
*/
|
||||
@ -29,14 +29,9 @@ if (!window.console || !console.firebug) {
|
||||
|
||||
/**
|
||||
* small helper function to urldecode strings
|
||||
*
|
||||
* See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent#Decoding_query_parameters_from_a_URL
|
||||
*/
|
||||
jQuery.urldecode = function(x) {
|
||||
if (!x) {
|
||||
return x
|
||||
}
|
||||
return decodeURIComponent(x.replace(/\+/g, ' '));
|
||||
return decodeURIComponent(x).replace(/\+/g, ' ');
|
||||
};
|
||||
|
||||
/**
|
||||
@ -290,10 +285,9 @@ var Documentation = {
|
||||
initOnKeyListeners: function() {
|
||||
$(document).keydown(function(event) {
|
||||
var activeElementType = document.activeElement.tagName;
|
||||
// don't navigate when in search box, textarea, dropdown or button
|
||||
// don't navigate when in search box or textarea
|
||||
if (activeElementType !== 'TEXTAREA' && activeElementType !== 'INPUT' && activeElementType !== 'SELECT'
|
||||
&& activeElementType !== 'BUTTON' && !event.altKey && !event.ctrlKey && !event.metaKey
|
||||
&& !event.shiftKey) {
|
||||
&& !event.altKey && !event.ctrlKey && !event.metaKey && !event.shiftKey) {
|
||||
switch (event.keyCode) {
|
||||
case 37: // left
|
||||
var prevHref = $('link[rel="prev"]').prop('href');
|
||||
@ -301,14 +295,12 @@ var Documentation = {
|
||||
window.location.href = prevHref;
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
case 39: // right
|
||||
var nextHref = $('link[rel="next"]').prop('href');
|
||||
if (nextHref) {
|
||||
window.location.href = nextHref;
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -1,6 +1,6 @@
|
||||
var DOCUMENTATION_OPTIONS = {
|
||||
URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'),
|
||||
VERSION: '1.7',
|
||||
VERSION: '1.6',
|
||||
LANGUAGE: 'None',
|
||||
COLLAPSE_INDEX: false,
|
||||
BUILDER: 'html',
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user