1284 lines
72 KiB
Plaintext
1284 lines
72 KiB
Plaintext
{
|
||
"cells": [
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "slide"
|
||
}
|
||
},
|
||
"source": [
|
||
"## Uczenie maszynowe – zastosowania\n",
|
||
"# 4. Metody ewaluacji"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "slide"
|
||
}
|
||
},
|
||
"source": [
|
||
"## 4.1. Metodologia testowania"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "notes"
|
||
}
|
||
},
|
||
"source": [
|
||
"W uczeniu maszynowym bardzo ważna jest ewaluacja budowanego modelu. Dlatego dobrze jest podzielić posiadane dane na odrębne zbiory – osobny zbiór danych do uczenia i osobny do testowania. W niektórych przypadkach potrzeba będzie dodatkowo wyodrębnić tzw. zbiór walidacyjny."
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "subslide"
|
||
}
|
||
},
|
||
"source": [
|
||
"### Zbiór uczący a zbiór testowy"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "fragment"
|
||
}
|
||
},
|
||
"source": [
|
||
"* Na zbiorze uczącym (treningowym) uczymy algorytmy, a na zbiorze testowym sprawdzamy ich poprawność.\n",
|
||
"* Zbiór uczący powinien być kilkukrotnie większy od testowego (np. 4:1, 9:1 itp.).\n",
|
||
"* Zbiór testowy często jest nieznany.\n",
|
||
"* Należy unikać mieszania danych testowych i treningowych – nie wolno „zanieczyszczać” danych treningowych danymi testowymi!"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "subslide"
|
||
}
|
||
},
|
||
"source": [
|
||
"Czasami potrzebujemy dobrać parametry modelu, np. $\\alpha$ – który zbiór wykorzystać do tego celu?"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "subslide"
|
||
}
|
||
},
|
||
"source": [
|
||
"### Zbiór walidacyjny"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "fragment"
|
||
}
|
||
},
|
||
"source": [
|
||
"Do doboru parametrów najlepiej użyć jeszcze innego zbioru – jest to tzw. **zbiór walidacyjny**"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "fragment"
|
||
}
|
||
},
|
||
"source": [
|
||
" * Zbiór walidacyjny powinien mieć wielkość zbliżoną do wielkości zbioru testowego, czyli np. dane można podzielić na te trzy zbiory w proporcjach 3:1:1, 8:1:1 itp."
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "slide"
|
||
}
|
||
},
|
||
"source": [
|
||
"### Walidacja krzyżowa"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "fragment"
|
||
}
|
||
},
|
||
"source": [
|
||
"Którą część danych wydzielić jako zbiór walidacyjny tak, żeby było „najlepiej”?"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "fragment"
|
||
}
|
||
},
|
||
"source": [
|
||
" * Niech każda partia danych pełni tę rolę naprzemiennie!"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "subslide"
|
||
}
|
||
},
|
||
"source": [
|
||
"<img width=\"100%\" src=\"https://chrisjmccormick.files.wordpress.com/2013/07/10_fold_cv.png\"/>\n",
|
||
"Żródło: https://chrisjmccormick.wordpress.com/2013/07/31/k-fold-cross-validation-with-matlab-code/"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "subslide"
|
||
}
|
||
},
|
||
"source": [
|
||
"### Walidacja krzyżowa\n",
|
||
"\n",
|
||
"* Podziel dane $D = \\left\\{ (x^{(1)}, y^{(1)}), \\ldots, (x^{(m)}, y^{(m)})\\right\\} $ na $N$ rozłącznych zbiorów $T_1,\\ldots,T_N$\n",
|
||
"* Dla $i=1,\\ldots,N$, wykonaj:\n",
|
||
" * Użyj $T_i$ do walidacji i zbiór $S_i$ do trenowania, gdzie $S_i = D \\smallsetminus T_i$. \n",
|
||
" * Zapisz model $\\theta_i$.\n",
|
||
"* Akumuluj wyniki dla modeli $\\theta_i$ dla zbiorów $T_i$.\n",
|
||
"* Ustalaj parametry uczenia na akumulowanych wynikach."
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "subslide"
|
||
}
|
||
},
|
||
"source": [
|
||
"### Walidacja krzyżowa – wskazówki\n",
|
||
"\n",
|
||
"* Zazwyczaj ustala się $N$ w przedziale od $4$ do $10$, tzw. $N$-krotna walidacja krzyżowa (*$N$-fold cross validation*). \n",
|
||
"* Zbiór $D$ warto zrandomizować przed podziałem.\n",
|
||
"* W jaki sposób akumulować wyniki dla wszystkich zbiórow $T_i$?\n",
|
||
"* Po ustaleniu parametrów dla każdego $T_i$, trenujemy model na całych danych treningowych z ustalonymi parametrami.\n",
|
||
"* Testujemy na zbiorze testowym (jeśli nim dysponujemy)."
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "subslide"
|
||
}
|
||
},
|
||
"source": [
|
||
"### _Leave-one-out_\n",
|
||
"\n",
|
||
"Jest to szczególny przypadek walidacji krzyżowej, w której $N = m$."
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "fragment"
|
||
}
|
||
},
|
||
"source": [
|
||
"* Jaki jest rozmiar pojedynczego zbioru $T_i$?\n",
|
||
"* Jakie są zalety i wady tej metody?\n",
|
||
"* Kiedy może być przydatna?"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "subslide"
|
||
}
|
||
},
|
||
"source": [
|
||
"### Zbiór walidujący a algorytmy optymalizacji\n",
|
||
"\n",
|
||
"* Gdy błąd rośnie na zbiorze uczącym, mamy źle dobrany parametr $\\alpha$. Należy go wtedy zmniejszyć.\n",
|
||
"* Gdy błąd zmniejsza się na zbiorze trenującym, ale rośnie na zbiorze walidującym, mamy do czynienia ze zjawiskiem **nadmiernego dopasowania** (*overfitting*).\n",
|
||
"* Należy wtedy przerwać optymalizację. Automatyzacja tego procesu to _early stopping_."
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "slide"
|
||
}
|
||
},
|
||
"source": [
|
||
"## 4.2. Miary jakości"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "notes"
|
||
}
|
||
},
|
||
"source": [
|
||
"Aby przeprowadzić ewaluację modelu, musimy wybrać **miarę** (**metrykę**), jakiej będziemy używać.\n",
|
||
"\n",
|
||
"Jakiej miary użyc najlepiej?\n",
|
||
" * To zależy od rodzaju zadania.\n",
|
||
" * Innych metryk używa się do regresji, a innych do klasyfikacji"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "slide"
|
||
}
|
||
},
|
||
"source": [
|
||
"### Metryki dla zadań regresji\n",
|
||
"\n",
|
||
"Dla zadań regresji możemy zastosować np.:\n",
|
||
" * błąd średniokwadratowy (*root-mean-square error*, RMSE):\n",
|
||
" $$ \\mathrm{RMSE} \\, = \\, \\sqrt{ \\frac{1}{m} \\sum_{i=1}^{m} \\left( \\hat{y}^{(i)} - y^{(i)} \\right)^2 } $$\n",
|
||
" * średni błąd bezwzględny (*mean absolute error*, MAE):\n",
|
||
" $$ \\mathrm{MAE} \\, = \\, \\frac{1}{m} \\sum_{i=1}^{m} \\left| \\hat{y}^{(i)} - y^{(i)} \\right| $$"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "notes"
|
||
}
|
||
},
|
||
"source": [
|
||
"W powyższych wzorach $y^{(i)}$ oznacza **oczekiwaną** wartości zmiennej $y$ w $i$-tym przykładzie, a $\\hat{y}^{(i)}$ oznacza wartość zmiennej $y$ w $i$-tym przykładzie wyliczoną (**przewidzianą**) przez nasz model."
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "slide"
|
||
}
|
||
},
|
||
"source": [
|
||
"### Metryki dla zadań klasyfikacji\n",
|
||
"\n",
|
||
"Aby przedstawić kilka najpopularniejszych metryk stosowanych dla zadań klasyfikacyjnych, posłużmy się następującym przykładem:"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 24,
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "notes"
|
||
}
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"# Przydatne importy\n",
|
||
"\n",
|
||
"import ipywidgets as widgets\n",
|
||
"import matplotlib.pyplot as plt\n",
|
||
"import numpy as np\n",
|
||
"import pandas\n",
|
||
"import random\n",
|
||
"import seaborn\n",
|
||
"\n",
|
||
"%matplotlib inline"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 25,
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "notes"
|
||
}
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"def powerme(x1,x2,n):\n",
|
||
" \"\"\"Funkcja, która generuje n potęg dla zmiennych x1 i x2 oraz ich iloczynów\"\"\"\n",
|
||
" X = []\n",
|
||
" for m in range(n+1):\n",
|
||
" for i in range(m+1):\n",
|
||
" X.append(np.multiply(np.power(x1,i),np.power(x2,(m-i))))\n",
|
||
" return np.hstack(X)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 26,
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "notes"
|
||
}
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"def plot_data_for_classification(X, Y, xlabel=None, ylabel=None, Y_predicted=[], highlight=None):\n",
|
||
" \"\"\"Wykres danych dla zadania klasyfikacji\"\"\"\n",
|
||
" fig = plt.figure(figsize=(16*.6, 9*.6))\n",
|
||
" ax = fig.add_subplot(111)\n",
|
||
" fig.subplots_adjust(left=0.1, right=0.9, bottom=0.1, top=0.9)\n",
|
||
" X = X.tolist()\n",
|
||
" Y = Y.tolist()\n",
|
||
" X1n = [x[1] for x, y in zip(X, Y) if y[0] == 0]\n",
|
||
" X1p = [x[1] for x, y in zip(X, Y) if y[0] == 1]\n",
|
||
" X2n = [x[2] for x, y in zip(X, Y) if y[0] == 0]\n",
|
||
" X2p = [x[2] for x, y in zip(X, Y) if y[0] == 1]\n",
|
||
" \n",
|
||
" if len(Y_predicted) > 0:\n",
|
||
" Y_predicted = Y_predicted.tolist()\n",
|
||
" X1tn = [x[1] for x, y, yp in zip(X, Y, Y_predicted) if y[0] == 0 and yp[0] == 0]\n",
|
||
" X1fn = [x[1] for x, y, yp in zip(X, Y, Y_predicted) if y[0] == 1 and yp[0] == 0]\n",
|
||
" X1tp = [x[1] for x, y, yp in zip(X, Y, Y_predicted) if y[0] == 1 and yp[0] == 1]\n",
|
||
" X1fp = [x[1] for x, y, yp in zip(X, Y, Y_predicted) if y[0] == 0 and yp[0] == 1]\n",
|
||
" X2tn = [x[2] for x, y, yp in zip(X, Y, Y_predicted) if y[0] == 0 and yp[0] == 0]\n",
|
||
" X2fn = [x[2] for x, y, yp in zip(X, Y, Y_predicted) if y[0] == 1 and yp[0] == 0]\n",
|
||
" X2tp = [x[2] for x, y, yp in zip(X, Y, Y_predicted) if y[0] == 1 and yp[0] == 1]\n",
|
||
" X2fp = [x[2] for x, y, yp in zip(X, Y, Y_predicted) if y[0] == 0 and yp[0] == 1]\n",
|
||
" \n",
|
||
" if highlight == 'tn':\n",
|
||
" ax.scatter(X1tn, X2tn, c='r', marker='x', s=100, label='Dane')\n",
|
||
" ax.scatter(X1fn, X2fn, c='k', marker='o', s=50, label='Dane')\n",
|
||
" ax.scatter(X1tp, X2tp, c='k', marker='o', s=50, label='Dane')\n",
|
||
" ax.scatter(X1fp, X2fp, c='k', marker='x', s=50, label='Dane')\n",
|
||
" elif highlight == 'fn':\n",
|
||
" ax.scatter(X1tn, X2tn, c='k', marker='x', s=50, label='Dane')\n",
|
||
" ax.scatter(X1fn, X2fn, c='g', marker='o', s=100, label='Dane')\n",
|
||
" ax.scatter(X1tp, X2tp, c='k', marker='o', s=50, label='Dane')\n",
|
||
" ax.scatter(X1fp, X2fp, c='k', marker='x', s=50, label='Dane')\n",
|
||
" elif highlight == 'tp':\n",
|
||
" ax.scatter(X1tn, X2tn, c='k', marker='x', s=50, label='Dane')\n",
|
||
" ax.scatter(X1fn, X2fn, c='k', marker='o', s=50, label='Dane')\n",
|
||
" ax.scatter(X1tp, X2tp, c='g', marker='o', s=100, label='Dane')\n",
|
||
" ax.scatter(X1fp, X2fp, c='k', marker='x', s=50, label='Dane')\n",
|
||
" elif highlight == 'fp':\n",
|
||
" ax.scatter(X1tn, X2tn, c='k', marker='x', s=50, label='Dane')\n",
|
||
" ax.scatter(X1fn, X2fn, c='k', marker='o', s=50, label='Dane')\n",
|
||
" ax.scatter(X1tp, X2tp, c='k', marker='o', s=50, label='Dane')\n",
|
||
" ax.scatter(X1fp, X2fp, c='r', marker='x', s=100, label='Dane')\n",
|
||
" else:\n",
|
||
" ax.scatter(X1tn, X2tn, c='r', marker='x', s=50, label='Dane')\n",
|
||
" ax.scatter(X1fn, X2fn, c='g', marker='o', s=50, label='Dane')\n",
|
||
" ax.scatter(X1tp, X2tp, c='g', marker='o', s=50, label='Dane')\n",
|
||
" ax.scatter(X1fp, X2fp, c='r', marker='x', s=50, label='Dane')\n",
|
||
"\n",
|
||
" else:\n",
|
||
" ax.scatter(X1n, X2n, c='r', marker='x', s=50, label='Dane')\n",
|
||
" ax.scatter(X1p, X2p, c='g', marker='o', s=50, label='Dane')\n",
|
||
" \n",
|
||
" if xlabel:\n",
|
||
" ax.set_xlabel(xlabel)\n",
|
||
" if ylabel:\n",
|
||
" ax.set_ylabel(ylabel)\n",
|
||
" \n",
|
||
" ax.margins(.05, .05)\n",
|
||
" return fig"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 27,
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "notes"
|
||
}
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"# Wczytanie danych\n",
|
||
"import pandas\n",
|
||
"import numpy as np\n",
|
||
"\n",
|
||
"alldata = pandas.read_csv('data-metrics.tsv', sep='\\t')\n",
|
||
"data = np.matrix(alldata)\n",
|
||
"\n",
|
||
"m, n_plus_1 = data.shape\n",
|
||
"n = n_plus_1 - 1\n",
|
||
"\n",
|
||
"X2 = powerme(data[:, 1], data[:, 2], n)\n",
|
||
"Y2 = np.matrix(data[:, 0]).reshape(m, 1)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 28,
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "subslide"
|
||
}
|
||
},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAm8AAAFmCAYAAAA70X3dAAAABHNCSVQICAgIfAhkiAAAAAlw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8AYACZnZVknHJO2WNGdm/yrlKgHoQIQ3AEjAzF4naVTSve5+RtKvS/pIqpUC0JHo8wYA62RmmyX9pqSbJR119/+acpUAtDHCGwAAQI7QbAoAAJAjhDcAAIAcIbwBAADkCOENAAAgRwhvAAAAOUJ4AwAAyBHCGwAAQI4Q3gAAAHKE8AYAAJAj/x84am1cPs4OtwAAAABJRU5ErkJggg==\n",
|
||
"text/plain": [
|
||
"<Figure size 691.2x388.8 with 1 Axes>"
|
||
]
|
||
},
|
||
"metadata": {
|
||
"needs_background": "light"
|
||
},
|
||
"output_type": "display_data"
|
||
}
|
||
],
|
||
"source": [
|
||
"fig = plot_data_for_classification(X2, Y2, xlabel=r'$x_1$', ylabel=r'$x_2$')"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 29,
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "notes"
|
||
}
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"def safeSigmoid(x, eps=0):\n",
|
||
" \"\"\"Funkcja sigmoidalna zmodyfikowana w taki sposób, \n",
|
||
" żeby wartości zawsz były odległe od asymptot o co najmniej eps\n",
|
||
" \"\"\"\n",
|
||
" y = 1.0/(1.0 + np.exp(-x))\n",
|
||
" if eps > 0:\n",
|
||
" y[y < eps] = eps\n",
|
||
" y[y > 1 - eps] = 1 - eps\n",
|
||
" return y\n",
|
||
"\n",
|
||
"def h(theta, X, eps=0.0):\n",
|
||
" \"\"\"Funkcja hipotezy (regresja logistyczna)\"\"\"\n",
|
||
" return safeSigmoid(X*theta, eps)\n",
|
||
"\n",
|
||
"def J(h,theta,X,y, lamb=0):\n",
|
||
" \"\"\"Funkcja kosztu dla regresji logistycznej\"\"\"\n",
|
||
" m = len(y)\n",
|
||
" f = h(theta, X, eps=10**-7)\n",
|
||
" j = -np.sum(np.multiply(y, np.log(f)) + \n",
|
||
" np.multiply(1 - y, np.log(1 - f)), axis=0)/m\n",
|
||
" if lamb > 0:\n",
|
||
" j += lamb/(2*m) * np.sum(np.power(theta[1:],2))\n",
|
||
" return j\n",
|
||
"\n",
|
||
"def dJ(h,theta,X,y,lamb=0):\n",
|
||
" \"\"\"Gradient funkcji kosztu\"\"\"\n",
|
||
" g = 1.0/y.shape[0]*(X.T*(h(theta,X)-y))\n",
|
||
" if lamb > 0:\n",
|
||
" g[1:] += lamb/float(y.shape[0]) * theta[1:] \n",
|
||
" return g\n",
|
||
"\n",
|
||
"def classifyBi(theta, X):\n",
|
||
" \"\"\"Funkcja predykcji - klasyfikacja dwuklasowa\"\"\"\n",
|
||
" prob = h(theta, X)\n",
|
||
" return prob"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 30,
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "notes"
|
||
}
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"def GD(h, fJ, fdJ, theta, X, y, alpha=0.01, eps=10**-3, maxSteps=10000):\n",
|
||
" \"\"\"Metoda gradientu prostego dla regresji logistycznej\"\"\"\n",
|
||
" errorCurr = fJ(h, theta, X, y)\n",
|
||
" errors = [[errorCurr, theta]]\n",
|
||
" while True:\n",
|
||
" # oblicz nowe theta\n",
|
||
" theta = theta - alpha * fdJ(h, theta, X, y)\n",
|
||
" # raportuj poziom błędu\n",
|
||
" errorCurr, errorPrev = fJ(h, theta, X, y), errorCurr\n",
|
||
" # kryteria stopu\n",
|
||
" if abs(errorPrev - errorCurr) <= eps:\n",
|
||
" break\n",
|
||
" if len(errors) > maxSteps:\n",
|
||
" break\n",
|
||
" errors.append([errorCurr, theta]) \n",
|
||
" return theta, errors"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 31,
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "subslide"
|
||
}
|
||
},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"theta = [[ 1.37136167]\n",
|
||
" [ 0.90128948]\n",
|
||
" [ 0.54708112]\n",
|
||
" [-5.9929264 ]\n",
|
||
" [ 2.64435168]\n",
|
||
" [-4.27978238]]\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"# Uruchomienie metody gradientu prostego dla regresji logistycznej\n",
|
||
"theta_start = np.matrix(np.zeros(X2.shape[1])).reshape(X2.shape[1],1)\n",
|
||
"theta, errors = GD(h, J, dJ, theta_start, X2, Y2, \n",
|
||
" alpha=0.1, eps=10**-7, maxSteps=10000)\n",
|
||
"print('theta = {}'.format(theta))"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 32,
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "notes"
|
||
}
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"def plot_decision_boundary(fig, theta, X):\n",
|
||
" \"\"\"Wykres granicy klas\"\"\"\n",
|
||
" ax = fig.axes[0]\n",
|
||
" xx, yy = np.meshgrid(np.arange(-1.0, 1.0, 0.02),\n",
|
||
" np.arange(-1.0, 1.0, 0.02))\n",
|
||
" l = len(xx.ravel())\n",
|
||
" C = powerme(xx.reshape(l, 1), yy.reshape(l, 1), n)\n",
|
||
" z = classifyBi(theta, C).reshape(int(np.sqrt(l)), int(np.sqrt(l)))\n",
|
||
"\n",
|
||
" plt.contour(xx, yy, z, levels=[0.5], lw=3);"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 33,
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "subslide"
|
||
}
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"Y_expected = Y2.astype(int)\n",
|
||
"Y_predicted = (classifyBi(theta, X2) > 0.5).astype(int)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 34,
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "notes"
|
||
}
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"# Przygotowanie interaktywnego wykresu\n",
|
||
"\n",
|
||
"dropdown_highlight = widgets.Dropdown(options=['all', 'tp', 'fp', 'tn', 'fn'], value='all', description='highlight')\n",
|
||
"\n",
|
||
"def interactive_classification(highlight):\n",
|
||
" fig = plot_data_for_classification(X2, Y2, xlabel=r'$x_1$', ylabel=r'$x_2$',\n",
|
||
" Y_predicted=Y_predicted, highlight=highlight)\n",
|
||
" plot_decision_boundary(fig, theta, X2)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 35,
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "subslide"
|
||
}
|
||
},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"application/vnd.jupyter.widget-view+json": {
|
||
"model_id": "32929ab5e3024128bd39a6c165e50196",
|
||
"version_major": 2,
|
||
"version_minor": 0
|
||
},
|
||
"text/plain": [
|
||
"interactive(children=(Dropdown(description='highlight', options=('all', 'tp', 'fp', 'tn', 'fn'), value='all'),…"
|
||
]
|
||
},
|
||
"metadata": {},
|
||
"output_type": "display_data"
|
||
},
|
||
{
|
||
"data": {
|
||
"text/plain": [
|
||
"<function __main__.interactive_classification(highlight)>"
|
||
]
|
||
},
|
||
"execution_count": 35,
|
||
"metadata": {},
|
||
"output_type": "execute_result"
|
||
}
|
||
],
|
||
"source": [
|
||
"widgets.interact(interactive_classification, highlight=dropdown_highlight)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "subslide"
|
||
}
|
||
},
|
||
"source": [
|
||
"Zadanie klasyfikacyjne z powyższego przykładu polega na przypisaniu punktów do jednej z dwóch kategorii:\n",
|
||
" 0. <font color=\"red\">czerwone krzyżyki</font>\n",
|
||
" 1. <font color=\"green\">zielone kółka</font>\n",
|
||
"\n",
|
||
"W tym celu zastosowano regresję logistyczną.\n",
|
||
"\n",
|
||
"W rezultacie otrzymano model, który dzieli płaszczyznę na dwa obszary:\n",
|
||
" 0. <font color=\"red\">na zewnątrz granatowej krzywej</font>\n",
|
||
" 1. <font color=\"green\">wewnątrz granatowej krzywej</font>\n",
|
||
" \n",
|
||
"Model przewiduje klasę <font color=\"red\">0 („czerwoną”)</font> dla punktów znajdujący się w obszarze na zewnątrz krzywej, natomiast klasę <font color=\"green\">1 („zieloną”)</font> dla punktów znajdujących sie w obszarze wewnąrz krzywej."
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "subslide"
|
||
}
|
||
},
|
||
"source": [
|
||
"Wszysktie obserwacje możemy podzielić zatem na cztery grupy:\n",
|
||
" * **true positives (TP)** – prawidłowo sklasyfikowane pozytywne przykłady (<font color=\"green\">zielone kółka</font> w <font color=\"green\">wewnętrznym obszarze</font>)\n",
|
||
" * **true negatives (TN)** – prawidłowo sklasyfikowane negatywne przykłady (<font color=\"red\">czerwone krzyżyki</font> w <font color=\"red\">zewnętrznym obszarze</font>)\n",
|
||
" * **false positives (FP)** – negatywne przykłady sklasyfikowane jako pozytywne (<font color=\"red\">czerwone krzyżyki</font> w <font color=\"green\">wewnętrznym obszarze</font>)\n",
|
||
" * **false negatives (FN)** – pozytywne przykłady sklasyfikowane jako negatywne (<font color=\"green\">zielone kółka</font> w <font color=\"red\">zewnętrznym obszarze</font>)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "subslide"
|
||
}
|
||
},
|
||
"source": [
|
||
"Innymi słowy:\n",
|
||
"\n",
|
||
"<img width=\"50%\" src=\"https://blog.aimultiple.com/wp-content/uploads/2019/07/positive-negative-true-false-matrix.png\">"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 13,
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "skip"
|
||
}
|
||
},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"TP = 5\n",
|
||
"TN = 35\n",
|
||
"FP = 3\n",
|
||
"FN = 6\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"# Obliczmy TP, TN, FP i FN\n",
|
||
"\n",
|
||
"tp = 0\n",
|
||
"tn = 0\n",
|
||
"fp = 0\n",
|
||
"fn = 0\n",
|
||
"\n",
|
||
"for i in range(len(Y_expected)):\n",
|
||
" if Y_expected[i] == 1 and Y_predicted[i] == 1:\n",
|
||
" tp += 1\n",
|
||
" elif Y_expected[i] == 0 and Y_predicted[i] == 0:\n",
|
||
" tn += 1\n",
|
||
" elif Y_expected[i] == 0 and Y_predicted[i] == 1:\n",
|
||
" fp += 1\n",
|
||
" elif Y_expected[i] == 1 and Y_predicted[i] == 0:\n",
|
||
" fn += 1\n",
|
||
" \n",
|
||
"print('TP =', tp)\n",
|
||
"print('TN =', tn)\n",
|
||
"print('FP =', fp)\n",
|
||
"print('FN =', fn)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "notes"
|
||
}
|
||
},
|
||
"source": [
|
||
"Możemy teraz zdefiniować następujące metryki:"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "slide"
|
||
}
|
||
},
|
||
"source": [
|
||
"#### Dokładność (*accuracy*)\n",
|
||
"$$ \\mbox{accuracy} = \\frac{\\mbox{przypadki poprawnie sklasyfikowane}}{\\mbox{wszystkie przypadki}} = \\frac{TP + TN}{TP + TN + FP + FN} $$"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "notes"
|
||
}
|
||
},
|
||
"source": [
|
||
"Dokładność otrzymujemy przez podzielenie liczby przypadków poprawnie sklasyfikowanych przez liczbę wszystkich przypadków:"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 14,
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "subslide"
|
||
}
|
||
},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"Accuracy: 0.8163265306122449\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"accuracy = (tp + tn) / (tp + tn + fp + fn)\n",
|
||
"print('Accuracy:', accuracy)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "notes"
|
||
}
|
||
},
|
||
"source": [
|
||
"**Uwaga:** Nie zawsze dokładność będzie dobrą miarą, zwłaszcza gdy klasy są bardzo asymetryczne!\n",
|
||
"\n",
|
||
"*Przykład:* Wyobraźmy sobie test na koronawirusa, który **zawsze** zwraca wynik negatywny. Jaką przydatność będzie miał taki test w praktyce? Żadną. A jaka będzie jego *dokładność*? Policzmy:\n",
|
||
"$$ \\mbox{accuracy} \\, = \\, \\frac{\\mbox{szacowana liczba osób zdrowych na świecie}}{\\mbox{populacja Ziemi}} \\, \\approx \\, \\frac{7\\,700\\,000\\,000 - 600\\,000}{7\\,700\\,000\\,000} \\, \\approx \\, 0.99992 $$\n",
|
||
"(zaokrąglone dane z 27 marca 2020)\n",
|
||
"\n",
|
||
"Powyższy wynik jest tak wysoki, ponieważ zdecydowana większość osób na świecie nie jest zakażona, więc biorąc losowego Ziemianina możemy w ciemno strzelać, że nie ma koronawirusa.\n",
|
||
"\n",
|
||
"W tym przypadku duża różnica w liczności obu zbiorów (zakażeni/niezakażeni) powoduje, że *accuracy* nie jest dobrą metryką.\n",
|
||
"\n",
|
||
"Dlatego dysponujemy również innymi metrykami:"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "slide"
|
||
}
|
||
},
|
||
"source": [
|
||
"#### Precyzja (*precision*)\n",
|
||
"$$ \\mbox{precision} = \\frac{TP}{TP + FP} $$"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 15,
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "subslide"
|
||
}
|
||
},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"Precision: 0.625\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"precision = tp / (tp + fp)\n",
|
||
"print('Precision:', precision)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "notes"
|
||
}
|
||
},
|
||
"source": [
|
||
"Precyzja określa, jaka część przykładów sklasyfikowanych jako pozytywne to faktycznie przykłady pozytywne."
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "slide"
|
||
}
|
||
},
|
||
"source": [
|
||
"#### Pokrycie (czułość, *recall*)\n",
|
||
"$$ \\mbox{recall} = \\frac{TP}{TP + FN} $$"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 16,
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "subslide"
|
||
}
|
||
},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"Recall: 0.45454545454545453\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"recall = tp / (tp + fn)\n",
|
||
"print('Recall:', recall)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "notes"
|
||
}
|
||
},
|
||
"source": [
|
||
"Pokrycie mówi nam, jaka część przykładów pozytywnych została poprawnie sklasyfikowana."
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "slide"
|
||
}
|
||
},
|
||
"source": [
|
||
"#### *$F$-measure* (*$F$-score*)\n",
|
||
"$$ F = \\frac{2 \\cdot \\mbox{precision} \\cdot \\mbox{recall}}{\\mbox{precision} + \\mbox{recall}} $$"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 17,
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "subslide"
|
||
}
|
||
},
|
||
"outputs": [
|
||
{
|
||
"name": "stdout",
|
||
"output_type": "stream",
|
||
"text": [
|
||
"F-score: 0.5263157894736842\n"
|
||
]
|
||
}
|
||
],
|
||
"source": [
|
||
"fscore = (2 * precision * recall) / (precision + recall)\n",
|
||
"print('F-score:', fscore)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "notes"
|
||
}
|
||
},
|
||
"source": [
|
||
"$F$-_measure_ jest kompromisem między precyzją a pokryciem (a ściślej: jest średnią harmoniczną precyzji i pokrycia)."
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "subslide"
|
||
}
|
||
},
|
||
"source": [
|
||
"$F$-_measure_ jest szczególnym przypadkiem ogólniejszej miary:"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "subslide"
|
||
}
|
||
},
|
||
"source": [
|
||
"*$F_\\beta$-measure*:\n",
|
||
"$$ F_\\beta = \\frac{(1 + \\beta) \\cdot \\mbox{precision} \\cdot \\mbox{recall}}{\\beta^2 \\cdot \\mbox{precision} + \\mbox{recall}} $$"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "fragment"
|
||
}
|
||
},
|
||
"source": [
|
||
"Dla $\\beta = 1$ otrzymujemy:\n",
|
||
"$$ F_1 \\, = \\, \\frac{(1 + 1) \\cdot \\mbox{precision} \\cdot \\mbox{recall}}{1^2 \\cdot \\mbox{precision} + \\mbox{recall}} \\, = \\, \\frac{2 \\cdot \\mbox{precision} \\cdot \\mbox{recall}}{\\mbox{precision} + \\mbox{recall}} \\, = \\, F $$"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "slide"
|
||
}
|
||
},
|
||
"source": [
|
||
"## 4.3. Obserwacje odstające"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "notes"
|
||
}
|
||
},
|
||
"source": [
|
||
"**Obserwacje odstające** (*outliers*) – to wszelkie obserwacje posiadające nietypową wartość.\n",
|
||
"\n",
|
||
"Mogą być na przykład rezultatem błędnego pomiaru albo pomyłki przy wprowadzaniu danych do bazy, ale nie tylko.\n",
|
||
"\n",
|
||
"Obserwacje odstające mogą niekiedy znacząco wpłynąć na parametry modelu, dlatego ważne jest, żeby takie obserwacje odrzucić zanim przystąpi się do tworzenia modelu."
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "notes"
|
||
}
|
||
},
|
||
"source": [
|
||
"W poniższym przykładzie można zobaczyć wpływ obserwacji odstających na wynik modelowania na przykładzie danych dotyczących cen mieszkań zebranych z ogłoszeń na portalu Gratka.pl: tutaj przykładem obserwacji odstającej może być ogłoszenie, w którym podano cenę w tys. zł zamiast ceny w zł."
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 18,
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "notes"
|
||
}
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"# Przydatne funkcje\n",
|
||
"\n",
|
||
"def h_linear(Theta, x):\n",
|
||
" \"\"\"Funkcja regresji liniowej\"\"\"\n",
|
||
" return x * Theta\n",
|
||
"\n",
|
||
"def linear_regression(theta):\n",
|
||
" \"\"\"Ta funkcja zwraca funkcję regresji liniowej dla danego wektora parametrów theta\"\"\"\n",
|
||
" return lambda x: h_linear(theta, x)\n",
|
||
"\n",
|
||
"def cost(theta, X, y):\n",
|
||
" \"\"\"Wersja macierzowa funkcji kosztu\"\"\"\n",
|
||
" m = len(y)\n",
|
||
" J = 1.0 / (2.0 * m) * ((X * theta - y).T * (X * theta - y))\n",
|
||
" return J.item()\n",
|
||
"\n",
|
||
"def gradient(theta, X, y):\n",
|
||
" \"\"\"Wersja macierzowa gradientu funkcji kosztu\"\"\"\n",
|
||
" return 1.0 / len(y) * (X.T * (X * theta - y)) \n",
|
||
"\n",
|
||
"def gradient_descent(fJ, fdJ, theta, X, y, alpha=0.1, eps=10**-5):\n",
|
||
" \"\"\"Algorytm gradientu prostego (wersja macierzowa)\"\"\"\n",
|
||
" current_cost = fJ(theta, X, y)\n",
|
||
" logs = [[current_cost, theta]]\n",
|
||
" while True:\n",
|
||
" theta = theta - alpha * fdJ(theta, X, y)\n",
|
||
" current_cost, prev_cost = fJ(theta, X, y), current_cost\n",
|
||
" if abs(prev_cost - current_cost) > 10**15:\n",
|
||
" print('Algorithm does not converge!')\n",
|
||
" break\n",
|
||
" if abs(prev_cost - current_cost) <= eps:\n",
|
||
" break\n",
|
||
" logs.append([current_cost, theta]) \n",
|
||
" return theta, logs\n",
|
||
"\n",
|
||
"def plot_data(X, y, xlabel, ylabel):\n",
|
||
" \"\"\"Wykres danych (wersja macierzowa)\"\"\"\n",
|
||
" fig = plt.figure(figsize=(16*.6, 9*.6))\n",
|
||
" ax = fig.add_subplot(111)\n",
|
||
" fig.subplots_adjust(left=0.1, right=0.9, bottom=0.1, top=0.9)\n",
|
||
" ax.scatter([X[:, 1]], [y], c='r', s=50, label='Dane')\n",
|
||
" \n",
|
||
" ax.set_xlabel(xlabel)\n",
|
||
" ax.set_ylabel(ylabel)\n",
|
||
" ax.margins(.05, .05)\n",
|
||
" plt.ylim(y.min() - 1, y.max() + 1)\n",
|
||
" plt.xlim(np.min(X[:, 1]) - 1, np.max(X[:, 1]) + 1)\n",
|
||
" return fig\n",
|
||
"\n",
|
||
"def plot_regression(fig, fun, theta, X):\n",
|
||
" \"\"\"Wykres krzywej regresji (wersja macierzowa)\"\"\"\n",
|
||
" ax = fig.axes[0]\n",
|
||
" x0 = np.min(X[:, 1]) - 1.0\n",
|
||
" x1 = np.max(X[:, 1]) + 1.0\n",
|
||
" L = [x0, x1]\n",
|
||
" LX = np.matrix([1, x0, 1, x1]).reshape(2, 2)\n",
|
||
" ax.plot(L, fun(theta, LX), linewidth='2',\n",
|
||
" label=(r'$y={theta0:.2}{op}{theta1:.2}x$'.format(\n",
|
||
" theta0=float(theta[0][0]),\n",
|
||
" theta1=(float(theta[1][0]) if theta[1][0] >= 0 else float(-theta[1][0])),\n",
|
||
" op='+' if theta[1][0] >= 0 else '-')))"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 19,
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "notes"
|
||
}
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"# Wczytanie danych (mieszkania) przy pomocy biblioteki pandas\n",
|
||
"\n",
|
||
"alldata = pandas.read_csv('data_flats_with_outliers.tsv', sep='\\t',\n",
|
||
" names=['price', 'isNew', 'rooms', 'floor', 'location', 'sqrMetres'])\n",
|
||
"data = np.matrix(alldata[['price', 'sqrMetres']])\n",
|
||
"\n",
|
||
"m, n_plus_1 = data.shape\n",
|
||
"n = n_plus_1 - 1\n",
|
||
"Xn = data[:, 0:n]\n",
|
||
"\n",
|
||
"Xo = np.matrix(np.concatenate((np.ones((m, 1)), Xn), axis=1)).reshape(m, n + 1)\n",
|
||
"yo = np.matrix(data[:, -1]).reshape(m, 1)\n",
|
||
"\n",
|
||
"Xo /= np.amax(Xo, axis=0)\n",
|
||
"yo /= np.amax(yo, axis=0)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 20,
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "subslide"
|
||
}
|
||
},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAmwAAAFoCAYAAADq7KeuAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAcJUlEQVR4nO3dfbBkZ10n8O9vJkOik9EISQjkBbQyC6IrAa9JkNRuYMWFKZboLu7E3ZKIWQIKFi/KGrVKFP9YastXJJCKvGZXcXwDUsUARgqNKTaGSUyAvOBMAco4kYSXDTcDiZnMs390z2a46Zn0vbdv93N7Pp+qW919znNO/+65p3u+85xznlOttQAA0K8Nsy4AAICjE9gAADonsAEAdE5gAwDonMAGANA5gQ0AoHMzC2xVdWZVfayq7qiq26rq1SPaVFW9uar2VNUnq+qZs6gVAGCWjpvhex9I8nOttZurakuSm6rq2tba7Ye1eUGSrcOf85K8bfgIAHDMmFkPW2vtrtbazcPni0nuSHL6kmYXJbm6DdyQ5KSqesKUSwUAmKkuzmGrqicneUaSv10y6/QkXzjs9d48MtQBAMy1WR4STZJU1YlJ/izJa1prX1s6e8QiI++lVVWXJbksSTZv3vz9T33qUydaJwDAat10001faq2dstzlZhrYqmpTBmHtD1prfz6iyd4kZx72+owk+0atq7V2VZKrkmRhYaHt2rVrwtUCAKxOVf3DSpab5VWileQdSe5orf3WEZpdk+Qlw6tFz09yb2vtrqkVCQDQgVn2sD07yU8k+VRV3TKc9ktJzkqS1tqVSXYm2ZZkT5KvJ3npDOoEAJipmQW21tr1GX2O2uFtWpJXTqciAIA+dXGVKAAARyawAQB0TmADAOicwAYA0DmBDQCgcwIbAEDnBDYAgM4JbAAAnRPYAAA6J7ABAHROYAMA6JzABgDQOYENAKBzAhsAQOcENgCAzglsAACdE9gAADonsAEAdE5gAwDonMAGANA5gQ0AoHMCGwBA5wQ2A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bAEDnBDYAgM4JbAAAnRPYAAA69/8AXoLYKINHTj4AAAAASUVORK5CYII=\n",
|
||
"text/plain": [
|
||
"<Figure size 691.2x388.8 with 1 Axes>"
|
||
]
|
||
},
|
||
"metadata": {
|
||
"needs_background": "light"
|
||
},
|
||
"output_type": "display_data"
|
||
}
|
||
],
|
||
"source": [
|
||
"fig = plot_data(Xo, yo, xlabel=u'metraż', ylabel=u'cena')\n",
|
||
"theta_start = np.matrix([0.0, 0.0]).reshape(2, 1)\n",
|
||
"theta, logs = gradient_descent(cost, gradient, theta_start, Xo, yo, alpha=0.01)\n",
|
||
"plot_regression(fig, h_linear, theta, Xo)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "notes"
|
||
}
|
||
},
|
||
"source": [
|
||
"Na powyższym przykładzie obserwacja odstająca jawi sie jako pojedynczy punkt po prawej stronie wykresu. Widzimy, że otrzymana krzywa regresji zamiast odwzorowywać ogólny trend, próbuje „dopasować się” do tej pojedynczej obserwacji.\n",
|
||
"\n",
|
||
"Dlatego taką obserwację należy usunąć ze zbioru danych (zobacz ponizej)."
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 21,
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "subslide"
|
||
}
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"# Odrzućmy obserwacje odstające\n",
|
||
"alldata_no_outliers = [\n",
|
||
" (index, item) for index, item in alldata.iterrows() \n",
|
||
" if item.price > 100 and item.sqrMetres > 10]\n",
|
||
"\n",
|
||
"alldata_no_outliers = alldata.loc[(alldata['price'] > 100) & (alldata['sqrMetres'] > 100)]"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 22,
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "notes"
|
||
}
|
||
},
|
||
"outputs": [],
|
||
"source": [
|
||
"data = np.matrix(alldata_no_outliers[['price', 'sqrMetres']])\n",
|
||
"\n",
|
||
"m, n_plus_1 = data.shape\n",
|
||
"n = n_plus_1 - 1\n",
|
||
"Xn = data[:, 0:n]\n",
|
||
"\n",
|
||
"Xo = np.matrix(np.concatenate((np.ones((m, 1)), Xn), axis=1)).reshape(m, n + 1)\n",
|
||
"yo = np.matrix(data[:, -1]).reshape(m, 1)\n",
|
||
"\n",
|
||
"Xo /= np.amax(Xo, axis=0)\n",
|
||
"yo /= np.amax(yo, axis=0)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "code",
|
||
"execution_count": 23,
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "subslide"
|
||
}
|
||
},
|
||
"outputs": [
|
||
{
|
||
"data": {
|
||
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAmwAAAFoCAYAAADq7KeuAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADh0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uMy4yLjIsIGh0dHA6Ly9tYXRwbG90bGliLm9yZy+WH4yJAAAgAElEQVR4nO3de5BcZ3nn8e8zmtFtZmSbsoxsWeayaO2YXWxYxZjgWi4JBKvYOAvEgs3GCsuW17GcNbdUTLIFhCSLUxtMAsgYr+PY3k3AW4GAKwgIIUk5TkJAJjbgu+IkWEjYigHP6K6Rnv3j9Eg9Mz0zPZfu82rm+6nq6tPnnO5+Z1ot/fSe533fyEwkSZJUrp66GyBJkqSpGdgkSZIKZ2CTJEkqnIFNkiSpcAY2SZKkwhnYJEmSCldbYIuIdRHxFxHxUEQ8EBHXtjgnIuIjEbEjIr4ZES+po62SJEl16q3xvUeAd2XmNyJiELg3Ir6cmQ82nXMpsL5xeynw8ca9JEnSolFbD1tm7s7MbzS2h4GHgLXjTrsMuCMrXwVOjYgzu9xUSZKkWhVRwxYRzwVeDPzduENrgSeaHu9kYqiTJEla0Oq8JApARAwAnwbenplD4w+3eErLtbQi4krgSoD+/v5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927IeUtCgY2CQtWI3AtgN4MVUw+zpVaHsbVah6K/Ag8GBm/t+IOBX4WuP8nwE2ZOY1jdd6P/AfgEsy80BErASOZebBiFgPfDIzNzS9dz9wN/COzLy7Cz+upAXMpakkLXT/mJnfAoiIB4CvZGZGxLeoesvOBn4qIt7dOH85jSVkWrgrMw80tvuAj0XEhcBR4F+PO/f3gdsMa5Lmg4FN0kJ3qGn7WNPjY1R/Bx4F3piZjzQ/KSJe2uK19jVtvwN4EriAqh74YNNzfxXYn5kfnXPrJQkHHUjSl4BfjIgAiIgXN/YPA4NTPO8UYHdmHqNa6HlJ4/kbqS63XtWxFktadAxskha7X6e6vPnNiPh24zHAXwDnR8R9EbGpxfNuBDZHxFepLoeO9r79ErAG+GrjuR/ubPMlLQYOOpAkSSqcPWySJEmFM7BJkiQVzsAmSZJUOAObJElS4QxskiRJhTOwSZIkFc7AJkmSVDgDmyRJUuH+P85m5/l5ILrVAAAAAElFTkSuQmCC\n",
|
||
"text/plain": [
|
||
"<Figure size 691.2x388.8 with 1 Axes>"
|
||
]
|
||
},
|
||
"metadata": {
|
||
"needs_background": "light"
|
||
},
|
||
"output_type": "display_data"
|
||
}
|
||
],
|
||
"source": [
|
||
"fig = plot_data(Xo, yo, xlabel=u'metraż', ylabel=u'cena')\n",
|
||
"theta_start = np.matrix([0.0, 0.0]).reshape(2, 1)\n",
|
||
"theta, logs = gradient_descent(cost, gradient, theta_start, Xo, yo, alpha=0.01)\n",
|
||
"plot_regression(fig, h_linear, theta, Xo)"
|
||
]
|
||
},
|
||
{
|
||
"cell_type": "markdown",
|
||
"metadata": {
|
||
"slideshow": {
|
||
"slide_type": "notes"
|
||
}
|
||
},
|
||
"source": [
|
||
"Na powyższym wykresie widać, że po odrzuceniu obserwacji odstających otrzymujemy dużo bardziej „wiarygodną” krzywą regresji."
|
||
]
|
||
}
|
||
],
|
||
"metadata": {
|
||
"celltoolbar": "Slideshow",
|
||
"kernelspec": {
|
||
"display_name": "Python 3",
|
||
"language": "python",
|
||
"name": "python3"
|
||
},
|
||
"language_info": {
|
||
"codemirror_mode": {
|
||
"name": "ipython",
|
||
"version": 3
|
||
},
|
||
"file_extension": ".py",
|
||
"mimetype": "text/x-python",
|
||
"name": "python",
|
||
"nbconvert_exporter": "python",
|
||
"pygments_lexer": "ipython3",
|
||
"version": "3.8.3"
|
||
},
|
||
"livereveal": {
|
||
"start_slideshow_at": "selected",
|
||
"theme": "white"
|
||
}
|
||
},
|
||
"nbformat": 4,
|
||
"nbformat_minor": 4
|
||
}
|