diff --git a/is/ub9/is9.pdf b/is/ub9/is9.pdf index d944551..f03aa58 100644 --- a/is/ub9/is9.pdf +++ b/is/ub9/is9.pdf Binary files differ diff --git a/is/ub9/is9.tex b/is/ub9/is9.tex index c34f421..69c20ec 100644 --- a/is/ub9/is9.tex +++ b/is/ub9/is9.tex @@ -9,7 +9,7 @@ \usepackage{enumerate} \usepackage{listings} \lstset{language=Python} - +\usepackage{ wasysym } \usepackage{algpseudocode} %Pseudocode \usepackage{dsfont} % schöne Zahlenräumezeichen \usepackage{amssymb, amsthm} %noch stärker erweiterte Mathe-Zeichen @@ -82,7 +82,8 @@ \Aufgabe{Independence}{50}\\ \includegraphics[width=0.49\textwidth]{regression.png} \includegraphics[width=0.49\textwidth]{residuals.png}\\ - Da $Y$ qudratisch von $X$ abhängt, vergrößert sich auch die Varianz. Entsprechend werden die Residuen für größere $Y$ ebenfalls größer. %TODO: ? + For small values of Y it is overestimated, for larger underestimated. For small X we predict small Y, however there's noise. This leads to the dense population of residuals on y=x.\\ + Due to the qudratic connection there are more data near zero for a uniformly distributed X than there are further to larger values.\vspace{1cm}\\ \Aufgabe{Kernels}{50} \begin{enumerate} \item $k(x_1,x_2)=C= \alpha \cdot k'(x,y)\\ @@ -91,19 +92,19 @@ \end{pmatrix} \begin{pmatrix} 1 &1\\1&1 \end{pmatrix}\begin{pmatrix} - x\\y - \end{pmatrix}= x^2+2xy+y^2=(x+y)^2 \geq 0 \forall{x,y}\\$ + x\\y + \end{pmatrix}= x^2+2xy+y^2=(x+y)^2 \geq 0 \forall{x,y}$\checkmark \item $k(x,y) =xy\\ - \geq 0 \forall{x,y} $ + \geq 0 \forall{x,y} $\checkmark \item No kernel $k(x,y) =\dfrac{1}{2}(x+y)\\ k(-1,-1) =-1 \ngeq 0\\$ - But for a Kernel ist has to be:\\ - $k(x,x) \geq 0 \forall{x} $ + But for a Kernel ist has to hold:\\ + $k(x,x) \geq 0 \forall{x} $\lightning \item $k(x,y) = 5x^Ty = 5 \cdot k'(x,y)$ with $k'(x,y) = x^Ty =$\\ - $= \alpha *k'(x,y)$ where $\alpha =5$ + $= \alpha *k'(x,y)$ where $\alpha =5$\checkmark \item $k(x,y)=(x^Ty+1)^2= (k_1(x,y)+k_2(x,y))^2$\\ where $k_1(x,y)=x^Ty, k_2(x,y)=1$\\ - $k_1$ and $k_2$ are proven as kernels in task 2 and 1. + $k_1$ and $k_2$ are proven as kernels in task 2 and 1 and summing and multiplying is allowed for kernels. So 5. is also a kernel.\checkmark \end{enumerate} \end{document} diff --git a/is/ub9/regression.png b/is/ub9/regression.png index 105a826..58499f0 100644 --- a/is/ub9/regression.png +++ b/is/ub9/regression.png Binary files differ diff --git a/is/ub9/residuals.png b/is/ub9/residuals.png index c60ca43..0692b9f 100644 --- a/is/ub9/residuals.png +++ b/is/ub9/residuals.png Binary files differ diff --git a/is/ub9/sample.py b/is/ub9/sample.py index 8ac1fc5..90b9e48 100755 --- a/is/ub9/sample.py +++ b/is/ub9/sample.py @@ -3,6 +3,7 @@ import matplotlib.pyplot as plt import random as rand from sklearn import svm +from scipy.optimize import curve_fit n=500 @@ -18,9 +19,19 @@ X=np.array(X) Xt=X.reshape((500,1)) -clf=svm.SVR() -clf.fit(Xt,Y) -ypred=clf.predict(Xt) +def func(x,p1,p2,p3,p4,p5): + return p1*x**p2+p3*np.exp(x*p4)+p5 + +popt, pcov = curve_fit(func, X, Y) +p1 = popt[0] +p2 = popt[1] +p3 = popt[2] +p4 = popt[3] +p5 = popt[4] +print(popt) +ypred=func(X,p1,p2,p3,p4,p5) +print(np.sum(Y-ypred)) +print(np.mean(Y-ypred)) plt.plot(X,ypred,'rx')