来自训练示例和假设集互相交叉。有没有办法避免这种情况,即他们改变“停靠”位置学习算法?
\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
[myBox/.style={rectangle,
draw,
align=center,
inner sep=2.5mm}]
\node[myBox] (unknownTargetFunction) at (-4, 4) {\textsc{Unknown Target Function}\\$f: \mathcal{X} \rightarrow \mathcal{Y}$};
\node[myBox] (trainingExamples) at (-4, 2) {\textsc{Training Examples}\\$\mathcal{D} = (x_1,y_1),...,(x_n,y_n)$};
\node[myBox] (learningAlgorithm) at ( 0, 0) {\textsc{Learning Algorithm}\\$\mathcal{A}$};
\node[myBox] (finalHypothesis) at ( 5, 0) {\textsc{Final Hypothesis}\\$g \approx f$};
\node[myBox] (hypothesisSet) at (-4,-2) {\textsc{Hypothesis Set}\\$\mathcal{H}$};
\draw [->] (unknownTargetFunction) to (trainingExamples);
\draw [->] (trainingExamples) to [bend right] (learningAlgorithm);
\draw [->] (hypothesisSet) to [bend left] (learningAlgorithm);
\draw [->] (learningAlgorithm) to (finalHypothesis);
\end{tikzpicture}
\end{document}
代码生成:
信息:该图片背后的想法源自 YS Abu-Mostafa 等人所著的《从数据中学习》一书。
答案1
您至少有三个选择:
您可以将“角度”锚点用于 ņode:
\draw [->] (trainingExamples) to [bend right] (learningAlgorithm.170); \draw [->] (hypothesisSet) to [bend left] (learningAlgorithm.190);
您可以使用
calc
库和部分修改器来避免手动计算:\draw [->] (trainingExamples) to [bend right] ( $ (learningAlgorithm.west)!0.5!(learningAlgorithm.north west) $ ); \draw [->] (hypothesisSet) to [bend left] ( $ (learningAlgorithm.west)!0.5!(learningAlgorithm.south west) $ );
您可以使用
west
锚点并在 y 方向上手动移动:\draw [->] (trainingExamples) to [bend right] ([yshift=10pt]learningAlgorithm.west); \draw [->] (hypothesisSet) to [bend left] ([yshift=-10pt]learningAlgorithm.west);
代码显示前两个选项:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
[myBox/.style={rectangle,
draw,
align=center,
inner sep=2.5mm}]
\node[myBox] (unknownTargetFunction) at (-4, 4) {\textsc{Unknown Target Function}\\$f: \mathcal{X} \rightarrow \mathcal{Y}$};
\node[myBox] (trainingExamples) at (-4, 2) {\textsc{Training Examples}\\$\mathcal{D} = (x_1,y_1),...,(x_n,y_n)$};
\node[myBox] (learningAlgorithm) at ( 0, 0) {\textsc{Learning Algorithm}\\$\mathcal{A}$};
\node[myBox] (finalHypothesis) at ( 5, 0) {\textsc{Final Hypothesis}\\$g \approx f$};
\node[myBox] (hypothesisSet) at (-4,-2) {\textsc{Hypothesis Set}\\$\mathcal{H}$};
\draw [->] (unknownTargetFunction) to (trainingExamples);
\draw [->] (trainingExamples) to [bend right] (learningAlgorithm.170);
\draw [->] (hypothesisSet) to [bend left] (learningAlgorithm.190);
\draw [->] (learningAlgorithm) to (finalHypothesis);
\end{tikzpicture}
\begin{tikzpicture}
[myBox/.style={rectangle,
draw,
align=center,
inner sep=2.5mm}]
\node[myBox] (unknownTargetFunction) at (-4, 4) {\textsc{Unknown Target Function}\\$f: \mathcal{X} \rightarrow \mathcal{Y}$};
\node[myBox] (trainingExamples) at (-4, 2) {\textsc{Training Examples}\\$\mathcal{D} = (x_1,y_1),...,(x_n,y_n)$};
\node[myBox] (learningAlgorithm) at ( 0, 0) {\textsc{Learning Algorithm}\\$\mathcal{A}$};
\node[myBox] (finalHypothesis) at ( 5, 0) {\textsc{Final Hypothesis}\\$g \approx f$};
\node[myBox] (hypothesisSet) at (-4,-2) {\textsc{Hypothesis Set}\\$\mathcal{H}$};
\draw [->] (unknownTargetFunction) to (trainingExamples);
\draw [->] (trainingExamples) to [bend right]
( $ (learningAlgorithm.west)!0.5!(learningAlgorithm.north west) $ );
\draw [->] (hypothesisSet) to [bend left]
( $ (learningAlgorithm.west)!0.5!(learningAlgorithm.south west) $ );
\draw [->] (learningAlgorithm) to (finalHypothesis);
\end{tikzpicture}
\end{document}