[英]draw neural network diagram in ggplot
是否可以在ggplot
中繪制神經網絡圖。
一個簡單的 ggplot 代碼,可以在 ggplot 中創建具有一個隱藏層網絡的淺層神經網絡圖(可以給定神經元的數量作為輸入)
下面附上所需的圖表。 目前我使用 power point/paint 來創建神經網絡圖。
library(tidyverse)
library(nnet)
library(caret)
# data
x <- c(0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1, 1)
y <- c(0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1)
choice <- c(1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 0, 1)
tbl <- tibble(x, y, choice)
tbl$choice = as.factor(tbl$choice)
myControl <- trainControl(## n-fold CV
method = "repeatedcv",
number = 2,
repeats = 5,
verboseIter = TRUE)
nnGrid <- expand.grid(size = 2,
decay = seq(0, 0.1, 0.3))
nnetFit <- train(choice ~ .,
data = tbl,
method = "nnet",
tuneGrid = nnGrid,
trace = FALSE,
maxit = 6000,
trControl = myControl)
據我所知不是。 我使用 ggnet2 function。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.