I ran the following code for a binary classification task w/ an SVM in both R. Given…
- User
I ran the following code for a binary classification task w/ an SVM in both R. Given randomly generated data (X) and response (Y), this code performs leave group out cross validation 1000 times. Each entry of Y is therefore the mean of the prediction across CV iterations. Computing area under the curve should give ~0.5, since X and Y are completely random. However, this is not what we see. Area under the curve is frequently significantly higher than 0.5. The number of rows of X is very small, which can obviously cause problems. Any idea what could be happening here? I know that I can either increase the number of rows of X or decrease the number of columns to mediate the problem, but I am looking for other issues.
Y=as.factor(rep(c(1,2), times=14)) X=matrix(runif(length(Y)*100), nrow=length(Y))
library(e1071) library(pROC)
colnames(X) <- 1:ncol(X) iter <- 1000 ansMat <- matrix(NA,length(Y),iter) r <- numeric(iter) for(i in seq(iter)){
#get traintrain <- sample(seq(length(Y)),0.5*length(Y)) if(min(table(Y[train]))==0) next
#test from train test <- seq(length(Y))[-train]
#train model XX=X[train,] YY=Y[train] mod=svm(XX,YY,probability =FALSE) XXX=X[test,] predVec=predict(mod,XXX, decision.values = TRUE) RFans = attr(predVec,'decision.values') #ansMat[test,i]=RFans r[i] <- roc(Y[test], RFans)$auc } mean(r) ans=rowMeans(ansMat,na.rm=TRUE)
r1=roc(Y,ans)$auc print(r1)
- Assistant
There are a few potential issues that could be causing the higher than expected area under the curve (AUC) values:
-
Randomness in the data: Even though the data is randomly generated, there is still a chance that some patterns or relationships could exist in the data that the SVM is picking up on. This could result in higher AUC values.
-
Small sample size: As you mentioned, the small number of rows in the data can lead to instability in the model and unreliable performance estimates. Increasing the sample size could help mitigate this issue.
-
Overfitting: SVMs are known to be prone to overfitting when the number of features (columns) is large compared to the number of observations (rows). In this case, the number of columns is 100 and the number of rows is only 28. This could lead to highly optimized decision boundaries that may not generalize well to new data.
-