From 993dfff0aa90d95b249890dd786b5729517471c0 Mon Sep 17 00:00:00 2001 From: Dan Mikus Date: Sun, 10 Dec 2017 15:09:33 -0500 Subject: [PATCH] Updated Decision_Tree_Image function by removing tree_ attribute from tree instance --- ...ion, and tree-structured models 2017.ipynb | 60 ++++++------------- 1 file changed, 18 insertions(+), 42 deletions(-) diff --git a/Module2_Supervised/ Correlation, supervised segmentation, and tree-structured models 2017.ipynb b/Module2_Supervised/ Correlation, supervised segmentation, and tree-structured models 2017.ipynb index 83c36cc..0cfa142 100644 --- a/Module2_Supervised/ Correlation, supervised segmentation, and tree-structured models 2017.ipynb +++ b/Module2_Supervised/ Correlation, supervised segmentation, and tree-structured models 2017.ipynb @@ -32,9 +32,7 @@ { "cell_type": "code", "execution_count": 2, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "# Import the libraries we will be using\n", @@ -73,9 +71,7 @@ { "cell_type": "code", "execution_count": 3, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "\n", @@ -84,7 +80,7 @@ "def Decision_Tree_Image(decision_tree, feature_names, name=\"temp\"):\n", " \n", " # Export our decision tree to graphviz format\n", - " dot_file = tree.export_graphviz(decision_tree.tree_, out_file='images/' + name + '.dot', feature_names=feature_names)\n", + " dot_file = tree.export_graphviz(decision_tree, out_file='images/' + name + '.dot', feature_names=feature_names)\n", " \n", " # Call graphviz to make an image file from our decision tree\n", " os.system(\"dot -T png images/\" + name + \".dot -o images/\" + name + \".png\")\n", @@ -156,9 +152,7 @@ { "cell_type": "code", "execution_count": 4, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "# Set the randomness\n", @@ -207,9 +201,7 @@ { "cell_type": "code", "execution_count": 5, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -276,9 +268,7 @@ { "cell_type": "code", "execution_count": 6, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -323,7 +313,6 @@ "cell_type": "code", "execution_count": 7, "metadata": { - "collapsed": false, "scrolled": true }, "outputs": [ @@ -392,9 +381,7 @@ { "cell_type": "code", "execution_count": 8, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "\n", @@ -440,9 +427,7 @@ { "cell_type": "code", "execution_count": 9, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -469,7 +454,6 @@ "cell_type": "code", "execution_count": 10, "metadata": { - "collapsed": false, "scrolled": true }, "outputs": [ @@ -515,9 +499,7 @@ { "cell_type": "code", "execution_count": 11, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -538,9 +520,7 @@ { "cell_type": "code", "execution_count": 12, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [ { "data": { @@ -578,9 +558,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "Decision_Surface(X,Y,decision_tree)" @@ -589,9 +567,7 @@ { "cell_type": "code", "execution_count": null, - "metadata": { - "collapsed": false - }, + "metadata": {}, "outputs": [], "source": [ "print ( \"Accuracy = %.3f\" % (metrics.accuracy_score(decision_tree.predict(X), Y)) )" @@ -609,23 +585,23 @@ ], "metadata": { "kernelspec": { - "display_name": "Python 2", + "display_name": "Python 3", "language": "python", - "name": "python2" + "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", - "version": 2 + "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", - "pygments_lexer": "ipython2", - "version": "2.7.13" + "pygments_lexer": "ipython3", + "version": "3.6.1" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 }