Comments (4)
I am happy to track down the bug, but could you specify which data set you where using to save me some time.
from decision-tree-id3.
I used the data set in the doc.
Code:
from id3 import Id3Estimator, export_text
import numpy as np
feature_names = ["age",
"gender",
"sector",
"degree"]
X = np.array([[45, "male", "private", "m"],
[50, "female", "private", "m"],
[61, "other", "public", "b"],
[40, "male", "private", "none"],
[34, "female", "private", "none"],
[33, "male", "public", "none"],
[43, "other", "private", "m"],
[35, "male", "private", "m"],
[34, "female", "private", "m"],
[35, "male", "public", "m"],
[34, "other", "public", "m"],
[34, "other", "public", "b"],
[34, "female", "public", "b"],
[34, "male", "public", "b"],
[34, "female", "private", "b"],
[34, "male", "private", "b"],
[34, "other", "private", "b"]])
y = np.array(["(30k,38k)",
"(30k,38k)",
"(30k,38k)",
"(13k,15k)",
"(13k,15k)",
"(13k,15k)",
"(23k,30k)",
"(23k,30k)",
"(23k,30k)",
"(15k,23k)",
"(15k,23k)",
"(15k,23k)",
"(15k,23k)",
"(15k,23k)",
"(23k,30k)",
"(23k,30k)",
"(23k,30k)"])
# is_repeating=True
clf1 = Id3Estimator(is_repeating=True)
clf1.fit(X, y, check_input=True)
print('is_repeating=True:')
print(export_text(clf1.tree_, feature_names))
# is_repeating=False
clf2 = Id3Estimator(is_repeating=False)
clf2.fit(X, y, check_input=True)
print('is_repeating=False:')
print(export_text(clf1.tree_, feature_names))
The output:
is_repeating=True:
degree b
| sector private: (23k,30k) (3)
| sector public
| | age <=47.50: (15k,23k) (3)
| | age >47.50: (30k,38k) (1)
degree m
| age <=44.00
| | sector private: (23k,30k) (3)
| | sector public: (15k,23k) (2)
| age >44.00: (30k,38k) (2)
degree none: (13k,15k) (3)
is_repeating=False:
degree b
| sector private: (23k,30k) (3)
| sector public
| | age <=47.50: (15k,23k) (3)
| | age >47.50: (30k,38k) (1)
degree m
| age <=44.00
| | sector private: (23k,30k) (3)
| | sector public: (15k,23k) (2)
| age >44.00: (30k,38k) (2)
degree none: (13k,15k) (3)
There are two age
and sector
in different levels when I set is_repeating=False
. (Actually, I am not sure about whether or not this situation could be considered as repeating
:-)
from decision-tree-id3.
After giving the code a peek after +1 year I figured out the behavior of is_repeating
. The parameter doesn't constrain global repeating features. The flag is_repeating
constrains a decision node to pick a feature not used by any parent of said node. So the following tree is not a bug per se with is_repeating = True
:
degree b
| sector private: (23k,30k) (3)
| sector public
| | age <=47.50: (15k,23k) (3)
| | age >47.50: (30k,38k) (1)
degree m
| age <=44.00
| | sector private: (23k,30k) (3)
| | sector public: (15k,23k) (2)
| age >44.00: (30k,38k) (2)
degree none: (13k,15k) (3)
By definition this only limit numerical features from repeating.
If this behavior is by design or incorrectly implemented I actually can't remember, but the docs is either way surly lacking in the case of is_repeating
.
I will give this a think. Thanks for bringing it up!
from decision-tree-id3.
Well, I think your explanation for the parameter is_repeating
is right and the implementation of the decision tree algorithm is right too.(I'm the one that misunderstanding the theory of ID3:-) Anyway, as you have said, we may need a more appropriate demo to make the parameter's meaning clear. Thanks a lot for your awesome work and helpful reply.
from decision-tree-id3.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from decision-tree-id3.