Giter VIP home page Giter VIP logo

decisiontreelearning's Introduction

Decision Tree Learning Algorithm

Implementation of the ID3 Algorithm in Java

Getting Started

I implemented the algorithm as follows;

  • Calculate the entropy of every attribute in the set
    • Find the best attribute by using information gain and split into subsets accordingly
    • Create a decision tree node containing the attribute
    • Recurse on each subset with the remaining attributes

My main methods include;

  • buildTree – which recursively builds the decision tree. Checks to see if data is pure if so returns corresponding classification, if not then finds best attribute to split on and call buildTree on each subset.

  • findBestAttribute – takes the set and an int array of used attributes and calculates the entropy and information gain for each attribute then returns the attribute with the highest information gain.

  • calculateEntropy – calculates the entropy of a given set.

  • calculateGain – calculate gain of a given attribute.

  • getSubset – helper method to split the original set into subsets.

  • checkIfPure – another helper method to go through the set and see if all have the same classification

  • mostCommon – goes through the set and returns the most common classification

To allow for any number of classes I used the private class attributes wherever possible.

Further Improvements;

  • If I had more time I would have liked to implement pruning to allow for better efficiency.

Prerequistes

Java IDE e.g. Netbeans, Eclipse or IntelliJ

Installing

Download this repo to your local computer and load up using the Java IDE.

Contributing

Feel free to contribute by submitting pull requests.

License

This project is licensed under the MIT License - Read the LICENSE.md file

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.