![多边形反馈回路](https://linux22.com/image/401554/%E5%A4%9A%E8%BE%B9%E5%BD%A2%E5%8F%8D%E9%A6%88%E5%9B%9E%E8%B7%AF.png)
你能帮我完成这个图的第 4 步吗?我使用的是上一篇文章中的代码(全部归功于薛定谔的猫):薛定谔的猫代码
我认为我应该添加这块代码:
\draw[semithick,decorate,decoration={brace,mirror,raise=1pt}]
(pin-5.south west) -- (pin-5.south east) coordinate[midway,below=1.2ex] (pf)
node[midway,below=2em,box=left:{Validation\\ Fold Data}](b1){};
\node[right=4em of b1,box=above:Prediction,yshift=-0.5ex] (b2){};
\node[below=4em of b2,box=below:{Validation\\ Fold Labels}] (b3){};
\path (b2) -- (b3) coordinate[midway,right=1em] (aux)
node[right=1em of aux] (PF) {Performance};
\draw[-stealth] (b2.east) -| (aux) |- (b3.east) (aux) -- (PF);
\node[below=0.1em of b1,regular polygon,regular polygon
sides=6,fill,text=white] (6gon2) {Model};
\path coordinate[left=1em of b2] (aux2);
\draw[-stealth] (6gon2.east) -| (aux2) |- (b1.east) (aux2) -- (b2);
\draw[-stealth] (pf) -- (b1);
梅威瑟:
\documentclass{article}
\usepackage[margin=1cm]{geometry}
\usepackage[edges]{forest}
\usetikzlibrary{shapes.geometric,shapes.misc,shapes.multipart,intersections}
\newsavebox\boxA
\newsavebox\boxB
\newsavebox\boxC
\newsavebox\boxD
\newsavebox\boxE
\tikzset{2box/.style={rectangle split, rectangle split parts=2, draw,minimum
width=#1},2box/.default=8em,
every picture/.append style={font=\sffamily,
every text node part/.style={align=center},
every pin edge/.style={-stealth}},
chess/.style={minimum size=#1,draw,fill=gray!20,path picture={
\foreach \XX in {0,...,4}
{\ifnum\XX>0
\draw ($(path picture bounding box.north west)+\XX*(#1/5,0)$)
-- ($(path picture bounding box.south west)+\XX*(#1/5,0)$)
($(path picture bounding box.north west)+\XX*(0,-#1/5)$)
-- ($(path picture bounding box.north east)+\XX*(0,-#1/5)$);
\fi
\draw[fill=blue!50] ($(path picture bounding box.north west)+\XX*(#1/5,-#1/5)$)
rectangle ++(#1/5,-#1/5); }
}},chess/.default=1.5cm,rr/.style={rounded rectangle,draw,align=center},
2ell/.style={ellipse split,draw}}
\sbox\boxA{\begin{forest}
forked edges,
for tree={grow'=0,edge={-stealth},l sep=4em}
[{Data\nodepart{two}Labels},2box=10em
[{Training Data\nodepart{two}Training Labels},2box,fill=gray!20]
[{Test Data\nodepart{two}Test Labels},2box=6em,fill=green!20]
]
\end{forest}}
\sbox\boxB{\begin{forest}
forked edges,
for tree={grow'=0,edge={-stealth},l sep=3em,s sep=0.3em,
where level=1{rr,anchor=center,l sep+=4em}{},
where level=2{chess,no edge,pin={[node font=\small]right:Performance}}{},
}
[{Training Data\nodepart{two}Training Labels},2box,fill=gray!20,anchor=text
split east
[Hyperparameters\\ value
[{},alias=ml31]
]
[Hyperparameters\\ value,alias=ml22
[{},alias=ml32]
]
[Hyperparameters\\ value
[{},alias=ml33]
]
]
\path let \p1=($(ml31.north)-(ml33.south)$) in (ml22) -- (ml32)
node[name path=elli,midway,ellipse,draw,node font=\bfseries,align=center,
minimum height=\y1,inner xsep=-1ex]{Learning\\
Algorithm};
\foreach \X in {1,2,3}
{\path[name path=l\X] (ml3\X.west-|ml22.east) -- (ml3\X.west);
\path[name intersections={of=elli and l\X,sort by=l\X}]
\ifnum\X=1
(ml3\X.west-|ml22.east) edge[-stealth] (intersection-2)
(intersection-1) edge[-stealth] (ml3\X.west)
\else
(ml3\X.west-|ml22.east) edge[-stealth] (intersection-1)
(intersection-2) edge[-stealth] (ml3\X.west)
\fi;}
\end{forest}}
\sbox\boxC{\begin{forest}
for tree={grow'=0,edge={-stealth},l sep=4em}
[{Training Data\nodepart{two}Training Labels},2box,fill=gray!20,anchor=text
split east
[{\begin{tabular}{@{}c@{}}
\textbf{Best}\\ hyperparameters\\ values\\[-0.3ex]~
\end{tabular}\nodepart{lower}
\begin{tabular}{@{}c@{}}~\\[-0.3ex]\textbf{Learning} \\\textbf{Algorithm}\end{tabular}},
2ell,anchor=center,inner ysep=-1.8ex
[Model,regular polygon,regular polygon sides=6,fill,text=white,anchor=center]
]
]
\end{forest}}
\sbox\boxD{\begin{forest}
for tree={grow'=0,edge={-stealth},l sep=4em}
[{Data\nodepart{two} Labels},2box,fill=white,anchor=text
split east
[{\begin{tabular}{@{}c@{}}
\textbf{Best}\\ hyperparameters\\ values\\[-0.3ex]~
\end{tabular}\nodepart{lower}
\begin{tabular}{@{}c@{}}~\\[-0.3ex]\textbf{Learning} \\\textbf{Algorithm}\end{tabular}},
2ell,anchor=center,inner ysep=-1.8ex
[Final \\ Model,regular polygon,regular polygon sides=6,fill,text=white,anchor=center]
]
]
\end{forest}}
\newcommand{\BC}[2][]{\begin{tikzpicture}[baseline={(X.base)}]
\node[circle,fill,text=white,minimum size=1.3em,#1](X){#2};
\end{tikzpicture}}
\begin{document}
$\begin{array}{cp{1em}l}
\BC{1} & & \vcenter{\hbox{\usebox{\boxA}}}\\[4em]
\BC{2} & & \vcenter{\hbox{\usebox{\boxB}}}\\[6em]
\BC{3} & & \vcenter{\hbox{\usebox{\boxC}}}\\[5em]
\BC{4} & & \vcenter{\hbox{\usebox{\boxC}}}\\[5em]
\BC{5} & & \vcenter{\hbox{\usebox{\boxD}}}\\
\end{array}$
\end{document}
答案1
它确实只是一个快速的复制和粘贴(以及一些边际调整)。
\documentclass{article}
\usepackage[margin=1cm]{geometry}
\usepackage[edges]{forest}
\usetikzlibrary{positioning,shapes.geometric,shapes.misc,shapes.multipart,intersections}
\foreach \X in {A,...,E}
{\expandafter\newsavebox\csname box\X\endcsname}
\tikzset{gbox/.style={draw,minimum size=1.2em,fill=green!50},
2box/.style={rectangle split, rectangle split parts=2, draw,minimum
width=#1},2box/.default=8em,
every picture/.append style={font=\sffamily,
every text node part/.style={align=center},
every pin edge/.style={-stealth}},
chess/.style={minimum size=#1,draw,fill=gray!20,path picture={
\foreach \XX in {0,...,4}
{\ifnum\XX>0
\draw ($(path picture bounding box.north west)+\XX*(#1/5,0)$)
-- ($(path picture bounding box.south west)+\XX*(#1/5,0)$)
($(path picture bounding box.north west)+\XX*(0,-#1/5)$)
-- ($(path picture bounding box.north east)+\XX*(0,-#1/5)$);
\fi
\draw[fill=blue!50] ($(path picture bounding box.north west)+\XX*(#1/5,-#1/5)$)
rectangle ++(#1/5,-#1/5); }
}},chess/.default=1.5cm,rr/.style={rounded rectangle,draw,align=center},
2ell/.style={ellipse split,draw}}
\sbox\boxA{\begin{forest}
forked edges,
for tree={grow'=0,edge={-stealth},l sep=4em}
[{Data\nodepart{two}Labels},2box=10em
[{Training Data\nodepart{two}Training Labels},2box,fill=gray!20]
[{Test Data\nodepart{two}Test Labels},2box=6em,fill=green!20]
]
\end{forest}}
\sbox\boxB{\begin{forest}
forked edges,
for tree={grow'=0,edge={-stealth},l sep=3em,s sep=0.3em,
where level=1{rr,anchor=center,l sep+=4em}{},
where level=2{chess,no edge,pin={[node font=\small]right:Performance}}{},
}
[{Training Data\nodepart{two}Training Labels},2box,fill=gray!20,anchor=text
split east
[Hyperparameters\\ value
[{},alias=ml31]
]
[Hyperparameters\\ value,alias=ml22
[{},alias=ml32]
]
[Hyperparameters\\ value
[{},alias=ml33]
]
]
\path let \p1=($(ml31.north)-(ml33.south)$) in (ml22) -- (ml32)
node[name path=elli,midway,ellipse,draw,node font=\bfseries,align=center,
minimum height=\y1,inner xsep=-1ex]{Learning\\
Algorithm};
\foreach \X in {1,2,3}
{\path[name path=l\X] (ml3\X.west-|ml22.east) -- (ml3\X.west);
\path[name intersections={of=elli and l\X,sort by=l\X}]
\ifnum\X=1
(ml3\X.west-|ml22.east) edge[-stealth] (intersection-2)
(intersection-1) edge[-stealth] (ml3\X.west)
\else
(ml3\X.west-|ml22.east) edge[-stealth] (intersection-1)
(intersection-2) edge[-stealth] (ml3\X.west)
\fi;}
\end{forest}}
\sbox\boxC{\begin{forest}
for tree={grow'=0,edge={-stealth},l sep=4em}
[{Training Data\nodepart{two}Training Labels},2box,fill=gray!20,anchor=text
split east
[{\begin{tabular}{@{}c@{}}
\textbf{Best}\\ hyperparameters\\ values\\[-0.3ex]~
\end{tabular}\nodepart{lower}
\begin{tabular}{@{}c@{}}~\\[-0.3ex]\textbf{Learning} \\\textbf{Algorithm}\end{tabular}},
2ell,anchor=center,inner ysep=-1.8ex
[Model,regular polygon,regular polygon sides=6,fill,text=white,anchor=center]
]
]
\end{forest}}
\sbox\boxD{\begin{tikzpicture}
\node[gbox](b1){Validation\\ Fold Data};
\node[right=4em of b1,gbox,yshift=-0.5ex] (b2){Prediction};
\node[below=4em of b2,gbox] (b3){Validation\\ Fold Labels};
\path (b2) -- (b3) coordinate[midway,right=4em] (aux)
node[right=2em of aux] (PF) {Performance};
\draw[-stealth] (b2.east) -| (aux) |- (b3.east) (aux) -- (PF);
\node[below=0.1em of b1,regular polygon,regular polygon
sides=6,fill,text=white] (6gon2) {Model};
\path coordinate[left=1em of b2] (aux2);
\draw[-stealth] (6gon2.east) -| (aux2) |- (b1.east) (aux2) -- (b2);
\end{tikzpicture}}
\sbox\boxE{\begin{forest}
for tree={grow'=0,edge={-stealth},l sep=4em}
[{Data\nodepart{two} Labels},2box=9em,fill=white,anchor=text
split east
[{\begin{tabular}{@{}c@{}}
\textbf{Best}\\ hyperparameters\\ values\\[-0.3ex]~
\end{tabular}\nodepart{lower}
\begin{tabular}{@{}c@{}}~\\[-0.3ex]\textbf{Learning} \\\textbf{Algorithm}\end{tabular}},
2ell,anchor=center,inner ysep=-1.8ex
[Final \\ Model,regular polygon,regular polygon sides=6,fill,text=white,anchor=center]
]
]
\end{forest}}
\newcommand{\BC}[2][]{\begin{tikzpicture}[baseline={(X.base)}]
\node[circle,fill,text=white,minimum size=1.3em,#1](X){#2};
\end{tikzpicture}}
\begin{document}
$\begin{array}{cp{1em}l}
\BC{1} & & \vcenter{\hbox{\usebox{\boxA}}}\\[4em]
\BC{2} & & \vcenter{\hbox{\usebox{\boxB}}}\\[6em]
\BC{3} & & \vcenter{\hbox{\usebox{\boxC}}}\\[5em]
\BC{4} & & \vcenter{\hbox{\usebox{\boxD}}}\\[5em]
\BC{5} & & \vcenter{\hbox{\usebox{\boxE}}}\\
\end{array}$
\end{document}