[API] Exposing fitted samplers + their scores in CFI #829
* I chose balanced accuracy in this version of the code as an easy solution for multiclass situations, but if AUC is preferred, then we need to choose between OVR or OVO strategy.
I think I'd rather take OVR AUC.
We need to find a different name than score.
In a case where features are independent, a perfect conditional sampler would have a score of 0. This would be misleading, especially for users familiar with sklearn's API.
Maybe we could even make this optional. In a scenario where this stage is costly and the user is not interested in the conditional_scores_ it could be convenient to skip this step.
conditional_score_types_ redundant with data_types? - regarding the naming I have some concerns about
conditional_scores_. First it's semantically close to conditional_importance which can be misleading. And second, a conditional sampler can be very good while the value of conditional_scores_ is very low (in the case of independent variables for instance). What about shared_variance_ or conditional_predictability_ or feature_predictability_- How will this deal with groups of featurs?
Isn'tconditional_score_types_redundant withdata_types?
Indeed, I deleted it.
regarding the naming I have some concerns aboutconditional_scores_. First it's semantically close toconditional_importancewhich can be misleading. And second, a conditional sampler can be very good while the value ofconditional_scores_is very low (in the case of independent variables for instance). What aboutshared_variance_orconditional_predictability_orfeature_predictability_
I renamed it feature_predictability_ following your suggestion
* How will this deal with groups of featurs?
It averages over the scores of individual features for the moment, but there's probably a better way to do it.
Also, I'm thinking that it could be nice to have a plot_feature_predictability() method similar to plot_importance().
I also modified the plot_cfi.py example to showcase changes, but since I haven't edited tests for the moment, it's not readable.
Also, for the moment, there is the issue that the entire feature_group has a single data_type ...
Also, for the moment, there is the issue that the entire feature_group has a single data_type ...
Indeed, but we can address that later. It's something to discuss first.
Ok, then I'll write some tests to settle the code.
Codecov Report
:x: Patch coverage is
96.07843% with 4 lines in your changes missing coverage. Please review.:white_check_mark: Project coverage is 97.53%. Comparing base (
f99afab) to head (ffde59d).| Files with missing lines | Patch % | Lines |
|---|---|---|
| src/hidimstat/conditional\_feature\_importance.py | 95.23% | 2 Missing :warning: |
| src/hidimstat/base\_variable\_importance.py | 94.11% | 1 Missing :warning: |
| src/hidimstat/samplers/conditional\_sampling.py | 97.56% | 1 Missing :warning: |
<details><summary>Additional details and impacted files</summary>
@@ Coverage Diff @@
## main #829 +/- ##
==========================================
- Coverage 97.62% 97.53% -0.10%
==========================================
Files 37 37
Lines 2523 2592 +69
==========================================
+ Hits 2463 2528 +65
- Misses 60 64 +4
</details>
:umbrella: View full report in Codecov by Harness.
:loudspeaker: Have feedback on the report? Share it here.
<details><summary> :rocket: New features to boost your workflow: </summary>
</details>
the title does not render well.
Besides, a vertical line at 1 would be useful.
WDYM ?
the R^2 score is averaged, right ?
What was the motivation for this renaming ? Maybe it's a good idea, but I'm not completely sure.
LGTM overall, thx.
For categorical data, the ROC AUC is computed.
For a group of variables, the ROC AUC is averaged uniformly
over the columns.
Another possibility would be to return $2\times$ AUC $-1$ for categorical variables so that it is in a comparable [0, 1] range to that of regression, with a similar chance level at 0.
Should we allow this to be skipped?
To avoid using "score" I would suggest _joblib_feature_predictability
Could we have a test in a setting where features are either very easy to predict or completely independent, and check that feature_predictability_ matches what we would expect?
The R2 score is averaged indeed. Sklearn r2_score method has the possibility to perform weighting during this computation by the variance of each column, but I honestly can't remember why I picked this option. I think it's better to use a uniform average since it's what we're doing for the categorical data. I switch back to this and update the doc.
The idea was to have a more explicit naming that was also closer to our API.
Yes, it can be a good thing to skip this. I'm making this computed by default, with a simple boolean as argument.
Indeed, I think it's a good idea. What do you think @bthirion ?
I've added tests for easy to predict features and independent ones, for both continuous and categorical outputs in single and multi output settings.
LGTM, thx.
Approved these changes.
bthirion
GrituX
Here is the list of changes, with some explanations:
_list_imputation_modelsbecomesfitted_samplers_conditional_scores_: this is computed duringimportance(), as the score to predict $X_j$ from $X_{-j}$. The metrics used here are $R^2$ and balanced accuracy depending on data type. I chose balanced accuracy in this version of the code as an easy solution for multiclass situations, but if AUC is preferred, then we need to choose between OVR or OVO strategy. The computation is done sequentially after everything all importance score computation because these scores are computed inside joblib workers. This would mean overriding all importance sub-methods, and change everything just for CFI, which can make things harder to maintain. It's doable, but it's more of a question of preference between code maintenance or compute upgrade.conditional_score_types_: similar todata_typesbut forconditional_scores_, it gives the score type for each feature groupFor the moment, there are no new tests. I think it's better to discuss things first, and once everything is validated, I'll add tests to finalize and settle the code, and fix current ones according to changes.