{"id":2026,"date":"2018-02-22T13:51:48","date_gmt":"2018-02-22T08:21:48","guid":{"rendered":"http:\/\/stepbystepschools.net\/?p=2026"},"modified":"2018-02-22T13:51:48","modified_gmt":"2018-02-22T08:21:48","slug":"data-science-training-in-mumbai-decision-tree","status":"publish","type":"post","link":"https:\/\/www.stepbystepschools.net\/?p=2026","title":{"rendered":"Data Science Training in Mumbai :- Decision Tree."},"content":{"rendered":"<p>A Decision Tree is a decision support tool which is a graphical representation or a model of possible solutions to a decision based on certain condition.<\/p>\n<p>It is called a decision tree because it initially starts from a single box (or root), which then branches off into a number of solutions, just like branches on a tree.<\/p>\n<p>Decision trees are mainly used in operations research and more specifically in decision analysis.<\/p>\n<p>It helps us to identity and decide a strategy most likely to reach a goal also being a popular tool in machine learning.<\/p>\n<p><a href=\"http:\/\/stepbystepschools.net\/wp-content\/uploads\/2018\/02\/1-1.png\" rel=\"attachment wp-att-2027\"><img loading=\"lazy\" src=\"http:\/\/stepbystepschools.net\/wp-content\/uploads\/2018\/02\/1-1.png\" alt=\"1\" width=\"602\" height=\"332\" class=\"aligncenter size-full wp-image-2027\" srcset=\"https:\/\/www.stepbystepschools.net\/wp-content\/uploads\/2018\/02\/1-1.png 602w, https:\/\/www.stepbystepschools.net\/wp-content\/uploads\/2018\/02\/1-1-300x165.png 300w\" sizes=\"(max-width: 602px) 100vw, 602px\" \/><\/a><\/p>\n<p>In the following demonstration we will use R programming to perform this test<\/p>\n<p><b>Initial Environment Setup<\/b><\/p>\n<p>But before we get into creating a program let\u2019s just first set up a proper environment for R programming.<\/p>\n<p>To install R programming tool go to the following link and download the software and install it.<\/p>\n<p>For Windows Users:<br \/>\n<a target=\"_blank\" href=\"https:\/\/ftp.iitm.ac.in\/cran\/\">https:\/\/ftp.iitm.ac.in\/cran\/<\/a>\n<\/p>\n<p><a href=\"http:\/\/stepbystepschools.net\/wp-content\/uploads\/2018\/02\/2-1.png\" rel=\"attachment wp-att-2028\"><img loading=\"lazy\" src=\"http:\/\/stepbystepschools.net\/wp-content\/uploads\/2018\/02\/2-1.png\" alt=\"2\" width=\"602\" height=\"118\" class=\"aligncenter size-full wp-image-2028\" srcset=\"https:\/\/www.stepbystepschools.net\/wp-content\/uploads\/2018\/02\/2-1.png 602w, https:\/\/www.stepbystepschools.net\/wp-content\/uploads\/2018\/02\/2-1-300x59.png 300w\" sizes=\"(max-width: 602px) 100vw, 602px\" \/><\/a><\/p>\n<p>And Type and Run the following code RGui<br \/>\n<span style=\"background-color: #C0C0C0\">install.packages(&#8220;ggplot2&#8221;)<br \/>\n<\/span><span style=\"background-color: #C0C0C0\">install.packages(&#8220;party&#8221;)<\/span><\/p>\n<p>For Linux Users:<\/p>\n<p>If you are on Linux platform then you can use this fast and easy command used in Linux which can be used to install R. The yum command is used for installing like this:<br \/>\n<span style=\"background-color: #C0C0C0\">$ yum install R<\/span><\/p>\n<p>For Ubuntu Linux or other Debian-related OSs, a more direct method is:<br \/>\n<span style=\"background-color: #C0C0C0\">$ apt-get install r-base<\/span><\/p>\n<p>R has a package called <span style=\"background-color: #C0C0C0\">&#8220;party&#8221;<\/span> has the function ctree() which is used to create and analyse decision tree.<\/p>\n<p>The most important syntax for creating decision tree is as follows<br \/>\n<span style=\"background-color: #C0C0C0\">ctree(formula, data)<\/span><\/p>\n<p>Where Formula is used to describe the predictor and response variables it has to offer while data represents the name of the dataset used.<\/p>\n<p>We can use the R in-built data set named<br \/>\n<span style=\"background-color: #C0C0C0\">readingSkills<\/span> which we will use to create a decision tree.<\/p>\n<p>The Data describes the score of someone&#8217;s<br \/>\n<span style=\"background-color: #C0C0C0\">readingSkills<\/span> if we know the variables<br \/>\n<span style=\"background-color: #C0C0C0\">&#8220;age&#8221;,&#8221;shoesize&#8221;,&#8221;score&#8221;<\/span> also whether the person is a native speaker of the language or not.<\/p>\n<p>Let\u2019s start coding in RGui<\/p>\n<p># Load the party package. It will automatically load other dependent packages.<br \/>\n<span style=\"background-color: #C0C0C0\">library(party)<\/span><\/p>\n<p># Print some records from data set readingSkills.<br \/>\n<span style=\"background-color: #C0C0C0\">print(head(readingSkills))<\/span><\/p>\n<p>The data in our dataframe readingSkills is read using the above command and printed on the console as shown below:<\/p>\n<p><a href=\"http:\/\/stepbystepschools.net\/wp-content\/uploads\/2018\/02\/3-1.png\" rel=\"attachment wp-att-2029\"><img loading=\"lazy\" src=\"http:\/\/stepbystepschools.net\/wp-content\/uploads\/2018\/02\/3-1.png\" alt=\"3\" width=\"586\" height=\"220\" class=\"aligncenter size-full wp-image-2029\" srcset=\"https:\/\/www.stepbystepschools.net\/wp-content\/uploads\/2018\/02\/3-1.png 586w, https:\/\/www.stepbystepschools.net\/wp-content\/uploads\/2018\/02\/3-1-300x113.png 300w\" sizes=\"(max-width: 586px) 100vw, 586px\" \/><\/a><\/p>\n<p>Using ctree() to generate a decision tree we have include in the code below<\/p>\n<p># Load the party package. It will automatically load other dependent packages<br \/>\n<span style=\"background-color: #C0C0C0\">library(party)<\/span>\n<\/p>\n<p># Create the input data frame.<br \/>\n<span style=\"background-color: #C0C0C0\">input.dat <- readingSkills[c(1:105),]<\/span>\n<\/p>\n<p><span style=\"background-color: #C0C0C0\">print(input.dat)<\/span><\/p>\n<p># Create the tree.<br \/>\n<span style=\"background-color: #C0C0C0\">output.tree <- ctree(<br \/>\n<\/span><span style=\"background-color: #C0C0C0\">nativeSpeaker ~ age + shoeSize + score,<br \/>\ndata = input.dat)<\/span><\/p>\n<p># Plot the tree.<br \/>\n<span style=\"background-color: #C0C0C0\">plot(output.tree)<\/span>\n<\/p>\n<p># Give the chart file a name.<br \/>\n<span style=\"background-color: #C0C0C0\">png(file = &#8220;decision_tree.png&#8221;)<\/span>\n<\/p>\n<p># Save the file.<br \/>\n<span style=\"background-color: #C0C0C0\">dev.off()<br \/>\n<\/span>\n<\/p>\n<p>On executing the code we get the following Output:<\/p>\n<p><a href=\"http:\/\/stepbystepschools.net\/wp-content\/uploads\/2018\/02\/4-1.png\" rel=\"attachment wp-att-2030\"><img loading=\"lazy\" src=\"http:\/\/stepbystepschools.net\/wp-content\/uploads\/2018\/02\/4-1.png\" alt=\"4\" width=\"544\" height=\"539\" class=\"aligncenter size-full wp-image-2030\" srcset=\"https:\/\/www.stepbystepschools.net\/wp-content\/uploads\/2018\/02\/4-1.png 544w, https:\/\/www.stepbystepschools.net\/wp-content\/uploads\/2018\/02\/4-1-150x150.png 150w, https:\/\/www.stepbystepschools.net\/wp-content\/uploads\/2018\/02\/4-1-300x297.png 300w\" sizes=\"(max-width: 544px) 100vw, 544px\" \/><\/a><\/p>\n<p>From the above chart of decision tree we can conclude that anyone whose reading skills are less than 38.306 and age more than 6 is not a native speaker of the language.<\/p>\n<p><a target=\"_blank\" href=\"http:\/\/stepbystepschools.net\/?page_id=1842\">Syllabus of Data Science training in Mumbai<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A Decision Tree is a decision support tool which is a graphical representation or a model of possible solutions to a decision based on certain condition. It is called a decision tree because it initially starts from a single box &hellip; <a href=\"https:\/\/www.stepbystepschools.net\/?p=2026\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":40,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[1],"tags":[198,199,206,202],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v18.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Data Science Training in Mumbai :- Decision Tree. - Learn MVC, Angular, Architecture, MSBI, Data Science in Mumbai<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.stepbystepschools.net\/?p=2026\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Data Science Training in Mumbai :- Decision Tree. - Learn MVC, Angular, Architecture, MSBI, Data Science in Mumbai\" \/>\n<meta property=\"og:description\" content=\"A Decision Tree is a decision support tool which is a graphical representation or a model of possible solutions to a decision based on certain condition. It is called a decision tree because it initially starts from a single box &hellip; Continue reading &rarr;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.stepbystepschools.net\/?p=2026\" \/>\n<meta property=\"og:site_name\" content=\"Learn MVC, Angular, Architecture, MSBI, Data Science in Mumbai\" \/>\n<meta property=\"article:published_time\" content=\"2018-02-22T08:21:48+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/stepbystepschools.net\/wp-content\/uploads\/2018\/02\/1-1.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"StepByStepSchoolsSupport\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.stepbystepschools.net\/#website\",\"url\":\"https:\/\/www.stepbystepschools.net\/\",\"name\":\"Learn MVC, Angular, Architecture, MSBI, Data Science in Mumbai\",\"description\":\"MVC 5\/Core, AngularJS 1.x, 2.0, 4.0, Design Pattern, Architecture, SSIS, SSAS, SSRS, Data Science, Big data, Hadoop classroom training\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.stepbystepschools.net\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.stepbystepschools.net\/?p=2026#primaryimage\",\"url\":\"http:\/\/stepbystepschools.net\/wp-content\/uploads\/2018\/02\/1-1.png\",\"contentUrl\":\"http:\/\/stepbystepschools.net\/wp-content\/uploads\/2018\/02\/1-1.png\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.stepbystepschools.net\/?p=2026#webpage\",\"url\":\"https:\/\/www.stepbystepschools.net\/?p=2026\",\"name\":\"Data Science Training in Mumbai :- Decision Tree. - Learn MVC, Angular, Architecture, MSBI, Data Science in Mumbai\",\"isPartOf\":{\"@id\":\"https:\/\/www.stepbystepschools.net\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.stepbystepschools.net\/?p=2026#primaryimage\"},\"datePublished\":\"2018-02-22T08:21:48+00:00\",\"dateModified\":\"2018-02-22T08:21:48+00:00\",\"author\":{\"@id\":\"https:\/\/www.stepbystepschools.net\/#\/schema\/person\/7131e4ee1c5673879e6029d14ec2f655\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.stepbystepschools.net\/?p=2026#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.stepbystepschools.net\/?p=2026\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.stepbystepschools.net\/?p=2026#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.stepbystepschools.net\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Data Science Training in Mumbai :- Decision Tree.\"}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.stepbystepschools.net\/#\/schema\/person\/7131e4ee1c5673879e6029d14ec2f655\",\"name\":\"StepByStepSchoolsSupport\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.stepbystepschools.net\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/cecaf2a0ee369391127b0159c266979d?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/cecaf2a0ee369391127b0159c266979d?s=96&d=mm&r=g\",\"caption\":\"StepByStepSchoolsSupport\"},\"url\":\"https:\/\/www.stepbystepschools.net\/?author=40\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Data Science Training in Mumbai :- Decision Tree. - Learn MVC, Angular, Architecture, MSBI, Data Science in Mumbai","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.stepbystepschools.net\/?p=2026","og_locale":"en_US","og_type":"article","og_title":"Data Science Training in Mumbai :- Decision Tree. - Learn MVC, Angular, Architecture, MSBI, Data Science in Mumbai","og_description":"A Decision Tree is a decision support tool which is a graphical representation or a model of possible solutions to a decision based on certain condition. It is called a decision tree because it initially starts from a single box &hellip; Continue reading &rarr;","og_url":"https:\/\/www.stepbystepschools.net\/?p=2026","og_site_name":"Learn MVC, Angular, Architecture, MSBI, Data Science in Mumbai","article_published_time":"2018-02-22T08:21:48+00:00","og_image":[{"url":"http:\/\/stepbystepschools.net\/wp-content\/uploads\/2018\/02\/1-1.png"}],"twitter_card":"summary_large_image","twitter_misc":{"Written by":"StepByStepSchoolsSupport","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebSite","@id":"https:\/\/www.stepbystepschools.net\/#website","url":"https:\/\/www.stepbystepschools.net\/","name":"Learn MVC, Angular, Architecture, MSBI, Data Science in Mumbai","description":"MVC 5\/Core, AngularJS 1.x, 2.0, 4.0, Design Pattern, Architecture, SSIS, SSAS, SSRS, Data Science, Big data, Hadoop classroom training","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.stepbystepschools.net\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.stepbystepschools.net\/?p=2026#primaryimage","url":"http:\/\/stepbystepschools.net\/wp-content\/uploads\/2018\/02\/1-1.png","contentUrl":"http:\/\/stepbystepschools.net\/wp-content\/uploads\/2018\/02\/1-1.png"},{"@type":"WebPage","@id":"https:\/\/www.stepbystepschools.net\/?p=2026#webpage","url":"https:\/\/www.stepbystepschools.net\/?p=2026","name":"Data Science Training in Mumbai :- Decision Tree. - Learn MVC, Angular, Architecture, MSBI, Data Science in Mumbai","isPartOf":{"@id":"https:\/\/www.stepbystepschools.net\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.stepbystepschools.net\/?p=2026#primaryimage"},"datePublished":"2018-02-22T08:21:48+00:00","dateModified":"2018-02-22T08:21:48+00:00","author":{"@id":"https:\/\/www.stepbystepschools.net\/#\/schema\/person\/7131e4ee1c5673879e6029d14ec2f655"},"breadcrumb":{"@id":"https:\/\/www.stepbystepschools.net\/?p=2026#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.stepbystepschools.net\/?p=2026"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.stepbystepschools.net\/?p=2026#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.stepbystepschools.net\/"},{"@type":"ListItem","position":2,"name":"Data Science Training in Mumbai :- Decision Tree."}]},{"@type":"Person","@id":"https:\/\/www.stepbystepschools.net\/#\/schema\/person\/7131e4ee1c5673879e6029d14ec2f655","name":"StepByStepSchoolsSupport","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.stepbystepschools.net\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/cecaf2a0ee369391127b0159c266979d?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cecaf2a0ee369391127b0159c266979d?s=96&d=mm&r=g","caption":"StepByStepSchoolsSupport"},"url":"https:\/\/www.stepbystepschools.net\/?author=40"}]}},"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"_links":{"self":[{"href":"https:\/\/www.stepbystepschools.net\/index.php?rest_route=\/wp\/v2\/posts\/2026"}],"collection":[{"href":"https:\/\/www.stepbystepschools.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.stepbystepschools.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.stepbystepschools.net\/index.php?rest_route=\/wp\/v2\/users\/40"}],"replies":[{"embeddable":true,"href":"https:\/\/www.stepbystepschools.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2026"}],"version-history":[{"count":2,"href":"https:\/\/www.stepbystepschools.net\/index.php?rest_route=\/wp\/v2\/posts\/2026\/revisions"}],"predecessor-version":[{"id":2032,"href":"https:\/\/www.stepbystepschools.net\/index.php?rest_route=\/wp\/v2\/posts\/2026\/revisions\/2032"}],"wp:attachment":[{"href":"https:\/\/www.stepbystepschools.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2026"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.stepbystepschools.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2026"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.stepbystepschools.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2026"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}