Una red Neural Artificial (ANN) modela la relación entre un conjunto de entradas y una salida, resolviendo un problema de aprendizaje.
Un ejemplo de apleciación de Redes Neuronales es la recomendación de contenido de Netflix o el feed “For You” de TikTok.
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr 1.1.2 ✔ readr 2.1.4
## ✔ forcats 1.0.0 ✔ stringr 1.5.0
## ✔ ggplot2 3.4.2 ✔ tibble 3.2.1
## ✔ lubridate 1.9.2 ✔ tidyr 1.3.0
## ✔ purrr 1.0.1
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag() masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
##
## Attaching package: 'scales'
##
## The following object is masked from 'package:purrr':
##
## discard
##
## The following object is masked from 'package:readr':
##
## col_factor
##
## Attaching package: 'neuralnet'
##
## The following object is masked from 'package:dplyr':
##
## compute
## examen proyecto estatus
## 1 20 90 1
## 2 10 20 0
## 3 30 40 0
## 4 20 50 0
## 5 80 50 1
## 6 30 80 1
#El punto añade todo lo demás de la bse de datos
RedNeuronal<-neuralnet(estatus~.,data=datarn)
plot(RedNeuronal,rep="best")#Nueva Info
PruebaE<-c(30,40,85)
PruebaP<-c(85,50,40)
Prueba<-data.frame(PruebaE,PruebaP)
#Predicción / Compute junta base de datos pero no las une como left join. solo las almacena
Prediccion<-compute(RedNeuronal,Prueba)
Prediccion$net.result## [,1]
## [1,] 0.5009412
## [2,] 0.5009412
## [3,] 0.5009412
## [,1]
## [1,] 1
## [2,] 1
## [3,] 1
#Cancer de Mama Predicción
CMP<-read.csv("C://Users/IanAb/Documents/7to Semestre/DATA BASE/cancer_de_mama.csv")CMP$diagnosis<-ifelse(CMP$diagnosis=="M",1,0)
# CMP$diagnosis[CMP$diagnosis == "M"] <- "1"
# CMP$diagnosis[CMP$diagnosis == "B"] <- "0"PruebaCM_RM<-c(6.981,27.42)
PruebaCM_TM<-c(13.43,26.27)
PruebaCM_PM<-c(43.79,186.9)
PruebaCM_AM<-c(143.5,2501)
PruebaCM_SmooM<-c(0.117,0.1084)
PruebaCM_ComM<-c(0.07568,0.1988)
PruebaCM_ConyM<-c(0,0.3635)
PruebaCM_CPM<-c(0,0.1689)
PruebaCM_SymM<-c(0.193, 0.2061)
PruebaCM_FDM<-c(0.07818,0.05623)
PruebaCM_RS<-c(0.2241,2.547)
PruebaCM_TS<-c(1.508,1.306)
PruebaCM_PS<-c(1.553,18.65)
PruebaCM_AS<-c(9.833,542.2)
PruebaCM_SmooS<-c(0.01019,0.00765)
PruebaCM_ComS<-c(0.01084,0.05374)
PruebaCM_ConS<-c(0,0.08055)
PruebaCM_CPS<-c(0,0.02598)
PruebaCM_SymS<-c(0.02659,0.01697)
PruebaCM_FDS<-c(0.0041,0.004558)
PruebaCM_RW<-c(7.93,36.04)
PruebaCM_TW<-c(19.54,31.37)
PruebaCM_PW<-c(50.41,251.2)
PruebaCM_AW<-c(185.2,4254)
PruebaCM_SmooW<-c(0.1584,0.1357)
PruebaCM_ComW<-c(0.1202,0.4256)
PruebaCM_ConW<-c(0,0.6833)
PruebaCM_CPW<-c(0,0.2625)
PruebaCM_SymW<-c(0.2932,0.2641)
PruebaCM_FDW<-c(0.09382,0.07427)
PruebaCM<-data.frame(PruebaCM_RM, PruebaCM_TM, PruebaCM_PM, PruebaCM_AM, PruebaCM_SmooM, PruebaCM_ComM, PruebaCM_ConyM, PruebaCM_CPM, PruebaCM_SymM, PruebaCM_FDM, PruebaCM_RS, PruebaCM_TS, PruebaCM_PS, PruebaCM_AS, PruebaCM_SmooS, PruebaCM_ComS, PruebaCM_ConS, PruebaCM_CPS, PruebaCM_SymS, PruebaCM_FDS, PruebaCM_RW, PruebaCM_TW, PruebaCM_PW, PruebaCM_AW, PruebaCM_SmooW, PruebaCM_ComW, PruebaCM_ConW, PruebaCM_CPW, PruebaCM_SymW, PruebaCM_FDW)
PrediccionCM<-compute(RedNeuronalCM,PruebaCM)
PrediccionCM$net.result## [,1]
## [1,] 0.3738953
## [2,] 0.3739001
## [,1]
## [1,] 0
## [2,] 0
PruebaCM_Prof<-CMP[c(19,20,21,22,23),]
PrediccionCM_Prof<-compute(RedNeuronalCM,PruebaCM_Prof)
PrediccionCM_Prof$net.result## [,1]
## 19 0.3739001
## 20 0.3739001
## 21 0.3739001
## 22 0.3739001
## 23 0.3739001
ProbabilidadCM_Prof<-PrediccionCM_Prof$net.result
ResultadoCM_Prof<-ifelse(ProbabilidadCM_Prof>0.5,1,0)
ResultadoCM_Prof## [,1]
## 19 0
## 20 0
## 21 0
## 22 0
## 23 0