mirror of
https://github.com/MartinThoma/LaTeX-examples.git
synced 2025-04-19 11:38:05 +02:00
Add ID3 algorithm
This commit is contained in:
parent
59b3d42774
commit
b36776fc27
4 changed files with 75 additions and 0 deletions
BIN
source-code/Pseudocode/ID3/ID3.png
Normal file
BIN
source-code/Pseudocode/ID3/ID3.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 27 KiB |
39
source-code/Pseudocode/ID3/ID3.tex
Normal file
39
source-code/Pseudocode/ID3/ID3.tex
Normal file
|
@ -0,0 +1,39 @@
|
|||
\documentclass{article}
|
||||
\usepackage[pdftex,active,tightpage]{preview}
|
||||
\setlength\PreviewBorder{2mm}
|
||||
|
||||
\usepackage[utf8]{inputenc} % this is needed for umlauts
|
||||
\usepackage[ngerman]{babel} % this is needed for umlauts
|
||||
\usepackage[T1]{fontenc} % this is needed for correct output of umlauts in pdf
|
||||
\usepackage{amssymb,amsmath,amsfonts} % nice math rendering
|
||||
\usepackage{braket} % needed for \Set
|
||||
\usepackage{algorithm,algpseudocode}
|
||||
|
||||
\DeclareMathOperator*{\argmin}{arg\,min}
|
||||
|
||||
\begin{document}
|
||||
\begin{preview}
|
||||
\begin{algorithm}[H]
|
||||
\begin{algorithmic}
|
||||
\Require Trainingsdaten $X$ jeweils mit Klasse $K(X)$, Attribute~$A$,
|
||||
Qualitätsfunktion $\varphi$
|
||||
\Procedure{ID3}{$X$, $A$}
|
||||
\If{$K(x_i) = K(x_j) \;\;\;\forall x_i, x_j \in X$}
|
||||
\State \Return Klasse $K(x_0)$
|
||||
\Else
|
||||
\State $a_\text{min} \gets \argmin_{a \in A} \varphi(a)$
|
||||
\State $n \gets \Call{CreateNode}{}$
|
||||
\For{Attributwert $w$ in $a_\text{min}(X)$}
|
||||
\State $X_{a_\text{min} = w} \gets \{x \in X | a_\text{min}(X) = w\}$
|
||||
\State $child \gets \Call{ID3}{X_{a_\text{min}}, A}$
|
||||
\State $n.\Call{AddChild}{child}$
|
||||
\EndFor
|
||||
\State \Return $n$
|
||||
\EndIf
|
||||
\EndProcedure
|
||||
\end{algorithmic}
|
||||
\caption{ID3 Algorithmus}
|
||||
\label{alg:ID3}
|
||||
\end{algorithm}
|
||||
\end{preview}
|
||||
\end{document}
|
33
source-code/Pseudocode/ID3/Makefile
Normal file
33
source-code/Pseudocode/ID3/Makefile
Normal file
|
@ -0,0 +1,33 @@
|
|||
SOURCE = ID3
|
||||
DELAY = 80
|
||||
DENSITY = 300
|
||||
WIDTH = 512
|
||||
|
||||
make:
|
||||
pdflatex $(SOURCE).tex -output-format=pdf
|
||||
make clean
|
||||
|
||||
clean:
|
||||
rm -rf $(TARGET) *.class *.html *.log *.aux *.data *.gnuplot
|
||||
|
||||
gif:
|
||||
pdfcrop $(SOURCE).pdf
|
||||
convert -verbose -delay $(DELAY) -loop 0 -density $(DENSITY) $(SOURCE)-crop.pdf $(SOURCE).gif
|
||||
make clean
|
||||
|
||||
png:
|
||||
make
|
||||
make svg
|
||||
inkscape $(SOURCE).svg -w $(WIDTH) --export-png=$(SOURCE).png
|
||||
|
||||
transparentGif:
|
||||
convert $(SOURCE).pdf -transparent white result.gif
|
||||
make clean
|
||||
|
||||
svg:
|
||||
#inkscape $(SOURCE).pdf --export-plain-svg=$(SOURCE).svg
|
||||
pdf2svg $(SOURCE).pdf $(SOURCE).svg
|
||||
# Necessary, as pdf2svg does not always create valid svgs:
|
||||
inkscape $(SOURCE).svg --export-width=$(WIDTH) --export-plain-svg=$(SOURCE)1.svg
|
||||
rsvg-convert -a -w 720 -f svg $(SOURCE)1.svg -o $(SOURCE).svg
|
||||
rm $(SOURCE)1.svg
|
3
source-code/Pseudocode/ID3/README.md
Normal file
3
source-code/Pseudocode/ID3/README.md
Normal file
|
@ -0,0 +1,3 @@
|
|||
Compiled example
|
||||
----------------
|
||||

|
Loading…
Add table
Add a link
Reference in a new issue