Skip to content

Commit

Permalink
Preventing Overfitting in Decision Trees
Browse files Browse the repository at this point in the history
  • Loading branch information
tuanavu committed Mar 20, 2016
1 parent 05a465c commit b584359
Show file tree
Hide file tree
Showing 10 changed files with 202 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@
"metadata": {},
"source": [
"<img src=\"images/lec4_quiz01_pic07.png\">\n",
"<img src=\"images/lec4_quiz01_pic07-01.png\">\n",
"\n",
"*Screenshot taken from [Coursera](https://www.coursera.org/learn/ml-classification/exam/NDTdJ/preventing-overfitting-in-decision-trees)*\n",
"\n",
Expand All @@ -146,13 +145,25 @@
"metadata": {},
"source": [
"<img src=\"images/lec4_quiz01_pic08.png\">\n",
"<img src=\"images/lec4_quiz01_pic08-01.png\">\n",
"\n",
"*Screenshot taken from [Coursera](https://www.coursera.org/learn/ml-classification/exam/NDTdJ/preventing-overfitting-in-decision-trees)*\n",
"\n",
"<!--TEASER_END-->"
]
},
{
"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": {},
Expand All @@ -171,6 +182,50 @@
"<!--TEASER_END-->"
]
},
{
"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": {},
Expand All @@ -183,13 +238,56 @@
"metadata": {},
"source": [
"<img src=\"images/lec4_quiz01_pic10.png\">\n",
"<img src=\"images/lec4_quiz01_pic10-01.png\">\n",
"\n",
"*Screenshot taken from [Coursera](https://www.coursera.org/learn/ml-classification/exam/NDTdJ/preventing-overfitting-in-decision-trees)*\n",
"\n",
"<!--TEASER_END-->"
]
},
{
"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": {},
Expand Down
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@
"metadata": {},
"source": [
"<img src=\"images/lec4_quiz01_pic07.png\">\n",
"<img src=\"images/lec4_quiz01_pic07-01.png\">\n",
"\n",
"*Screenshot taken from [Coursera](https://www.coursera.org/learn/ml-classification/exam/NDTdJ/preventing-overfitting-in-decision-trees)*\n",
"\n",
Expand All @@ -146,13 +145,25 @@
"metadata": {},
"source": [
"<img src=\"images/lec4_quiz01_pic08.png\">\n",
"<img src=\"images/lec4_quiz01_pic08-01.png\">\n",
"\n",
"*Screenshot taken from [Coursera](https://www.coursera.org/learn/ml-classification/exam/NDTdJ/preventing-overfitting-in-decision-trees)*\n",
"\n",
"<!--TEASER_END-->"
]
},
{
"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": {},
Expand All @@ -171,6 +182,50 @@
"<!--TEASER_END-->"
]
},
{
"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": {},
Expand All @@ -183,13 +238,56 @@
"metadata": {},
"source": [
"<img src=\"images/lec4_quiz01_pic10.png\">\n",
"<img src=\"images/lec4_quiz01_pic10-01.png\">\n",
"\n",
"*Screenshot taken from [Coursera](https://www.coursera.org/learn/ml-classification/exam/NDTdJ/preventing-overfitting-in-decision-trees)*\n",
"\n",
"<!--TEASER_END-->"
]
},
{
"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": {},
Expand Down

0 comments on commit b584359

Please sign in to comment.