diff --git a/machine_learning/3_classification/lecture/week4/.ipynb_checkpoints/quiz-Preventing Overfitting in Decision Trees-checkpoint.ipynb b/machine_learning/3_classification/lecture/week4/.ipynb_checkpoints/quiz-Preventing Overfitting in Decision Trees-checkpoint.ipynb index 98d5aa4..249904c 100644 --- a/machine_learning/3_classification/lecture/week4/.ipynb_checkpoints/quiz-Preventing Overfitting in Decision Trees-checkpoint.ipynb +++ b/machine_learning/3_classification/lecture/week4/.ipynb_checkpoints/quiz-Preventing Overfitting in Decision Trees-checkpoint.ipynb @@ -127,7 +127,6 @@ "metadata": {}, "source": [ "\n", - "\n", "\n", "*Screenshot taken from [Coursera](https://www.coursera.org/learn/ml-classification/exam/NDTdJ/preventing-overfitting-in-decision-trees)*\n", "\n", @@ -146,13 +145,25 @@ "metadata": {}, "source": [ "\n", - "\n", "\n", "*Screenshot taken from [Coursera](https://www.coursera.org/learn/ml-classification/exam/NDTdJ/preventing-overfitting-in-decision-trees)*\n", "\n", "" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "** Answer **\n", + "\n", + "At this node, the y values have:\n", + "- 3 True (+1)\n", + "- 1 False (-1)\n", + "\n", + "The classification error is: 1/4 = 0.25" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -171,6 +182,50 @@ "" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "** Answer **\n", + "- x1 has 2 zeros and 2 ones, so spliting by x1, we have the tree structure as follow" + ] + }, + { + "cell_type": "code", + "execution_count": 47, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " root (3, 1)\n", + " |---------------|----------------|\n", + " | |\n", + " | |\n", + " | |\n", + " node_1 (2,0) node_1 (1,1) \n" + ] + } + ], + "source": [ + "print ' %s' % 'root (3, 1)'\n", + "print ' |---------------|----------------|'\n", + "print ' | |'\n", + "print ' | |'\n", + "print ' | |'\n", + "print ' node_1 (2,0) node_1 (1,1) '" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**Classification error = 1/4 = 0.25**" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -183,13 +238,56 @@ "metadata": {}, "source": [ "\n", - "\n", "\n", "*Screenshot taken from [Coursera](https://www.coursera.org/learn/ml-classification/exam/NDTdJ/preventing-overfitting-in-decision-trees)*\n", "\n", "" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "** Answer **\n", + "- x2 has 1 zeros and 3 ones, so spliting by x2, we have the tree structure as follow" + ] + }, + { + "cell_type": "code", + "execution_count": 48, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " root (3, 1)\n", + " |---------------|----------------|\n", + " | |\n", + " | |\n", + " | |\n", + " node_1 (2,1) node_1 (1,0) \n" + ] + } + ], + "source": [ + "print ' %s' % 'root (3, 1)'\n", + "print ' |---------------|----------------|'\n", + "print ' | |'\n", + "print ' | |'\n", + "print ' | |'\n", + "print ' node_1 (2,1) node_1 (1,0) '" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**Classification error = 1/4 = 0.25**" + ] + }, { "cell_type": "markdown", "metadata": {}, diff --git a/machine_learning/3_classification/lecture/week4/images/lec4_quiz01_pic06-01.png b/machine_learning/3_classification/lecture/week4/images/lec4_quiz01_pic06-01.png deleted file mode 100644 index 54f1e36..0000000 Binary files a/machine_learning/3_classification/lecture/week4/images/lec4_quiz01_pic06-01.png and /dev/null differ diff --git a/machine_learning/3_classification/lecture/week4/images/lec4_quiz01_pic06.png b/machine_learning/3_classification/lecture/week4/images/lec4_quiz01_pic06.png index 59a9991..54f1e36 100644 Binary files a/machine_learning/3_classification/lecture/week4/images/lec4_quiz01_pic06.png and b/machine_learning/3_classification/lecture/week4/images/lec4_quiz01_pic06.png differ diff --git a/machine_learning/3_classification/lecture/week4/images/lec4_quiz01_pic07-01.png b/machine_learning/3_classification/lecture/week4/images/lec4_quiz01_pic07-01.png deleted file mode 100644 index 6a3c708..0000000 Binary files a/machine_learning/3_classification/lecture/week4/images/lec4_quiz01_pic07-01.png and /dev/null differ diff --git a/machine_learning/3_classification/lecture/week4/images/lec4_quiz01_pic07.png b/machine_learning/3_classification/lecture/week4/images/lec4_quiz01_pic07.png index 6834fce..5d6f85c 100644 Binary files a/machine_learning/3_classification/lecture/week4/images/lec4_quiz01_pic07.png and b/machine_learning/3_classification/lecture/week4/images/lec4_quiz01_pic07.png differ diff --git a/machine_learning/3_classification/lecture/week4/images/lec4_quiz01_pic08-01.png b/machine_learning/3_classification/lecture/week4/images/lec4_quiz01_pic08-01.png deleted file mode 100644 index e211a8d..0000000 Binary files a/machine_learning/3_classification/lecture/week4/images/lec4_quiz01_pic08-01.png and /dev/null differ diff --git a/machine_learning/3_classification/lecture/week4/images/lec4_quiz01_pic08.png b/machine_learning/3_classification/lecture/week4/images/lec4_quiz01_pic08.png index ef83dd1..d4a504b 100644 Binary files a/machine_learning/3_classification/lecture/week4/images/lec4_quiz01_pic08.png and b/machine_learning/3_classification/lecture/week4/images/lec4_quiz01_pic08.png differ diff --git a/machine_learning/3_classification/lecture/week4/images/lec4_quiz01_pic10-01.png b/machine_learning/3_classification/lecture/week4/images/lec4_quiz01_pic10-01.png deleted file mode 100644 index 51d5aed..0000000 Binary files a/machine_learning/3_classification/lecture/week4/images/lec4_quiz01_pic10-01.png and /dev/null differ diff --git a/machine_learning/3_classification/lecture/week4/images/lec4_quiz01_pic10.png b/machine_learning/3_classification/lecture/week4/images/lec4_quiz01_pic10.png index 315aa04..288deda 100644 Binary files a/machine_learning/3_classification/lecture/week4/images/lec4_quiz01_pic10.png and b/machine_learning/3_classification/lecture/week4/images/lec4_quiz01_pic10.png differ diff --git a/machine_learning/3_classification/lecture/week4/quiz-Preventing Overfitting in Decision Trees.ipynb b/machine_learning/3_classification/lecture/week4/quiz-Preventing Overfitting in Decision Trees.ipynb index 98d5aa4..249904c 100644 --- a/machine_learning/3_classification/lecture/week4/quiz-Preventing Overfitting in Decision Trees.ipynb +++ b/machine_learning/3_classification/lecture/week4/quiz-Preventing Overfitting in Decision Trees.ipynb @@ -127,7 +127,6 @@ "metadata": {}, "source": [ "\n", - "\n", "\n", "*Screenshot taken from [Coursera](https://www.coursera.org/learn/ml-classification/exam/NDTdJ/preventing-overfitting-in-decision-trees)*\n", "\n", @@ -146,13 +145,25 @@ "metadata": {}, "source": [ "\n", - "\n", "\n", "*Screenshot taken from [Coursera](https://www.coursera.org/learn/ml-classification/exam/NDTdJ/preventing-overfitting-in-decision-trees)*\n", "\n", "" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "** Answer **\n", + "\n", + "At this node, the y values have:\n", + "- 3 True (+1)\n", + "- 1 False (-1)\n", + "\n", + "The classification error is: 1/4 = 0.25" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -171,6 +182,50 @@ "" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "** Answer **\n", + "- x1 has 2 zeros and 2 ones, so spliting by x1, we have the tree structure as follow" + ] + }, + { + "cell_type": "code", + "execution_count": 47, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " root (3, 1)\n", + " |---------------|----------------|\n", + " | |\n", + " | |\n", + " | |\n", + " node_1 (2,0) node_1 (1,1) \n" + ] + } + ], + "source": [ + "print ' %s' % 'root (3, 1)'\n", + "print ' |---------------|----------------|'\n", + "print ' | |'\n", + "print ' | |'\n", + "print ' | |'\n", + "print ' node_1 (2,0) node_1 (1,1) '" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**Classification error = 1/4 = 0.25**" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -183,13 +238,56 @@ "metadata": {}, "source": [ "\n", - "\n", "\n", "*Screenshot taken from [Coursera](https://www.coursera.org/learn/ml-classification/exam/NDTdJ/preventing-overfitting-in-decision-trees)*\n", "\n", "" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "** Answer **\n", + "- x2 has 1 zeros and 3 ones, so spliting by x2, we have the tree structure as follow" + ] + }, + { + "cell_type": "code", + "execution_count": 48, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " root (3, 1)\n", + " |---------------|----------------|\n", + " | |\n", + " | |\n", + " | |\n", + " node_1 (2,1) node_1 (1,0) \n" + ] + } + ], + "source": [ + "print ' %s' % 'root (3, 1)'\n", + "print ' |---------------|----------------|'\n", + "print ' | |'\n", + "print ' | |'\n", + "print ' | |'\n", + "print ' node_1 (2,1) node_1 (1,0) '" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "**Classification error = 1/4 = 0.25**" + ] + }, { "cell_type": "markdown", "metadata": {},