\Section[
    \eng{Machine-Learning}
    \ger{Maschinelles Lernen}
]{ml}
    \Subsection[
        \eng{Performance metrics}
        \ger{Metriken zur Leistungsmessung}
    ]{performance}
        \eng[cp]{correct predictions}
        \ger[cp]{richtige Vorhersagen}
        \eng[fp]{false predictions}
        \ger[fp]{falsche Vorhersagen}

        \eng[y]{ground truth}
        \eng[yhat]{prediction}
        \ger[y]{Wahrheit}
        \ger[yhat]{Vorhersage}

        \begin{formula}{accuracy}
            \desc{Accuracy}{}{}
            \desc[german]{Genauigkeit}{}{}
            \eq{a = \frac{\tgt{cp}}{\tgt{fp} + \tgt{cp}}}
        \end{formula}
        \eng{n_desc}{Number of data points}
        \ger{n_desc}{Anzahl der Datenpunkte}
        \begin{formula}{mean_abs_error}
            \desc{Mean absolute error (MAE)}{}{$y$ \gt{y}, $\hat{y}$ \gt{yhat}, $n$ \gt{n_desc}}
            \desc[german]{Mittlerer absoluter Fehler (MAE)}{}{}
            \eq{\text{MAE} = \frac{1}{n} \sum_{i=1}^n \abs{y_i - \hat{y}_i}}
        \end{formula}
        \begin{formula}{mean_square_error}
            \desc{Mean squared error (MSE)}{}{$y$ \gt{y}, $\hat{y}$ \gt{yhat}, $n$ \gt{n_desc}}
            \desc[german]{Methode der kleinsten Quadrate (MSE)}{Quadratwurzel des mittleren quadratischen Fehlers (SME)}{}
            \eq{\text{MSE} = \frac{1}{n} \sum_{i=1}^n \left(y_i - \hat{y}_i\right)^2}
        \end{formula}
        \begin{formula}{root_mean_square_error}
            \desc{Root mean squared error (RMSE)}{}{$y$ \gt{y}, $\hat{y}$ \gt{yhat}, $n$ \gt{n_desc}}
            \desc[german]{Standardfehler der Regression}{Quadratwurzel des mittleren quadratischen Fehlers (RSME)}{}
            \eq{\text{RMSE} = \sqrt{\frac{1}{n} \sum_{i=1}^n \left(y_i - \hat{y}_i\right)^2}}
        \end{formula}

    \Subsection[
        \eng{Regression}
        \ger{Regression}
    ]{reg}
        \Subsubsection[
            \eng{Linear Regression}
            \ger{Lineare Regression}
        ]{linear}
            \begin{formula}{eq}
                \desc{Linear regression}{Fits the data under the assumption of \hyperref[f:math:pt:distributions:cont:normal]{normally distributed errors}}{$\mat{x}\in\R^{N\times M}$ input data, $\mat{y}\in\R^{N\times L}$ output data, $\mat{b}$ bias, $\vec{\beta}$ weights, $N$ samples, $M$ features, $L$ output variables}
                \desc[german]{Lineare Regression}{Fitted Daten unter der Annahme \hyperref[f:math:pt:distributions:cont:normal]{normalverteilter Fehler}}{}
                \eq{\mat{y} = \mat{\epsilon} + \mat{x} \cdot \vec{\beta}}
            \end{formula}
            \begin{formula}{design_matrix}
                \desc{Design matrix}{Stack column of ones to the feature vector\\Useful when $\epsilon$ is scalar}{$x_{ij}$ feature $j$ of sample $i$}
                \desc[german]{Designmatrix Ansatz}{}{}
                \eq{
                    \mat{X} = \begin{pmatrix} 1 & x_{11} & \ldots & x_{1M} \\  \vdots & \vdots & \vdots & \vdots \\ 1 & x_{N1} & \ldots & x_{NM} \end{pmatrix} 
                }
            \end{formula}       
            \begin{formula}{scalar_bias}
                \desc{Linear regression with scalar bias}{Using the design matrix, the scalar is absorbed into the weight vector}{$\mat{y}$ output data, $\mat{X}$ \fqEqRef{comp:ml:reg:design_matrix}, $\vec{\beta}$ weights}
                \desc[german]{Lineare Regression mit skalarem Bias}{Durch die Designmatrix wird der Bias in den Gewichtsvektor absorbiert}{}
                \eq{\mat{y} = \mat{X} \cdot \vec{\beta}}
            \end{formula}
            \begin{formula}{normal_equation}
                \desc{Normal equation}{Solves \fqEqRef{comp:ml:reg:linear:scalar_bias} with \fqEqRef{comp:ml:performance:mse}}{$\mat{y}$ output data, $\mat{X}$ \fqEqRef{comp:ml:reg:linear:design_matrix}, $\vec{\beta}$ weights}
                \desc[german]{Normalengleichung}{Löst \fqEqRef{comp:ml:reg:linear:scalar_bias} mit \fqEqRef{comp:ml:performance:mse}}{}
                \eq{\vec{\beta} = \left(\mat{X}^\T \mat{X}\right)^{-1} \mat{X}^T \mat{y}}
            \end{formula}

        \Subsubsection[
            \eng{Kernel method}
            \ger{Kernelmethode}
        ]{kernel}
            \begin{formula}{kernel_trick}
                \desc{Kernel trick}{}{$\vecx_i \in \R^{M_1}$ input vectors, $M_1$ dimension of data vector space, $M_2$ dimension of feature space}
                % \desc[german]{}{}{}
                \ttxt{\eng{
                    Useful when transforming the input data $x$ into a much higher dimensional space ($M_2 \gg M_1$) $\Phi: \R^{M_1} \mapsto \R^{M_2},\quad \vecx \to \Phi(\vecx)$ 
                    and only the dot product of this transformed data $\Phi(x)^\T\Phi(x)$ is required.
                    Then the dot product can be replaced by a suitable kernel function $\kappa$.
                }}
                \eq{
                    k(\vecx_i,\vecx_j) \equiv \Phi(\vecx_i)^{\T} \Phi(\vecx_j)
                }
            \end{formula}   

            \begin{formula}{common_kernels}
                \desc{Common kernels}{}{}
                % \desc[german]{}{}{}
                % \eq{}
                \ttxt{\eng{
                    Linear, Polynomial, Sigmoid, Laplacian, radial basis funciton (RBF)
                }}
            \end{formula}

            \begin{formula}{radial_basis_function}
                \abbrLabel{RBF}
                \desc{Radial basis function kernel (RBF)}{RBF = Real function of which the value only depends on the distance of the input}{}
                \desc[german]{Radiale Basisfunktion-Kernel (RBF)}{RBF = Reelle Funktion, deren Wert nur vom Abstand zum Ursprung abängt}{}
                \eq{k(\vecx_i, \vecx_j) = \Exp{-\frac{\norm{\vecx_i - \vecx_j}_2^2}{\sigma}}}
            \end{formula}

        \Subsubsection[
            \eng{Bayesian regression}
            \ger{Bayes'sche Regression}
        ]{bayes}

            \begin{formula}{linear_regression}
                \desc{Bayesian linear regression}{}{}
                \desc[german]{Bayes'sche lineare Regression}{}{}
                \ttxt{\eng{
                        Assume a \fqEqRef{math:pt:bayesian:prior} distribution over the weights.
                        Offers uncertainties in addition to the predictions.
                }}
            \end{formula}

            \begin{formula}{ridge}
                \desc{Ridge regression}{Regularization method}{}
                \desc[german]{Ridge Regression}{}{}
                \ttxt{\eng{
                    Applies a L2 norm penalty on the weights.
                    This ensures unimportant features are less regarded and do not encode noise.
                    \\Corresponds to assuming a \fqEqRef{math:pt:bayesian:prior} \absRef{multivariate_normal_distribution} with $\vec{mu} = 0$ and independent components ($\mat{\Sigma}$) for the weights.
                }\ger{
                    Reduziert Gewichte mit der L2-Norm.
                    Dadurch werden unwichtige Features nicht berücksichtigt (kleines Gewicht) und enkodieren nicht Noise.
                    \\Entspricht der Annahme einer \absRef[Normalverteilung]{multivariate_normal_distribution} mit $\vec{mu}=0$ und unanhängingen Komponenten ($\mat{Sigma}$ diagonaol) der die Gewichte als \fqEqRef{math:pt:bayesian:prior}.
                }}
            \end{formula}

            \begin{formula}{ridge_weights}
                \desc{Optimal weights}{for ridge regression}{$\lambda = \frac{\sigma^2}{\xi^2}$ shrinkage parameter, $\xi$ \absRef{variance} of the gaussian \fqEqRef{math:pt:bayesian:prior}, $\sigma$ \absRef{variance} of the gaussian likelihood of the data}
                \desc[german]{Optimale Gewichte}{für Ridge Regression}{}
                \eq{\vec{\beta} = \left(\mat{X}^\T \mat{X} + \lambda \mathcal{1} \right)^{-1} \mat{X}^\T \vecy}
                \TODO{Does this only work for gaussian data?}
            \end{formula}

            \begin{formula}{lasso}
                \desc{Lasso regression}{Least absolute shrinkage and selection operator\\Regularization method}{}
                \desc[german]{Lasso Regression}{}{}
                \ttxt{\eng{
                    Applies a L1 norm penalty on the weights, which means features can be disregarded entirely.
                    \\Corresponds to assuming a \absRef{laplace_distribution} for the weights as \fqEqRef{math:pt:bayesian:prior}.
                }\ger{
                    Reduziert Gewichte mit der L1-Norm.
                    Unwichtige Features werden reduziert und können auch ganz vernachlässigt werden und enkodieren nicht Noise.
                    \\Entspricht der Annahme einer \absRef[Laplace-Verteilung]{laplace_distribution} der die Gewichte als \fqEqRef{math:pt:bayesian:prior}. 
                }}
            \end{formula}


        
        \begin{formula}{gaussion_process_regression}
            \desc{Gaussian process regression (GPR)}{}{}
            % \desc[german]{}{}{}
            \ttxt{\eng{
                Gaussian process: A distribtuion over functions that produce jointly gaussian distribution.
                Multivariate normal distribution like \secEqRef{bayesian}, except that $\vec{\mu}$ and $\mat{\Sigma}$ are functions.
                GPR: non-parametric Bayesion regressor, does not assume fixed functional form for the underlying data, instead, the data determines the functional shape,
                with predictions governed by the covariance structure defined by the kernel (often \abbrRef{radial_basis_function}).

                Offers uncertainties in addition to the predictions.
                \TODO{cleanup}
            }}
        \end{formula}
        

        \TODO{soap}

    \Subsection[
        \eng{Gradient descent}
        \ger{Gradientenverfahren}
    ]{gd}
        \TODO{in lecture 30 CMP}

