Machine Learning with Python – Decision Tree
Machine Learning - Decision Tree

Machine Learning with Python – Decision Tree

?Machine learning is a branch of Artificial Intelligence.

?An Early Example of Machine Learning is …

?..Deep Blue; it was a software designed to play chess game, but that’s all it could do.

?Evolution of Machine Learning

?Some questions sounds quite easy but we can’t answer them by writing a programme, like “what is the difference between apple and orange?” for these types of questions, machine learning is the best.

?How machine learning answers these questions is by identifying features for e.g. weight of apple and orange, size etc..

Types Of Classifiers

?Artificial Neural network

?Support Vector Machine

?Linear Classifiers: Logistic Regression, Na?ve Bayes Classifier

?Random Forest

?Boosted Trees

?Decision Tree etc.

But we are using decision trees first because it is easy to understand.

?Machine Learning with Decision Tree Classifier can have number of applications;

?For example identifying if the image is black or white etc.

How it Works!

?Classifier takes some input and then assigns to it an output.

?In our example we are defining two features and a label.

?The data contains the weight and texture (features) for the label apple or orange.

?Labels is the last columns that contains the fruit name.

?If there is apple we take 0 and if orange then 1 similarly if the shape is smooth it means its apple and so we assign 1 and if bumpy then we assign 0.

Recipe for Supervised Learning Model

Training Data

Decision Tree

?In scikit the training algorithm is included in the classifier object, and it is called fit.

?We can think of Fit as synonym for “Find pattern in data”.

Working Program

?Now we are asking our short machine learning program to predict, we will be providing features and it will be outputting labels.

?Feature we defined is “(150, 0)”, Remember, 0 represents bumpy and 1 represents smooth, so our arguments define that the weight for the label is 150 and the shape is 0 i.e. bumpy.

?We think that the output should be Orange, and binary representation for this is ‘1’. Lets see what our program outputs.

Program Output

?The output is 1, that means our program now predicts well.

Another Example

A bit more complex example is "Iris" data set that is about 3 types of flowers "Setosa, Versicolor and verginicia".

Goal for this dataset:

?Import dataset

?Train a classifier

?Predict label for new flower

?Visualize the tree

The process of importing, training and predicting would remain same as discussed above.

Decision Tree Diagram

You can also print decision tree diagram of the model for any given data set. This is the decision tree diagram for Iris data set.

Hope Now You Have Improved Understanding of Decision Tree :)

May you have any queries, feel free to contact us. https://www.custech2.com/

Thank You

Prepared by: Kumail Raza and Hadi Rajani (BI and Business Analytics Practitioners)


要查看或添加评论,请登录

Kumail Raza的更多文章

  • Star Schema Model - Transforming 2 Fact Tables to Star Schema Data Model

    Star Schema Model - Transforming 2 Fact Tables to Star Schema Data Model

    Problems 2 fact table and corresponding dimension tables associated separately to dimension table. The problem is when…

  • MS Power BI Time Intelligence

    MS Power BI Time Intelligence

    In this brief article I will be talking about 3-time intelligence components in MS Power BI. · Auto Time Intelligence ·…

    1 条评论
  • Datawarehouse Schema Models

    Datawarehouse Schema Models

    Star Schema: The star schema architecture is the simplest data warehouse schema. It is called a star schema because the…

  • Data warehouse Components & Selection Strategies

    Data warehouse Components & Selection Strategies

    Data Warehouse Database The central database is the foundation of the data warehousing environment. This database is…

  • Data Warehouse Concepts And Architecture

    Data Warehouse Concepts And Architecture

    What is Data Warehousing? Data warehousing is the process of constructing and using a data warehouse. A data warehouse…

  • POWER BI DESKTOP - DATA TRANSFORMATION FEATURES

    POWER BI DESKTOP - DATA TRANSFORMATION FEATURES

    Purpose of this document The purpose of the Power BI Data-Transformation document is to elaborate details of get data…

    1 条评论

社区洞察

其他会员也浏览了