Skip to content

Commit

Permalink
Fixing Scree Graph
Browse files Browse the repository at this point in the history
  • Loading branch information
rolandojduartem committed Dec 1, 2021
1 parent 28f63ff commit 6def5ec
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 1,027 deletions.
1,012 changes: 0 additions & 1,012 deletions FTSExample/FTSExample.ipynb

This file was deleted.

25 changes: 17 additions & 8 deletions FillingTimeSeries/FillingMethods.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Note: V 0.9.1 Originally, filling data methods was developed by Eric Alfaro and Javier Soley in SCILAB
Note: V 0.9.2 Originally, filling data methods was developed by Eric Alfaro and Javier Soley in SCILAB
Python version was developed by Rolando Duarte and Erick Rivera
Centro de Investigaciones Geofísicas (CIGEFI)
Universidad de Costa Rica (UCR)
Expand Down Expand Up @@ -154,25 +154,33 @@ def checkPrincipalComponents(self):
upperError: int
Maximum value to choose principal components
"""
#Scalating to get the best performance using PCA
scale = StandardScaler()
dfMeanScaled = scale.fit_transform(self.dfMean)
pca = PCA(n_components = self.dfColumns, copy = True, svd_solver = "full", random_state = 0)
pca.fit(dfMeanScaled)
vectorsPCA = pca.fit_transform(dfMeanScaled)
explainedVariance = pca.explained_variance_
errorExplainedVarience = explainedVariance * sqrt(2 / self.dfRows)
errorExplainedVarience = []

#Calculating error bars
for index in arange(0, len(explainedVariance)):
dfComponents = DataFrame({"Original": vectorsPCA[:, index]})
dfComponents["Shift"] = dfComponents.Original.shift(1)
corr = dfComponents.corr().iloc[0, 1]
nEffective = self.dfRows * (1 - corr**2) / (1 + corr**2)
errorExplainedVarience.append(explainedVariance[index] * sqrt(2 / nEffective))
components = arange(1, len(explainedVariance) + 1)
upperError = len(explainedVariance) - 1

figure(figsize = (20, 20))
#Plotting eigenvalues and principal components
errorbar(components, explainedVariance,
yerr=errorExplainedVarience, fmt="o", color="#9b6dff",
ecolor="black", capsize=6,
yerr=errorExplainedVarience, fmt="D", color="green",
ecolor="red", capsize=10,
)
title("Explained variance vs. principal components")
xlabel("Principal components")
ylabel("Explained variance")
show()

return upperError

def PCAMethod(self, components=1, tol=1e-1, itermax=10, valueMin=0.0):
Expand Down Expand Up @@ -247,7 +255,8 @@ def checkPrincipalComponents(self):
upperError: int
Maximum value to choose principal components
"""
return PrincipalComponentAnalysis(self.df).checkPrincipalComponents()
upperError = PrincipalComponentAnalysis(self.df).checkPrincipalComponents()
return upperError

def FullMethod(self, lags=1, components=1, tol=1e-1, itermax=10, valueMin=0.0):
"""
Expand Down
2 changes: 1 addition & 1 deletion FillingTimeSeries/PreprocessingFillingMethods.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
Note: V 0.9.1 Originally, filling data methods was developed by Eric Alfaro and Javier Soley in SCILAB
Note: V 0.9.2 Originally, filling data methods was developed by Eric Alfaro and Javier Soley in SCILAB
Python version was developed by Rolando Duarte and Erick Rivera
Centro de Investigaciones Geofísicas (CIGEFI)
Universidad de Costa Rica (UCR)
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Filling Time Series (v.0.9.1)
# Filling Time Series (v.0.9.2)

## Filling missing values in geophysical time series

Expand All @@ -10,9 +10,7 @@
Filling Time Series is a Python package to help the users to work with geophysical time series by filling missing values in their data. Filling Time Series was developed at the Centro de Investigaciones Geofísicas (CIGEFI), Universidad de Costa Rica (UCR).

## Last updates
- Added new method: ComponentsAutoregression applies autoregression method, then, the principal components method to fill the time series.
- Small fixes in the Scree graph.
- Renaming some classes, please, check documentation.
- Fixing the error bar calculation.

## Documentation
Documentation will be available soon.
Expand Down Expand Up @@ -44,6 +42,10 @@ Bug reports can be submitted to the issue tracker at:

[https://github.com/rolandojduartem/FillingTimeSeries/issues](https://github.com/rolandojduartem/FillingTimeSeries/issues)

## References
- Alfaro, E., & Soley, J. (2009). Descripción de dos métodos de rellenado de datos ausentes en series de tiempo metereológicos. Revista de matemática: Teoría y Aplicaciones, 16, 60 - 75.
- Ureña, P., Alfaro, E., & Soley, J. (2016). Propuestas metodológicas para el rellenado de datos ausentes en series de tiempo geofísicas. Guía Práctica de uso. Universidad de Costa Rica.

## License

MIT License
Expand Down
Binary file removed dist/FillingTimeSeries-0.9.1-py3-none-any.whl
Binary file not shown.
Binary file removed dist/FillingTimeSeries-0.9.1.tar.gz
Binary file not shown.
Binary file added dist/FillingTimeSeries-0.9.2-py3-none-any.whl
Binary file not shown.
Binary file added dist/FillingTimeSeries-0.9.2.tar.gz
Binary file not shown.
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
setup(
name = 'FillingTimeSeries',
packages = ['FillingTimeSeries'],
version = '0.9.1',
version = '0.9.2',
license='MIT', # License from here: https://help.github.com/articles/licensing-a-repository
description = 'Filling Time series: Package to fill missing values in geophysical time series in Python', # Short description
long_description = long_description,
long_description_content_type = "text/markdown",
author = 'Rolando Jesus Duarte Mejias, Erick Rivera Fernandez',
author_email = '[email protected]',
url = 'https://github.com/rolandojduartem/FillingTimeSeries', # github or website
download_url = 'https://github.com/rolandojduartem/FillingTimeSeries/archive/refs/tags/v_0_9_1.tar.gz', # Download file
download_url = 'https://github.com/rolandojduartem/FillingTimeSeries/archive/refs/tags/v_0_9_2.tar.gz', # Download file
keywords = ['Time Series', 'Missing values', 'Metereology', "Geophysics", "Metereological"],
setup_requires=['wheel'],
install_requires=[ # I get to this in a second
Expand Down

0 comments on commit 6def5ec

Please sign in to comment.