I have 25 highly differentially expressed genes among and patients to chemotherapy.
I have made a neural network of these genes. The accuracy of the model is 0.73
but I don't know from 25 genes how I could select the best predictors or remove the weaker ones.
> # Convert column from /to 1/0
> = as.numeric(data$)-1
> data1 = cbind(,df)
> head(data1[,1:4])
ALB CALML5 CALML6
A2 0 4.64 5.77 3.16
A3 0 7.12 9.13 5.13
A4 0 7.84 7.09 4.85
A6 0 7.90 9.64 6.52
A7 0 5.84 6.26 0.00
A8 0 4.83 5.77 2.15
>
> library(caTools)
> set.seed(101)
> # Create Split (any column is fine)
> split = sample.split(data1$, SplitRatio = 0.70)
> # Split based off of split Boolean Vector
> train = subset(data1, split == TRUE)
> test = subset(data1, split == FALSE)
> feats <- names(data[,-1])
> # Concatenate strings
> f <- paste(feats,collapse=' + ')
> f <- paste('TG ~',f)
> # Convert to formula
> f <- as.formula(f)
> f
~ ALB + CALML5 + CALML6 + CDK6 + CHGA + CREB3L3 + CSF3 +
CXCL5 + CXCL6 + CXCL8 + DKK1 + EGLN2 + FGF20 + FGF4 + IL11 +
IL1B + IL6 + ISG15 + KLK5 + KRT17 + MMP3 + MMP7 + PKP1 +
PTGS2 + S100A7A
> #install.packages('neuralnet')
> library(neuralnet)
Warning message:
package ‘neuralnet’ was built under R version 3.5.2
> nn <- neuralnet(f,train,hidden=c(25,2,1),linear.output=FALSE)
> View(test)
> # Compute Predictions off Test Set
> predicted.nn.values <- compute(nn,test[2:26])
> # Check out net.result
> print(head(predicted.nn.values$net.result))
[,1]
A4 0.26890819169
B5 0.94836576493
B7 0.19753554824
B8 0.99790838807
B9 0.99764782073
B12 0.05230351043
> predicted.nn.values$net.result <- sapply(predicted.nn.values$net.result,round,digits=0)
> table(test$Private,predicted.nn.values$net.result)
0 1
0 4 3
1 1 7
> accuracy<-(table(test$Private,predicted.nn.values$net.result)[1,1]+table(test$Private,predicted.nn.values$net.result)[2,2])/(sum(table(test$Private,predicted.nn.values$net.result)))
> accuracy
[1] 0.7333333333
>