-
Notifications
You must be signed in to change notification settings - Fork 1.9k
OLS FeatureWeights are not the model weights #1850
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@yaeldekel @glebuk Are you all familiar with these APIs and what they are supposed to mean? |
Also, to be clear, the p-value for a feature doesn't specify the relative importance of the feature; it just means how confidence one can be that the value is different than zero. You can have very unimportant features that you are very confident are not zero.... |
@najeeb-kazmi You just touched up the linear model public APIs -- do you have any thoughts on this? |
Hi @rogancarr , it has been many years since I wrote this code, but the request for "feature importance" remains the motivation for the differentiation here. In something like a stochastic method for learning a linear predictor, it is true that the coefficients themselves might be the best (though deeply imperfect) means of measuring feature importance. However a statistical method (like OLS) we can actually do a bit better here. The goal as you've observed is to get the model's best opinion of what it considers its per-feature importance measures, as opposed to, say, "coefficients if it's a linear model and something else if not." The issue here might be one of naming -- it is perhaps wrong to use the word "weight" since that is also used in the case of linear models specifically to mean "coefficient." Would renaming potentially help? |
Hi @TomFinley , Thanks for the insight here! If the meaning is around feature importance, then I'd say we rename the API to reflect that. The word Now, there is also a second point here. Since it's a measure of importance, then the way we calculate it using a p-value isn't really useful. The p-value simply tells us the confidence that we can have that the coefficient should not be zero; it doesn't actually tell us how important the coefficient is to the model, nor does it indicate the relative sizes of the coefficient (as the standard deviations are different for each coefficient). However, now that I've criticized our current importance measure, I'm not sure what to recommend instead: I'm just not sure there is a great way to specify feature importance other than by the coefficients themselves. Usually we have to model or measure importance, as we do in the Edit: Note that I'm talking about coefficients as a proxy for importance when the data is standardized. |
Since I'm touching HAL assembly, I get to the point you guys discussing, and I want to make changes.
Does that sound fair? Or I didn't get you right? Also shall we make GetFeatureWeights internal since it operates over |
hi @Ivanidzo4ka !
FeatureWeights is some sort of measure of feature importance. I kinda want to make it internal, but I think it's the only way to get feature importance for Trees currently. Let's discuss this before we make a move. |
I think it shouldn't be hard to make |
Moving |
@Ivanidzo4ka I looked into this a bit:
I'd like to mark this method What do you think about that? @Ivanidzo4ka and @TomFinley? |
Update to the current status:
The tree model parameters still have this interface and it is used to get the feature gain. This is fine, except that nowhere does it say that this is feature gain. I suggest we add documentation to this function in the tree classes that says that it's feature gain and then close this issue. |
For the
LinearPredictor
, theGetFeatureWeights
returns the model weights, as expected:The
OlsLinearRegressionPredictor
has the same method, but it does not return the model weights. It returns the-log(p-value)
for each feature. This is weird because it overrides theLinearRegressionPredictor
's GetFeatureWeights method but returns a different kind of value, essentially the magnitudes of the p-values.Now, this goes back to the meaning of
feature weight
. Many predictors that are not linear models implementGetFeatureWeight
, and it looks like it's a measure of importance. What's the right thing here? Do we want to return a measure of relative importance or do we want to return the model weights?Currently, I find this API to be super confusing because there is no docstring to explain what you are getting back, and I would expect the "Feature Weights" of a linear model to the model weight parameters.
Also, this is a nit, but if we really want to return the magnitude of the p-values, doesn't
-log10(p-value)
make more sense? The base e log puts these onto a weird scale.The text was updated successfully, but these errors were encountered: