Coder Social home page Coder Social logo

ml_assignment_3_decision-trees-'s Introduction

Task 3 (Decision Trees )

1. Loading the data and did some preprocessing on it such as assuming categories for continous data and filling the missing data or adjusting the outliers

Then the data looks finally like :

alt text

2.Training and test split to 90/10

3.Started defining function:

Gini_impurity :

takes lable and label index, it counts how many unique values in the target and each unique value counts

information_gain: Calculates info gain from the following formula:

alt text

SplitDataSet:

Splitting data according to a value

find_best_split:

for each feature it takes the values and split it then calculate varience to get best feature and best value

Count:

to get unique values and its count

Leaf ,Decision_Note :

Two classes to help building and printing the tree which i got from :

Github

build_tree:

Using all the previous functions to finaly build a tree and use a recursive method to repeat for each branch

Predict:

first it checks if we are at the leaf node then it keeps asking where is the new test data recursively .

Accuracy:

It measure the matches between predicted values and true values over the length of the data.

Finally i tried sklearn code to compare both codes.

Results :

alt text
alt text

ml_assignment_3_decision-trees-'s People

Contributors

marwaomar avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.