我需要帮助!我知道这非常艰难,充满挑战。但有了你们这些天才,我们一定能成功!
具有水平层次结构的 MWE:
\documentclass{article}
\usepackage{tikz}
\usepackage{tikz-qtree}
\usetikzlibrary{trees}
\begin{document}
\begin{tikzpicture}[grow'=right,level distance=1.25in,sibling distance=.25in]
\tikzset{edge from parent/.style=
{thick, draw, edge from parent fork right},
every tree node/.style=
{draw,minimum width=1in,text width=1in,align=center}}
\Tree
[. Data
[.{Training data}
[.{Training Data } ]
[.{Training Labels } ]
[.{Test data } ]
[.{Test Labels } ]
]
[.Training data
[.{Hyperparameters values } ]
[.{Hyperparameters values } ]
[.{Hyperparameters values } ]
]
[. Best hyperparameters values ]
[. Learning Algorithm ]
]
\end{tikzpicture}
\end{document}
答案1
您可能知道,我对从屏幕截图中输入文本并不十分感兴趣。所以我创建了前三个子图。第二个很有趣,因为我可以在使箭头终止于椭圆边界时尝试一些相对新的东西。所有其他东西都基本是标准的(因为有大量此类帖子)。对于子树,我使用forest
,而大的东西在我看来是表,而不是树。\savebox
这里实际上不需要使用 es,但如果您想使用 a 而不是表,则需要使用 es tikzpicture
。我在图表 3 之后停止,否则会花费太多时间并且重复太多。
\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}}
\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}}}\\[5em]
\BC{3} & & \vcenter{\hbox{\usebox{\boxC}}}\\
\end{array}$
\end{document}