Comments (3)
Very nice observation. Lasso does tend to randomly pick a feature (rule) in the case of collinearity!
For the OR option, do you mean carry all equivalent rules say R1 R2 R3 into a composite R*=(R1 or R2 or R3)?
Would a simpler solution be to whip out Occams razor and simply pick the simplest rule (lowest number of conditions) - or pick at random if they are equal? Or do you think it is important to let the user see the options for equivalent rules...
from rulefit.
As an aside, if my intuition is true,
the following formulations are also equivalent where a and b are two rule-transformed columns and ws are the weights.
y = w0 + w1 a + w2 b
and
y = w0 + w1 a + w2 (1-b) = w0 + w1 a + w2 - w2b = (w0+w2) + w1 a - w2 b
So in the end rules A and B are also equivalent in terms of linear model if transform(A) = 1 - transform(B) , i.e. the negated rule is equivalent to itself.
This is true when the linear model contains an intercept (which is the default in RuleFit). Depending on the research question these may not be desired in cases where intercept is not used.
Such positive-negative redundancies can be found in a similar way:
equivalence_classes_with_negative = {}
for rule, col in transformed_x.T.iterrows():
key_pos = tuple(col)
key_neg = tuple(1 - col)
try:
equivalence_classes_with_negative[key_pos].append(('+', rule))
except KeyError:
equivalence_classes_with_negative[key_pos] = [('+', rule)]
try:
equivalence_classes_with_negative[key_neg].append(('-', rule))
except KeyError:
equivalence_classes_with_negative[key_neg] = [('-', rule)]
redundant_rules_with_neg = {k: v for k, v in equivalence_classes_with_negative.items() if len(v) > 1}
for v in redundant_rules_with_neg.values():
print('Redundant rules')
for vv in v:
print('{}: support={:.3f}, prediction={:.3f}'.format(vv, vv[1].support, vv[1].prediction_value))
we get rule groups like this:
('+', tax <= 278.0): support=0.256, prediction=2.626
('-', tax > 278.0): support=0.744, prediction=-0.623
Arguably we would need only one of these features in the linear model (as the other can be absorbed into the intercept). I'm pretty sure this is a special case of the issue of constructing linearly-independent categorical encoding that patsy
tries to solve
I wonder if something like this should be implemented here as well.
from rulefit.
My concern is that simplest rule might overgeneralise on the training dataset.
In theory there is a small chance that the additional rules that are redundant in the training dataset might capture some extra variation in the test datasets. In this case OR could capture this.
For instance, for something like the following dataset of (x,y) pairs:
[(1, 2), (3, 4), (5,6)]
The following rules are redundant
R1: x > 1
R2: x <= 5 and y>3
But for a hypothetical test observation (0,4)
this will no longer be the case.
Simplest rule, R1, will have a zero for this dataset.
R1 or R2 should correctly capture this combination as 1 though.
Ideally I think something like R* = simplify(R1 or R2 or R3)
would work best for such rules.
In this case it is clear that
R* = (x>1 or x <=5) and (x>1 or y>3) = True and (x>1 or y<=3) = x>1 or y > 3
Not entirely sure how to implement this though. Maybe sympy?
Related to my second comment in this issue, I have been thinking about that and either I don't understand something about the decision rule generation as described in Friedman in Popescu, or it could be improved. In my opinion, only one side of the rules (condition == True, or condition == False) need to be incorporated at any given level of the tree, as including both adds no extra predictability to the linear model downstream. Let me see if I can draft a proof for this.
from rulefit.
Related Issues (20)
- rulefit.py - SyntaxError: invalid syntax, line 105 HOT 5
- predict() does not work in rules-only mode HOT 2
- Error on passed estimator HOT 4
- Fails when model_type='l'
- Be careful if you are using this package! HOT 4
- predict_prob
- Your own example is not working HOT 4
- How can I calculate the list of rules that fired for a given prediction ?
- ValueError in example_simulated.py HOT 3
- exp_rand_tree_size=True issue: results are not reproducible when running multiple times
- Fix Friedscale test
- Why is max depth fixed?
- Argument description in rulefit.py needs corrected
- Getting error : unsupported operand type(s) for /: 'int' and 'RandomForestClassifier' HOT 4
- InvalidIndexError: (slice(None, None, None), 0) HOT 1
- Update installation instructions HOT 1
- Input variable importance HOT 2
- Compatibility with GridSearchCV of sklearn HOT 1
- may you recommend actively maintained and good python code with the similar capabilities
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 rulefit.