Giter Site home page Giter Site logo

tdidt-decision-tree's Introduction

TDIDT Algorithm for Decision-Tree

Developed in Python Code can be run from command line Python Libraries numpy, copy, random, pickle, graphviz, argparse, sys, string.

All scripts should be in the same folder. Tree is populated with samples of positive and negative class while training. For pruning tree should already exist in a pickle file in same folder.

Running the Algorithm:

See 'python tdidt.py --help' for further options

arguments:
-h, --help	show the help message
--data_file : File name. Depends on mode. If mode is ‘train’ then training file name else test file name 
--max_depth : Maximum depth for tree growth.
--mode : String can take one of two values: ‘train’ or ‘test’, ‘train’ mode is for training decision tree and test mode is for evaluating trained tree on test data.
--dot_file_name: Name of file to store dot format of decision tree.

Train Decision Tree

python tdidt.py --data_file gene_expression_training.csv --max_depth 3 --mode train --dot_file_name tree.dot --pickle_file_name tree.pickle

To generate png file from dot

dot -Tpng tree.dot -o tree.png

Test Decision-Tree

python tdidt.py --data_file gene_expression_test.csv --mode test

Prunning Decision Tree

Arguements
--mode : String to specify pruning mode: ‘heuristic’ or ‘pessimistic’.
--dot_file_name: If training mode name of file to store dot format of decision tree.
--pickle_file_name: Pickle file for tree

(A) Heuristic Pruning Steps

  1. First train the tree on training set.
  2. Prune the tree on validation set (this implementation uses training).
  3. Test the tree on test set.

(B) Pessimistic Pruning Steps

  1. First train the tree on training set.
  2. Prune the tree on training set.
  3. Test the tree on test set.

Prune Decision Tree

python prune_tree.py --mode heuristic --dot_file_name prune_heuristic.dot --pickle_file_input tree.pickle --pickle_file_output heuristic_prune_tree.pickle

Rule Extraction

To extract rules from a trainded decision tree:

python rule_extraction.py --pickle_file_name tree.pickle

Dependencies

  1. Python 3.0+
  2. Graphviz

tdidt-decision-tree's People

Contributors

mdasifkhan avatar

Stargazers

 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.