Giter VIP home page Giter VIP logo

petolau / tsrepr Goto Github PK

View Code? Open in Web Editor NEW
96.0 10.0 23.0 857 KB

TSrepr: R package for time series representations

Home Page: https://petolau.github.io/package/

License: GNU General Public License v3.0

R 61.13% C++ 38.87%
time-series-analysis time-series-data-mining time-series-classification time-series-clustering representation data-science data-analysis data-mining-algorithms data-mining time-series

tsrepr's Introduction

TSrepr

Travis-CI Build Status CRAN_Status_Badge Downloads Downloads

codecov.io DOI

TSrepr is R package for fast time series representations and dimensionality reduction computations. Z-score normalisation, min-max normalisation, forecasting accuracy measures and other useful functions implemented in C++ (Rcpp) and R.

Installation

You can install TSrepr directly from CRAN:

install.packages("TSrepr")

Or development version from GitHub with:

# install.packages("devtools")
devtools::install_github("PetoLau/TSrepr")

Overview

All type of time series representations methods are implemented, and these are so far:

  • Nondata adaptive:
    • PAA - Piecewise Aggregate Approximation (repr_paa)
    • DWT - Discrete Wavelet Transform (repr_dwt)
    • DFT - Discrete Fourier Transform (repr_dft)
    • DCT - Discrete Cosine Transform (repr_dct)
    • SMA - Simple Moving Average (repr_sma)
    • PIP - Perceptually Important Points (repr_pip)
  • Data adaptive:
    • SAX - Symbolic Aggregate Approximation (repr_sax)
    • PLA - Piecewise Linear Approximation (repr_pla)
  • Model-based:
    • Mean seasonal profile - Average seasonal profile, Median seasonal profile, etc. (repr_seas_profile)
    • Model-based seasonal representations based on linear (additive) model (LM, RLM, L1, GAM) (repr_lm, repr_gam)
    • Exponential smoothing seasonal coefficients (repr_exp)
  • Data dictated:
    • FeaClip - Feature extraction from clipping representation (repr_feaclip, clipping)
    • FeaTrend - Feature extraction from trending representation (repr_featrend, trending)
    • FeaClipTrend - Feature extraction from clipping and trending representation (repr_feacliptrend)

Additional useful functions are implemented as:

  • Windowing (repr_windowing) - applies above mentioned representations to every window of a time series
  • Matrix of representations (repr_matrix) - applies above mentioned representations to every row of a matrix of time series
  • List of representations (repr_list) - applies above mentioned representations to every member of a list of time series with different lengths
  • Normalisation functions - z-score (norm_z), min-max (norm_min_max), arctan (norm_atan), Box-Cox (norm_boxcox), Yeo-Johnson (norm_yj)
  • Normalisation functions with output also of scaling parameters - z-score (norm_z_list), min-max (norm_min_max_list)
  • Normalisation functions with defined parameters - z-score (norm_z_params), min-max (norm_min_max_params)
  • Denormalisation functions - z-score (denorm_z), min-max (denorm_min_max), arctan (denorm_atan), Box-Cox (denorm_boxcox), Yeo-Johnson (denorm_yj)
  • Forecasting accuracy measures - MSE, MAE, RMSE, MdAE, MAPE, sMAPE, MAAPE, MASE

Usage

library(TSrepr)
library(ggplot2)

data_ts <- as.numeric(elec_load[5,]) # electricity load consumption data
# Comparison of PAA and PLA
# Dimensionality of the time series will be reduced 8 times
data_paa <- repr_paa(data_ts, q = 12, func = mean)
data_pla <- repr_pla(data_ts, times = 55, return = "both") # returns both extracted places and values

data_plot <- data.frame(value = c(data_ts, data_paa, data_pla$points),
                        time = c(1:length(data_ts), seq(6, length(data_ts), by = 12),
                                 data_pla$places),
                        type = factor(c(rep("Original", length(data_ts)),
                                        rep(c("PAA", "PLA"), each = 56))))

ggplot(data_plot, aes(time, value, color = type, size = type)) +
  geom_line(alpha = 0.8) +
  scale_size_manual(values = c(0.6, 0.8, 0.8)) +
  theme_bw()

For more information

Contact

Citation

Cite the package as:

tsrepr's People

Contributors

petolau avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

tsrepr's Issues

shifting the start day of `repr_lm`

I have weekly data that starts on a Tuesday. The output after using the repr_lm function will therefore begin on Tuesday when plotting in ggplot2. Is it possible to shift the starting day to another day (i.e., I would like the plot to start on Monday). Thank you!

How to representation for many time-series data

Dear @PetoLau

I have 298 time-series dataset, may ask you about how do that like a return dataframe. of all time-series.

b_repr_df<- reinterpolate(b_lst_df[2L:298L], new.length = max(lengths(b_lst_df[2L:298L])))
b_repr_df<- repr_pla(b_lst_df[2L:298L],time=1090)

it will show an error like this

Error in repr_pla(b_lst_df[2L:297L]) : 
  (list) object cannot be coerced to type 'double'

but if i run one by one time-series, it is no problem.
b_repr_df<- repr_pla(b_lst_df$coin, time= 1090, return='both')

MASE

I saw that you calculate MASE by "error = diff / denom;". However, according to Hyndman, Koehler (2006) your "denom" should be defined as (1/ (N-m)) * sum(abs( korrekt(i) - naive(i-m))) (with m being the time-shift). I think your calculation misses this.

repr_sma unexpected output

Captura-de-pantalla-de-2020-06-24-18-40-29

Hi, I was using your repr_sma function but the result was not consistent with the input, then I tried it with simple examples and still got unexpected results.

Community guidelines

This is detailed feedback for your JOSS review openjournals/joss-reviews#577.

There’s an email contact for questions and comments, but no guidelines for contribution. I would suggest adding a CONTRIBUTING.md file to the repository. I browsed through some ROpenSci packages and many of them have guidelines like this. For example:

Unable to install TSrepr in R studio

when i write below line, it produces the error in loadnamespace
library("TSrepr", lib.loc="~/R/win-library/3.2")
Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) :
namespace ‘Rcpp’ 0.12.10 is being loaded, but >= 0.12.12 is required
In addition: Warning message:
package ‘TSrepr’ was built under R version 3.5.1
Error: package or namespace load failed for ‘TSrepr’

Help me.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.