library(caret)
## Loading required package: lattice
## Loading required package: ggplot2
library(e1071)
library(fastICA)
load("~/PED/prepareDataDay/PP_new.RData")
load("~/PED/datasets/dataset_ 14 _prepared.RData")
source('~/functions/normalizationFunction.R', echo=TRUE)
##
## > normalized <- function(x) {
## + (x - min(x)) * 0.8/(max(x) - min(x)) + 0.1
## + }
source('~/functions/calculateErrors.R', echo=TRUE)
##
## > modelErrors <- function(predicted, actual) {
## + sal <- vector(mode = "numeric", length = 3)
## + names(sal) <- c("MAE", "RMSE", "RELE")
## + me .... [TRUNCATED]
##
## > modelsErrorsTotal <- 0
##
## > allModelErrors <- function(models, inputsTest, targetsTest,
## + dataset) {
## + error <- function(model) {
## + pd <- predict(model, newdat .... [TRUNCATED]
with the whole features
###training svm and see the errors of training set
svm(inputsTrain,targetsTrainReg,gamma=10,cost=0.0001,epsilon=0.0001)->svmFit
predict(svmFit,newdata=inputsTrain)->svm_pred_train
modelErrors(svm_pred_train,targetsTrainReg)
## MAE RMSE RELE
## 0.09593 0.12206 0.30333
PCA Analysis
inputsTrain_pca<-prcomp(inputsTrain)
plot(inputsTrain_pca)
###select the first 5 components
pca<-list()
svmFit_pca<-list()
svm_pred_pca_train<-list()
pca_errors<-list()
pca_errors2<-data.frame()
for (i in 1:6){
inputsTrain_pca$x[,1:i]->pca[[i]]
###training svm and see the errors of training set
svm(pca[[i]],targetsTrainReg,gamma=10,cost=0.0001,epsilon=0.0001)->svmFit_pca[[i]]
predict(svmFit_pca[[i]],newdata=pca[[i]])->svm_pred_pca_train[[i]]
modelErrors(svm_pred_pca_train[[i]],targetsTrainReg)->pca_errors[[i]]
rbind(pca_errors2, pca_errors[[i]])->pca_errors2
}
colnames(pca_errors2)<-c("MAE","RMSE","RELE")
pca_errors2
## MAE RMSE RELE
## 1 0.09590 0.1220 0.3033
## 2 0.09590 0.1220 0.3033
## 3 0.09591 0.1220 0.3033
## 4 0.09592 0.1221 0.3033
## 5 0.09592 0.1221 0.3033
## 6 0.09593 0.1221 0.3033
ICA
ica<-list()
icaS<-list()
svmFit_ica<-list()
svm_pred_ica_train<-list()
ica_errors<-list()
ica_errors2<-data.frame()
for(i in 1:6){
ica [[i]]<- fastICA(inputsTrain, i, alg.typ = "parallel", fun = "logcosh", alpha = 1,
method = "R", row.norm = FALSE, maxit = 500,
tol = 0.0001, verbose = TRUE)
icaS[[i]]<-ica[[i]]$S
##first i components and see the errors of training set
svm(icaS[[i]],targetsTrainReg,gamma=1,cost=0.0001,epsilon=0.0001)->svmFit_ica[[i]]
predict(svmFit_ica[[i]],newdata=icaS[[i]])->svm_pred_ica_train[[i]]
modelErrors(svm_pred_ica_train[[i]],targetsTrainReg)->ica_errors[[i]]
rbind(ica_errors2, ica_errors[[i]])->ica_errors2
}
## Centering
## Whitening
## Symmetric FastICA using logcosh approx. to neg-entropy function
## Iteration 1 tol = 0
## Centering
## Whitening
## Symmetric FastICA using logcosh approx. to neg-entropy function
## Iteration 1 tol = 0.08497
## Iteration 2 tol = 0.002459
## Iteration 3 tol = 8.721e-08
## Centering
## Whitening
## Symmetric FastICA using logcosh approx. to neg-entropy function
## Iteration 1 tol = 0.3846
## Iteration 2 tol = 0.04136
## Iteration 3 tol = 0.0002736
## Iteration 4 tol = 7.198e-06
## Centering
## Whitening
## Symmetric FastICA using logcosh approx. to neg-entropy function
## Iteration 1 tol = 0.9695
## Iteration 2 tol = 0.1328
## Iteration 3 tol = 0.02313
## Iteration 4 tol = 0.0004695
## Iteration 5 tol = 1.203e-05
## Centering
## Whitening
## Symmetric FastICA using logcosh approx. to neg-entropy function
## Iteration 1 tol = 0.6401
## Iteration 2 tol = 0.1644
## Iteration 3 tol = 0.01392
## Iteration 4 tol = 0.0008403
## Iteration 5 tol = 6.078e-05
## Centering
## Whitening
## Symmetric FastICA using logcosh approx. to neg-entropy function
## Iteration 1 tol = 0.9452
## Iteration 2 tol = 0.9858
## Iteration 3 tol = 0.9654
## Iteration 4 tol = 0.857
## Iteration 5 tol = 0.5986
## Iteration 6 tol = 0.1664
## Iteration 7 tol = 0.007626
## Iteration 8 tol = 0.0013
## Iteration 9 tol = 0.0001781
## Iteration 10 tol = 5.412e-05
colnames(ica_errors2)<-c("MAE","RMSE","RELE")
ica_errors2
## MAE RMSE RELE
## 1 0.09592 0.1221 0.3032
## 2 0.09581 0.1219 0.3034
## 3 0.09572 0.1218 0.3029
## 4 0.09582 0.1219 0.3031
## 5 0.09586 0.1220 0.3032
## 6 0.09589 0.1220 0.3033
O3~PC1,O3~CA1
data.frame(cbind(pc1=pca[[1]],targetsTrainReg))->pc1_targets
plot(pc1_targets$pc1,pc1_targets$targetsTrainReg)
data.frame(cbind(icaS[[1]],targetsTrainReg))->ica1_targets
colnames(ica1_targets)<-c("ica1","targetsTrainReg")
plot(ica1_targets$ica1,ica1_targets$targetsTrainReg)