Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit ac6a79c
Showing
7 changed files
with
341 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Package: EEMDSVR | ||
Type: Package | ||
Title: Ensemble Empirical Mode Decomposition and Its Variant Based | ||
Support Vector Regression Model | ||
Version: 0.1.0 | ||
Authors@R: c(person("Pankaj", "Das", role = c("aut","cre"),email="pankaj.das2@icar.gov.in"), person("Kapil", "Choudhary", role = "aut",email="choudharykapil832@gmail.com"), | ||
person("Girish", "Kumar Jha", role = "aut",email="grish.stat@gmail.com"), person("Achal", "Lama", role = "aut",email="achal.lama@icar.gov.in")) | ||
Maintainer: Pankaj Das <pankaj.das2@icar.gov.in> | ||
Description: Application of Ensemble Empirical Mode Decomposition and its variant based Support Vector regression model for univariate time series forecasting. For method details see Das (2020).<http://krishi.icar.gov.in/jspui/handle/123456789/44138>. | ||
License: GPL-3 | ||
Encoding: UTF-8 | ||
Imports: Rlibeemd,e1071 | ||
Author: Pankaj Das [aut, cre], | ||
Kapil Choudhary [aut], | ||
Girish Kumar Jha [aut], | ||
Achal Lama [aut] | ||
NeedsCompilation: no | ||
Packaged: 2021-09-18 05:13:27 UTC; Pankaj | ||
Repository: CRAN | ||
Date/Publication: 2021-09-20 09:20:05 UTC |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
38d438036cc3f59a77a65af5791474b2 *DESCRIPTION | ||
1e38c2863e86e6f86d448a218ba8a4aa *NAMESPACE | ||
7f503f070a3a85fb130250afa3c8838f *R/CEEMDSVR.R | ||
873824ce1a9afe5cf85364ad7de8d956 *R/EEMDSVR.R | ||
48ce861d9590dcd543c8005284e94895 *man/CEEMDSVR.Rd | ||
e67f599138de290b9c6a5d63e51d8989 *man/EEMDSVR.Rd |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
exportPattern("^[[:alpha:]]+") | ||
#' @importFrom ("graphics", "plot") | ||
#' @importFrom ("stats", "predict") | ||
#' @import (Rlibeemd) | ||
#' @import (e1071) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
|
||
#Complementary Ensemble Empirical Mode Decomposition Based Support Vector Regression Model | ||
CEEMDSVR=function(data,k,ensem.size, ker.funct="",svm.type=""){ | ||
|
||
data_org=as.matrix(data) | ||
xt=as.matrix(data_org) | ||
xt=as.vector(data_org) | ||
|
||
#code for display no.of imf and residual | ||
|
||
try=Rlibeemd::ceemdan(xt,ensemble_size =ensem.size) | ||
|
||
imf_extr=try[,-ncol(try)] | ||
total_IMF=ncol(imf_extr) | ||
emd_residual=try[,ncol(try)] | ||
no_of_imf=ncol(imf_extr) | ||
len_extr_imf=length(imf_extr[,1]) | ||
length_split=len_extr_imf-1 | ||
test_data_l=ceiling(k*length_split) | ||
test_data_original=data_org[(test_data_l+2):length(data_org),] | ||
length_test_data=length(test_data_original) | ||
# dataset creation | ||
extr_imf=0 | ||
model_svm=0 | ||
predicted_out=matrix(nrow =length_test_data,ncol = no_of_imf) | ||
MSE_out=0 | ||
RMSE_out=0 | ||
MAPE_out=0 | ||
MAD_out=0 | ||
final_predict_imf=0 | ||
for (i in 1:no_of_imf) | ||
{ | ||
extr_imf=imf_extr[,i] | ||
|
||
yt=extr_imf[1:(len_extr_imf-1)] | ||
xt=extr_imf[2:len_extr_imf] | ||
data=data.frame(yt,xt) | ||
len_data=length(data[,1]) | ||
split_train=k*len_data | ||
r_train=ceiling(split_train) | ||
traindata=data[1:r_train,] | ||
testdata=data[(r_train+1):len_data,] | ||
|
||
model_svm<-e1071::svm(yt ~ ., data=traindata,kernel=ker.funct,type=svm.type) | ||
print(model_svm) | ||
predicted_out[,i]<- stats::predict(model_svm,testdata) | ||
final_predict_imf=final_predict_imf+predicted_out[,i] | ||
} | ||
emd_residual | ||
lenght_of_residual=length(emd_residual) | ||
|
||
#differencing | ||
dif_resid=base::diff(emd_residual) | ||
len_dresid=length(dif_resid) | ||
#spliting of data set | ||
ytr=dif_resid[1:(len_dresid-1)] | ||
xtr=extr_imf[2:len_dresid] | ||
datar=data.frame(ytr,xtr) | ||
len_datar=length(datar[,1]) | ||
split_trainr=k*len_datar | ||
r_trainr=round((split_trainr),1) | ||
traindatar=datar[1:r_trainr,] | ||
testdatar=datar[(r_trainr+1):len_datar,] | ||
|
||
model_svmr <-e1071::svm(ytr ~ ., data=traindatar,kernel=ker.funct,type=svm.type) | ||
summary(model_svmr) | ||
|
||
#out sample | ||
predicted_outr <- stats::predict(model_svmr,testdatar) | ||
length_residual_predict=length(testdatar[,1]) | ||
adding_residual_length=lenght_of_residual-length_residual_predict | ||
final_prediction=final_predict_imf+predicted_outr+emd_residual[-(1:adding_residual_length)] | ||
|
||
# summarize accuracy | ||
MSE_out <- mean((test_data_original - final_prediction)^2) | ||
RMSE_out<- sqrt(MSE_out) | ||
|
||
|
||
#mean absolute deviation (MAD) | ||
MAD_out=mean(abs(test_data_original - final_prediction)) | ||
|
||
|
||
#Mean absolute percent error (MAPE) | ||
MAPE_out=mean(abs((test_data_original-final_prediction)/test_data_original)) | ||
|
||
|
||
#Maximum Error | ||
ME_out=max(abs(test_data_original-final_prediction)) | ||
#accuracy | ||
prediction_accuracy=cbind(RMSE_out,MAD_out,MAPE_out,ME_out) | ||
#ploting IMF | ||
Plot_IMFs <- try | ||
AllIMF_plots <- graphics::plot(Plot_IMFs) | ||
|
||
TotalIMF = no_of_imf | ||
output_f=list(Total_No_IMF=TotalIMF, Prediction_Accuracy_CEEMDSVR =prediction_accuracy, Final_Prediction_CEEMDSVR =final_prediction) | ||
return(output_f) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
|
||
#Ensemble Empirical Mode Decomposition Based Support Vector Regression Model | ||
EEMDSVR=function(data,k,ensem.size, ker.funct="",svm.type=""){ | ||
|
||
data_org=as.matrix(data) | ||
xt=as.matrix(data_org) | ||
xt=as.vector(data_org) | ||
|
||
#code for display no.of imf and residual | ||
|
||
try=Rlibeemd::eemd(xt,ensemble_size =ensem.size) | ||
|
||
imf_extr=try[,-ncol(try)] | ||
total_IMF=ncol(imf_extr) | ||
emd_residual=try[,ncol(try)] | ||
no_of_imf=ncol(imf_extr) | ||
len_extr_imf=length(imf_extr[,1]) | ||
length_split=len_extr_imf-1 | ||
test_data_l=ceiling(k*length_split) | ||
test_data_original=data_org[(test_data_l+2):length(data_org),] | ||
length_test_data=length(test_data_original) | ||
# dataset creation | ||
extr_imf=0 | ||
model_svm=0 | ||
predicted_out=matrix(nrow =length_test_data,ncol = no_of_imf) | ||
MSE_out=0 | ||
RMSE_out=0 | ||
MAPE_out=0 | ||
MAD_out=0 | ||
final_predict_imf=0 | ||
for (i in 1:no_of_imf) | ||
{ | ||
extr_imf=imf_extr[,i] | ||
|
||
yt=extr_imf[1:(len_extr_imf-1)] | ||
xt=extr_imf[2:len_extr_imf] | ||
data=data.frame(yt,xt) | ||
len_data=length(data[,1]) | ||
split_train=k*len_data | ||
r_train=ceiling(split_train) | ||
traindata=data[1:r_train,] | ||
testdata=data[(r_train+1):len_data,] | ||
|
||
model_svm<-e1071::svm(yt ~ ., data=traindata,kernel=ker.funct,type=svm.type) | ||
print(model_svm) | ||
predicted_out[,i]<- stats::predict(model_svm,testdata) | ||
final_predict_imf=final_predict_imf+predicted_out[,i] | ||
} | ||
emd_residual | ||
lenght_of_residual=length(emd_residual) | ||
|
||
#differencing | ||
dif_resid=base::diff(emd_residual) | ||
len_dresid=length(dif_resid) | ||
#spliting of data set | ||
ytr=dif_resid[1:(len_dresid-1)] | ||
xtr=extr_imf[2:len_dresid] | ||
datar=data.frame(ytr,xtr) | ||
len_datar=length(datar[,1]) | ||
split_trainr=k*len_datar | ||
r_trainr=round((split_trainr),1) | ||
traindatar=datar[1:r_trainr,] | ||
testdatar=datar[(r_trainr+1):len_datar,] | ||
|
||
model_svmr <-e1071::svm(ytr ~ ., data=traindatar,kernel=ker.funct,type=svm.type) | ||
summary(model_svmr) | ||
|
||
#out sample | ||
predicted_outr <- stats::predict(model_svmr,testdatar) | ||
length_residual_predict=length(testdatar[,1]) | ||
adding_residual_length=lenght_of_residual-length_residual_predict | ||
final_prediction=final_predict_imf+predicted_outr+emd_residual[-(1:adding_residual_length)] | ||
|
||
# summarize accuracy | ||
MSE_out <- mean((test_data_original - final_prediction)^2) | ||
RMSE_out<- sqrt(MSE_out) | ||
|
||
|
||
#mean absolute deviation (MAD) | ||
MAD_out=mean(abs(test_data_original - final_prediction)) | ||
|
||
|
||
#Mean absolute percent error (MAPE) | ||
MAPE_out=mean(abs((test_data_original-final_prediction)/test_data_original)) | ||
|
||
|
||
#Maximum Error | ||
ME_out=max(abs(test_data_original-final_prediction)) | ||
#accuracy | ||
prediction_accuracy=cbind(RMSE_out,MAD_out,MAPE_out,ME_out) | ||
#ploting IMF | ||
Plot_IMFs <- try | ||
AllIMF_plots <- graphics::plot(Plot_IMFs) | ||
TotalIMF = no_of_imf | ||
output_f=list(Total_No_IMF=TotalIMF, Prediction_Accuracy_EEMDSVR =prediction_accuracy, Final_Prediction_EEMDSVR =final_prediction) | ||
return(output_f) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
\name{CEEMDSVR} | ||
\alias{CEEMDSVR} | ||
\title{ | ||
Complementary Ensemble Empirical Mode Decomposition Based Support Vector Regression Model | ||
} | ||
\description{ | ||
The CEEMDSVR function helps to fit the Complementary Ensemble Empirical Mode Decomposition with Adaptive Noise Based Support Vector Regression Model. It will also provide you with accuracy measures along with an option to select the proportion of training and testing data sets. Users can choose among the available choices of kernel and types of regresion model for fitting the Support Vector Regression model. In this package we have modelled the dependency of the study variable assuming first order autocorrelation. This package will help the researchers working in the area of hybrid machine learning models. | ||
} | ||
\usage{ | ||
CEEMDSVR(data,k,ensem.size, ker.funct="",svm.type="") | ||
} | ||
\arguments{ | ||
\item{data}{ | ||
Input univariate time series data. | ||
} | ||
\item{k}{ | ||
Partition value for spliting the data set into training and testing. | ||
} | ||
\item{ensem.size}{ | ||
Number of copies of the input signal to use as the ensemble. | ||
} | ||
\item{ker.funct}{ | ||
The available choices of kernel functions like radial basis, linear, polynomial and sigmoidfor fitting Support Vector Regression. By default radial basis function works. | ||
} | ||
\item{svm.type}{ | ||
SVM can be used as a regression machine. User can apply eps-regression or nu-regression. By default the CEEMDSVR uses eps-regression. | ||
} | ||
} | ||
\details{ | ||
Torres et al.(2011) proposed Complementary Ensemble Empirical Mode Decomposition with Adaptive Noise (CEEMDAN). This algorithm generates a Fewer IMFs on the premise of successfully separating different components of a series, which can reduce the computational cost. Further Support Vector Regression (SVR) model applied to each decomposed items to forecast them. Finally all forecasted values are aggregated to produce final forecast value (Das et al, 2020). | ||
} | ||
\value{ | ||
\item{Total_No_IMF }{Total number of IMFs after decomposition by EEMD method.} | ||
\item{Prediction_Accuracy_CEEMDSVR }{List of performance measures of the fitted CEEMDSVR model.} | ||
\item{Final_Prediction_CEEMDSVR }{Final forecasted value of the CEEMDAN based SVR model. It is obtained by combining the forecasted value of all individual IMF and fresidue.} | ||
} | ||
\author{ | ||
Pankaj Das, Kapil Choudhary, Girish Kumar Jha, Achal Lama | ||
} | ||
\references{ | ||
Torres, M.E., Colominas, M.A., Schlotthauer, G. and Flandrin, P. (2011). A complete ensemble empirical mode decomposition with adaptive noise. In 2011 IEEE international conference on acoustics, speech and signal processing (ICASSP) (pp. 4144--4147). IEEE. | ||
|
||
Das,P., Jha,G. K.,Lama,A., Parsad, R. and Mishra, D. (2020). Empirical Mode Decomposition based Support Vector Regression for Agricultural Price Forecasting. Indian Journal of Extension Education, 56(2): 7-12. (http://krishi.icar.gov.in/jspui/handle/123456789/44138). | ||
|
||
Das, P. (2019). Study On Machine Learning Techniques Based Hybrid Model for Forecasting in Agriculture. Published Ph.D. Thesis. (http://krishikosh.egranth.ac.in/handle/1/5810147805). | ||
} | ||
\seealso{ | ||
EMDSVRhybrid, CEEMD, EEMDSVR | ||
} | ||
\examples{ | ||
set.seed(6) | ||
example_data=rnorm(500,30,5) | ||
CEEMDSVR(example_data,0.9,250,"radial","nu-regression") | ||
} | ||
\keyword{CEEMDSVR} | ||
\keyword{CEEMDAN} | ||
\keyword{SVR} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
\name{EEMDSVR} | ||
\alias{EEMDSVR} | ||
\title{ | ||
Ensemble Empirical Mode Decomposition Based Support Vector Regression Model | ||
} | ||
\description{ | ||
The EEMDSVR function helps to fit the Ensemble Empirical Mode Decomposition with Adaptive Noise Based Support Vector Regression Model. It will also provide you with accuracy measures along with an option to select the proportion of training and testing data sets. Users can choose among the available choices of kernel and types of regresion model for fitting the Support Vector Regression model. In this package we have modelled the dependency of the study variable assuming first order autocorrelation. This package will help the researchers working in the area of hybrid machine learning models. | ||
} | ||
\usage{ | ||
EEMDSVR(data,k,ensem.size, ker.funct="",svm.type="") | ||
} | ||
\arguments{ | ||
\item{data}{ | ||
Input univariate time series data. | ||
} | ||
\item{k}{ | ||
Partition value for spliting the data set into training and testing. | ||
} | ||
\item{ensem.size}{ | ||
Number of copies of the input signal to use as the ensemble. | ||
} | ||
\item{ker.funct}{ | ||
The available choices of kernel functions like radial basis, linear, polynomial and sigmoid for fitting Support Vector Regression. By default radial basis function works. | ||
} | ||
\item{svm.type}{ | ||
SVM can be used as a regression machine. User can apply eps-regression or nu-regression. By default the CEEMDSVR uses eps-regression. | ||
} | ||
} | ||
\details{ | ||
Ensemble Empirical Mode Decomposition (EEMD) method was developed by Wu and Huang (2009).EEMD significantly reduces the chance of mode mixing and represents a substantial improvement over the original EMD. This algorithm generates a Fewer IMFs on the premise of successfully separating different components of a series. Further Support Vector Regression (SVR) model applied to each decomposed components to forecast them. Finally all forecasted values are aggregated to produce final forecast value (Das et al, 2020). | ||
} | ||
\value{ | ||
\item{Total_No_IMF }{Total number of IMFs after decomposition by EEMD method.} | ||
\item{Prediction_Accuracy_CEEMDSVR }{List of performance measures of the fitted CEEMDSVR model.} | ||
\item{Final_Prediction_CEEMDSVR }{Final forecasted value of the CEEMDAN based SVR model. It is obtained by combining the forecasted value of all individual IMF and fresidue.} | ||
} | ||
\author{ | ||
Pankaj Das, Kapil Choudhary, Girish Kumar Jha, Achal Lama | ||
} | ||
\references{ | ||
Das, P. (2019). Study On Machine Learning Techniques Based Hybrid Model for Forecasting in Agriculture. Published Ph.D. Thesis. (http://krishikosh.egranth.ac.in/handle/1/5810147805). | ||
|
||
Das,P., Jha,G. K.,Lama,A., Parsad, R. and Mishra, D. (2020). Empirical Mode Decomposition based Support Vector Regression for Agricultural Price Forecasting. Indian Journal of Extension Education, 56(2), 7-12. (http://krishi.icar.gov.in/jspui/handle/123456789/44138). | ||
|
||
Wu, Z. and Huang, N.E. (2009) Ensemble empirical mode decomposition: a noise assisted data analysis method. Advances in adaptive data analysis, 1(1), 1-41. | ||
|
||
} | ||
\seealso{ | ||
EMDSVRhybrid, CEEMD | ||
} | ||
\examples{ | ||
set.seed(6) | ||
example_data=rnorm(500,30,5) | ||
EEMDSVR(example_data,0.9,250,"radial","nu-regression") | ||
} | ||
\keyword{EEMDSVR} | ||
\keyword{EEMD} | ||
\keyword{SVR} |