Giter VIP home page Giter VIP logo

simplehoeffdingtree's Introduction

SimpleHoeffdingTree

Simply calculates the splits based on the amazing Hoeffding bound. This is just for research purposes.

Reference paper:

@inproceedings{domingos2000mining,
  title={Mining high-speed data streams},
  author={Domingos, Pedro and Hulten, Geoff},
  booktitle={Proceedings of the sixth ACM SIGKDD international conference on Knowledge discovery and data mining},
  pages={71--80},
  year={2000}
}

Sample data:

Person Time since license Gender Area Risk class
1 1 − 2 m urban low
2 2 − 7 m rural high
3 > 7 f rural low
4 1 − 2 f rural high
5 > 7 m rural high
6 1 − 2 m rural high
7 2 − 7 f urban low
8 2 − 7 m urban low

Sample output (with verbose set to True):

2
dict_keys(['1-2', '2-7'])
entropy for 1-2 :  -0.0
entropy for 2-7 :  -0.0
weighted_sum: 0.0
infogain: 1.0 - 0.0 =  1.0
dict_keys(['m'])
entropy for m :  1.0
weighted_sum: 1.0
infogain: 1.0 - 1.0 =  0.0
dict_keys(['urban', 'rural'])
entropy for urban :  -0.0
entropy for rural :  -0.0
weighted_sum: 0.0
infogain: 1.0 - 0.0 =  1.0
All infogains: [(0.0, 'gender'), (1.0, 'area'), (1.0, 'time')]

4
dict_keys(['1-2', '2-7', '>7'])
entropy for 1-2 :  1.0
entropy for 2-7 :  -0.0
entropy for >7 :  -0.0
weighted_sum: 0.5
infogain: 1.0 - 0.5 =  0.5
dict_keys(['m', 'f'])
entropy for m :  1.0
entropy for f :  1.0
weighted_sum: 1.0
infogain: 1.0 - 1.0 =  0.0
dict_keys(['urban', 'rural'])
entropy for urban :  -0.0
entropy for rural :  0.9182958340544896
weighted_sum: 0.6887218755408672
infogain: 1.0 - 0.6887218755408672 =  0.31127812445913283
All infogains: [(0.0, 'gender'), (0.31127812445913283, 'area'), (0.5, 'time')]

6
dict_keys(['1-2', '2-7', '>7'])
entropy for 1-2 :  0.9182958340544896
entropy for 2-7 :  -0.0
entropy for >7 :  1.0
weighted_sum: 0.792481250360578
infogain: 0.9182958340544896 - 0.792481250360578 =  0.12581458369391152
dict_keys(['m', 'f'])
entropy for m :  0.8112781244591328
entropy for f :  1.0
weighted_sum: 0.8741854163060885
infogain: 0.9182958340544896 - 0.8741854163060885 =  0.044110417748401076
dict_keys(['urban', 'rural'])
entropy for urban :  -0.0
entropy for rural :  0.7219280948873623
weighted_sum: 0.6016067457394686
infogain: 0.9182958340544896 - 0.6016067457394686 =  0.31668908831502096
All infogains: [(0.044110417748401076, 'gender'), (0.12581458369391152, 'time'), (0.31668908831502096, 'area')]

8
dict_keys(['1-2', '2-7', '>7'])
entropy for 1-2 :  0.9182958340544896
entropy for 2-7 :  0.9182958340544896
entropy for >7 :  1.0
weighted_sum: 0.9387218755408672
infogain: 1.0 - 0.9387218755408672 =  0.06127812445913283
dict_keys(['m', 'f'])
entropy for m :  0.9709505944546686
entropy for f :  0.9182958340544896
weighted_sum: 0.9512050593046015
infogain: 1.0 - 0.9512050593046015 =  0.04879494069539847
dict_keys(['urban', 'rural'])
entropy for urban :  -0.0
entropy for rural :  0.7219280948873623
weighted_sum: 0.4512050593046014
infogain: 1.0 - 0.4512050593046014 =  0.5487949406953986
All infogains: [(0.04879494069539847, 'gender'), (0.06127812445913283, 'time'), (0.5487949406953986, 'area')]
Split on: area

simplehoeffdingtree's People

Contributors

instance01 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  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.