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]
Original data set
###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
inputsTrain_pca$x[,1:5]->pca5
###training svm and see the errors of training set
svm(pca5,targetsTrainReg,gamma=10,cost=0.0001,epsilon=0.0001)->svmFit_pca
predict(svmFit_pca,newdata=pca5)->svm_pred_pca_train
modelErrors(svm_pred_pca_train,targetsTrainReg)
## MAE RMSE RELE
## 0.09592 0.12206 0.30332
ICA
ica <- fastICA(inputsTrain, 5, alg.typ = "parallel", fun = "logcosh", alpha = 1,
method = "R", row.norm = FALSE, maxit = 500,
tol = 0.0001, verbose = TRUE)
## Centering
## Whitening
## Symmetric FastICA using logcosh approx. to neg-entropy function
## Iteration 1 tol = 0.3096
## Iteration 2 tol = 0.02118
## Iteration 3 tol = 0.003734
## Iteration 4 tol = 0.00117
## Iteration 5 tol = 0.000437
## Iteration 6 tol = 0.0001193
## Iteration 7 tol = 2.924e-05
##first 5 components and see the errors of training set
ica5<-ica$S
svm(ica5,targetsTrainReg,gamma=1,cost=0.0001,epsilon=0.0001)->svmFit_ica
predict(svmFit_ica,newdata=ica5)->svm_pred_ica_train
modelErrors(svm_pred_ica_train,targetsTrainReg)
## MAE RMSE RELE
## 0.09586 0.12200 0.30315