SHARE
TWEET

Untitled

a guest Nov 20th, 2019 93 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. tab=datas
  2. tab1=na.omit(tab)
  3. shapiro.test(tab1$TTG) #нет
  4. shapiro.test(tab1$Mochevina)
  5. shapiro.test(tab1$Ferritin)
  6. shapiro.test(tab1$VitD)
  7. shapiro.test(tab1$MKislota)
  8. shapiro.test(tab1$B12)
  9. shapiro.test(tab1$CholesterinVP)
  10. shapiro.test(tab1$GGT)
  11. shapiro.test(tab1$Cbelok)
  12. shapiro.test(tab1$Kreatinin)
  13. shapiro.test(tab1$Albumin)
  14. shapiro.test(tab1$Trigleceridy)
  15. shapiro.test(tab1$Cholesterin)
  16. shapiro.test(tab1$ALAT)
  17. shapiro.test(tab1$CholesterinNP)
  18. shapiro.test(tab1$Age) #нет
  19.  
  20. cor(tab1, method = "kendal")
  21.  
  22. cor.test(tab1$Trigleceridy, tab1$Mochevina,method = "kendall") #p-value = 1.115e-06
  23. cor.test(tab1$Trigleceridy, tab1$Ferritin,method = "kendall") #p-value = 2.626e-16
  24. cor.test(tab1$Trigleceridy, tab1$MKislota,method = "kendall") #p-value < 2.2e-16
  25. cor.test(tab1$Trigleceridy, tab1$GGT,method = "kendall") #p-value < 2.2e-16
  26. cor.test(tab1$Trigleceridy, tab1$Cbelok,method = "kendall") #p-value < 2.2e-16
  27. cor.test(tab1$Trigleceridy, tab1$Kreatinin,method = "kendall") #p-value = 3.853e-11
  28. cor.test(tab1$Trigleceridy, tab1$Cholesterin,method = "kendall") #p-value < 2.2e-16
  29. cor.test(tab1$Trigleceridy, tab1$ALAT,method = "kendall") #p-value < 2.2e-16
  30. cor.test(tab1$Trigleceridy, tab1$CholesterinNP,method = "kendall") #p-value < 2.2e-16
  31. cor.test(tab1$Trigleceridy, tab1$Age,method = "kendall") #p-value < 2.2e-16
  32.  
  33.  
  34. library(caret)
  35.  
  36. fitControl <- trainControl(method="repeatedcv",number=10,repeats=10)
  37.  
  38. tr1=train(tab1[,-13],tab1$Trigleceridy,method ="rpart",trControl=fitControl)
  39. #важные значение
  40. tab33<-data.frame(Trigleceridy = tab1$Trigleceridy, Mochevina=tab1$Mochevina, Ferritin = tab1$Ferritin,
  41.                   MKislota=tab1$MKislota, GGT = tab1$GGT, Cbelok=tab1$Cbelok, Kreatinin = tab1$Kreatinin,
  42.                   Cholesterin = tab1$Cholesterin, ALAT = tab1$ALAT, CholesterinNP = tab1$CholesterinNP,
  43.                   Age = tab1$Age)
  44. tab33
  45.  
  46. lm.p<-lm(tab33$Trigleceridy~., data = tab33)
  47. summary(lm.p)
  48.  
  49. lm.p<-lm(tab33$Trigleceridy~tab1$Ferritin+
  50.            tab1$Cbelok+tab1$Kreatinin+tab1$Cholesterin+tab1$CholesterinNP+tab1$Ferritin+tab1$MKislota+tab1$ALAT+tab1$Cbelok, data = tab33)
  51. summary(lm.p)
  52.  
  53. mse<-MSE(y_pred = exp(lm.p$fitted.values), y_true = tab33$Tcrigleceridy)
  54. mse
  55. rmse<-RMSE(y_pred = exp(lm.p$fitted.values), y_true = tab33$Trigleceridy)
  56. rmse
  57.  
  58. cacao<-mean(abs(lm.p$residuals/tab33$Trigleceridy))*100
  59. cacao
  60. #другие значение
  61. tab44<-data.frame(Trigleceridy = tab1$Trigleceridy, TTG = tab1$TTG, B12=tab1$B12, CholesterinVP = tab1$CholesterinVP,
  62.                   VitD = tab1$VitD, Albumin = tab1$Albumin)
  63.  
  64. lm.p44<-lm(tab44$Trigleceridy~., data = tab44)
  65. summary(lm.p44)
  66.  
  67.  
  68. mse44<-MSE(y_pred = exp(lm.p44$fitted.values), y_true = tab44$Trigleceridy)
  69. mse44
  70. rmse44<-RMSE(y_pred = exp(lm.p44$fitted.values), y_true = tab44$Trigleceridy)
  71. rmse44
  72.  
  73. cacao44<-mean(abs(lm.p44$residuals/tab44$Trigleceridy))*100
  74. cacao44
  75.  
  76.  
  77. set.seed(11)
  78.  
  79.  
  80. tr2=train(tab33,tab33$Trigleceridy,method ="nnet", trControl=fitControl)
  81. tr2$finalModel
  82.  
  83. library(nnet)
  84. library(MLmetrics)
  85.  
  86. for(i in 1:10){
  87.   nnet <- nnet(tab33$Trigleceridy ~ ., tab33, decay=0.1, size=i)
  88.   ind <- sample(2, nrow(tab33), replace = TRUE, prob=c(0.7, 0.3))
  89.   trainset = parsedTen[ind == 1,]
  90.   testset = parsedTen[ind == 2,]
  91.  
  92.   mse <- MSE(y_pred = exp(nnet$fitted.values), y_true = tab33$Trigleceridy)
  93.   mse
  94.   RMSE <- RMSE(y_pred = exp(nnet$fitted.values), y_true = tab33$Trigleceridy)
  95.   COOA = mean(abs(nnet$residuals/tab33$Trigleceridy)) * 100
  96.  
  97.   print(i)
  98.   print(mse)
  99.   print(RMSE)
  100.   print(COOA)
  101. }
  102.  
  103.  
  104. ind = sample(2, nrow(tab33), replace = TRUE, prob=c(0.7, 0.3))
  105. trainset = tab33[ind == 1,]
  106. testset = tab33[ind == 2,]
  107. ###
  108. nnmodel<-nnet(tab33$Trigleceridy~., data=tab33, decay=0.1, size=3)
  109.  
  110. nnmodel1<-nnet(trainset$Trigleceridy~., trainset, decay=0.1, size=3)
  111.  
  112. pp<-predict(nnmodel1, testset)
  113. pp
  114.  
  115.  
  116. mse66<-MSE(y_pred = exp(nnmodel$fitted.values), y_true = tab33$Trigleceridy)
  117. mse66
  118. rmse66<-RMSE(y_pred = exp(nnmodel$fitted.values), y_true = tab33$Trigleceridy)
  119. rmse66
  120.  
  121. cacao66<-mean(abs(nnmodel$residuals/tab33$Trigleceridy))*100
  122. cacao66
  123. ######
  124.  
  125.  
  126. nnmodel<-nnet(tab33$Trigleceridy~., data=tab33, decay=0.1, size=50)
  127.  
  128. nnmodel1<-nnet(trainset$Trigleceridy~., trainset, decay=0.1, size=50)
  129.  
  130. pp<-predict(nnmodel1, testset)
  131. pp
  132.  
  133.  
  134. mse66<-MSE(y_pred = exp(nnmodel$fitted.values), y_true = tab33$Trigleceridy)
  135. mse66
  136. rmse66<-RMSE(y_pred = exp(nnmodel$fitted.values), y_true = tab33$Trigleceridy)
  137. rmse66
  138.  
  139. cacao66<-mean(abs(nnmodel$residuals/tab33$Trigleceridy))*100
  140. cacao66
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top