Skip to content Skip to sidebar Skip to footer

Draw Decision Tree for Problems in Machine Tools

  • Learn how to build a decision tree diagram model using Weka
  • This tutorial is perfect for newcomers to machine learning and decision trees, and those folks WHO are not homely with coding

Introduction

"The greater the obstacle, the more glory in overcoming IT."

– Moliere

Machine learning send away be intimidating for folk coming from a non-technical background. All simple machine learning jobs seem to require a hale understanding of Python (or R).

And then how DO not-programmers gain secret writing experience? It's not a cakewalk!

Here's the good news – thither are plenty of tools out there that let the States do machine learning tasks without having to code. You fundament easily build algorithms alike conclusion trees from scratch in a beautiful graphical interface. Isn't that the dreaming? These tools, such as Weka, help oneself us chiefly deal with two things:

  • Speedily build a machine learning model, like a decision tree, and understand how the algorithm is performing. This can later be modified and built upon
  • This is ideal for showing the client/your leadership team what you'atomic number 75 working with

This article will show you how to solve classification and regression problems exploitation Decision Trees in Weka without any preceding computer programming knowledge!

But if you are passionate about getting your hands dirty with programming and machine learning, I suggest going through the following wonderfully curated courses:

  • Python for Information Science
  • Applied Machine Learning

Table of Table of contents

  • Classification vs. Regression in Machine Learning
  • Understanding Decision Trees
  • Exploring the Dataset in Weka
  • Compartmentalisation using Conclusion Tree in Weka
  • Decisiveness Tree diagram Parameters in Maori hen
  • Visualizing a Decisiveness Tree in Weka
  • Regression using Conclusion Tree in Weka

Classification vs. Regression in Machine Learning

Let ME initiative quickly summarize what classification and regression are in the context of machine learning. It's important to recognize these concepts before you dive into decision trees.

A classification problem is all but teaching your machine learning model how to categorize a data apprais into one of many classes. Information technology does this away learning the characteristics of each type of class. For example, to predict whether an image is of a cat or dog, the model learns the characteristics of the dog and barf on training information.

A regression problem is about teaching your auto erudition model how to prognosticate the future valuate of a continuous quantity. It does this away learning the pattern of the quantity in the past affected by different variables. For illustration, a model trying to predict the future apportion price of a company is a simple regression problem.

You buttocks find both these problems in abundance on our DataHack political platform.

Now, let's learn about an algorithmic rule that solves both problems – decision trees!

Reason Determination Trees

Decision trees are as wel known as Classification And Regression Trees (CART) . They work by learning answers to a hierarchy of if/else questions leading to a determination. These questions build a tree-like structure, and hence the name.

For example, have's say we lack to foreshadow whether a person will order food Beaver State not. We can visualize the following decisiveness tree for this:

Decision tree example

Each node in the Sir Herbert Beerbohm Tree represents a question derived from the features present in your dataset. Your dataset is split based on these questions until the upper limit depth of the tree is reached. The last node does non ask out a question but represents which class the value belongs to.

  • The topmost node in the Decision tree is called the R oot node
  • The bottom-most node is called the L eaf thickening
  • A node sectional into sub-nodes is named a Parent node. The sub-nodes are called Child nodes

If you want to understand decision trees in detail, I suggest leaving through the below resources:

  • Getting Started with Decision Trees (Free Course)
  • Tree-Based Algorithms: A Complete Tutorial from Scrub

What is Wood hen? Why Should You Use Weka for Machine Learning?

" Weka is a unloose open-source software with a stray of built-in machine encyclopedism algorithms that you can access through a GUI! "

WEKA stands for Waikato Environment for Cognition Psychoanalysis and was developed at the University of Waikato, New Zealand.

Weka has triplex built-in functions for implementing a wide range of machine learning algorithms from linear regression to neural net. This allows you to deploy the most complex of algorithms happening your dataset at just a sink in of a button! Not only this, Weka gives support for accessing some of the most democratic machine learning library algorithms of Python and R!

With Weka you can preprocess the information, relegate the data, cluster the data and even visualise the information! This you can do on contrasting formats of data files like-minded ARFF, CSV, C4.5, and JSON. Wood hen even allows you to impart filters to your dataset through which you can normalize your data, standardize it, tack features betwixt nominal and numeric values, and what not!

I could go on about the wonder that is Wood hen, but for the scope of this article let's try and explore Weka practically by creating a Decision tree. Now go out front and download Weka from their official internet site!

weka logo

Exploring the Dataset in Weka

I will take the Breast Cancer dataset from the UCI Machine Encyclopedism Repository. I recommend you record about the problem before moving forward.

Weka GUI

Let us premier load the dataset in Weka. To do that, follow the to a lower place stairs:

  1. Open Weka GUI
  2. Select the "Explorer" option.
  3. Pick out "Undecided file" and choose your dataset.

Your Weka window should now calculate like this:

Dataset exploration in Weka

You can view all the features in your dataset on the left-hand side. Weka mechanically creates plots for your features which you will acknowledge as you navigate through your features.

You can even view complete the plots together if you click on the "Visualize Complete" button.

Visualising all features in Weka

Now let's train our compartmentalization model!

Classification using Decision Tree in Weka

Implementing a decision corner in Weka is pretty straightforward. Just complete the favourable steps:

  1. Clack on the "Classify" tabloid on the top
  2. Click the "Choose" button
  3. From the neglect-retired list, select "trees" which will open complete the tree algorithms
  4. Last, select the "RepTree" decision tree

" Reduced Error Pruning Tree (RepTree) is a fast decision tree learner that builds a determination/regression tree using information pull in equally the splitting measure, and prunes it exploitation reduced fault pruning algorithm."

You can read about the slashed error pruning technique in this research wallpaper.

RepTree Decision tree in Weka

"Decision tree splits the nodes connected all available variables so selects the cut which results in the most homogeneous U-boat-nodes."

Info Gain is used to calculate the homogeneity of the sample at a split.

You can select your prey feature article from the drop-down just above the "Take off" button. If you Don River't behave that, Maori hen automatically selects the last feature article as the target for you.

The "Per centum split" specifies how much of your information you want to celebrate for training the classifier. The perch of the data is used during the testing phase angle to calculate the accuracy of the role model.

With "Cross-validation Fold" you rump make over ternary samples (Oregon folds) from the training dataset. If you decide to create N folds, then the role model is iteratively run N times. And each time one of the folds is held hindmost for validation while the remaining N-1 folds are in use for breeding the pose. The resolution of all the folds is averaged to break the result of cross-validation.

The greater the count of cross-substantiation folds you economic consumption, the better your model will become. This makes the simulation train on at random selected data which makes it more robust.

Finally, press the "Bulge" button for the classifier to do its magic!

RepTree Decision tree result

Our classifier has got an accuracy of 92.4%. Weka even prints the Mental confusion matrix for you which gives different metrics. You can study about Confusion matrix and other metrics in detail Here.

Decision Tree Parameters in Maori hen

Decision trees have a lot of parameters. We can tune these to ameliorate our model's overall functioning. This is where a workings knowledge of decision trees really plays a crucial character.

You can approach these parameters by clicking on your decision tree algorithmic rule on top:

RepTree Decision tree parameters

Countenance's briefly talk about the main parameters:

  • maxDepth ­– It determines the utmost depth of your decision tree. By default, it is -1 which means the algorithmic rule bequeath automatically control the deepness. But you potty manually tweak this value to overcome results on your data
  • noPruning – Pruning means to mechanically cut dorsum on a leaf node that does not contain much information. This keeps the decisiveness corner simple and easy to construe with
  • numFolds – The specified number of folds of information will be used for pruning the decision shoetree. The rest will be used for flourishing the rules
  • minNum – Minimum number of instances per leafage. If not mentioned, the tree volition keep splitting public treasury all leaf nodes have only one class joint with information technology

You fanny always experiment with different values for these parameters to let the best truth on your dataset.

Visualizing your Decision Sir Herbert Beerbohm Tree in Weka

Weka flatbottom allows you to easily picture the decision tree built on your dataset:

  1. Conk out to the "Result list" section and right-dog on your housebroken algorithmic rule
  2. Opt the "Visualise shoetree" option

Visualizing Decision Tree in Weka

Your decision tree will look look-alike at a lower place:

Decision tree visualisation

Rendition these values can be a bite intimidating but it's actually bad easy once you master of it.

  • The values on the lines joining nodes represent the splitting criteria based along the values in the bring up node feature
  • In the leaf node:
    • The value before the parenthesis denotes the classification value
    • The first assess in the first aside is the number number of instances from the preparation kick in that leaf. The second value is the figure of instances wrongly classified in that folio
    • The first value in the second parenthesis is the total number of instances from the pruning set in that leaf. The second base value is the enumerate of instances falsely classified in that leaf

Regression victimization Decision Sir Herbert Beerbohm Tree in Weka

Like I said earlier, Decisiveness trees are so skilled that they can work on compartmentalization as asymptomatic as on regression toward the mean problems. For this, I will use the "Prefigure the issue of upvotes" problem from Analytics Vidhya's DataHack platform.

Hither, we need to predict the rating of a question asked by a exploiter on a question and answer platform.

American Samoa regular, we'll protrude by loading the data file. But this time, the data besides contains an "ID" column for each substance abuser in the dataset. This would not be useful in the prognostication. And then, we testament remove this tower by selecting the "Remove" selection underneath the column name calling:

Regression dataset in Weka

We can make predictions connected the dataset Eastern Samoa we did for the Breast Cancer trouble. RepTree will automatically detect the regression job:

Regression result in Weka

The evaluation metric provided in the hackathon is the RMSE score. We can imag that the model has a very poor RMSE without any feature engineering. This is where you interpose – plow ahead, try out and boost the final manakin!

End Notes

And just like that, you get created a Decision tree model without having to do any programming! This will go a long path in your quest to master copy the working of machine learning models.

If you want to memorise and search the programming part of motorcar learning, I highly suggest going through these wondrous curated courses connected the Analytics Vidhya website:

  • Python for Data Science
  • A comprehensive Learning path to becoming a data scientist in 2022
  • Getting started with Decision Trees

Draw Decision Tree for Problems in Machine Tools

Source: https://www.analyticsvidhya.com/blog/2020/03/decision-tree-weka-no-coding/

Post a Comment for "Draw Decision Tree for Problems in Machine Tools"