Skip to content

Conversation

@lionelkusch
Copy link
Collaborator

Update the model of CFI, PFI and LOCO for API 2.

@lionelkusch lionelkusch added the API 2 Refactoring following the second version of API label Sep 2, 2025
@codecov
Copy link

codecov bot commented Sep 2, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.06%. Comparing base (1f97f5b) to head (eca0c0c).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #372      +/-   ##
==========================================
+ Coverage   98.94%   99.06%   +0.12%     
==========================================
  Files          23       21       -2     
  Lines        1424     1393      -31     
==========================================
- Hits         1409     1380      -29     
+ Misses         15       13       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@jpaillard jpaillard left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks good but the diff seems very large for this small change.
Is there a reason for all the other modifications?

@lionelkusch
Copy link
Collaborator Author

I reorganize a bit the parameter in the init and move the docstring to the class because in all the other classes, I plan to do this.

By looking into more details, I miss some parts being added. I will add it and ask you to review it after. Sorry for it.

Copy link
Collaborator

@bthirion bthirion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is definitely an improvement, thx.

Copy link
Collaborator

@bthirion bthirion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thx for the progress. Please find a few suggestions enclosed.

return partial(
nadeau_bengio_ttest,
popmean=0,
test_frac=0.1 / 0.9,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One solution is to make this function a class function, only called during the .importance(X_test, y_test) and to add a fitted attribute self.n_train_ that is set during the fit.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to let the user define it for the moment.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a possible solution to add a required argument test_frac to the instantiation. But since this comes for free in the fit/importance process, I would suggest that hidimstat takes care of it to avoid mistakes from users and limit the number of required arguments in the initialization of the class.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not supported by the other statistical tests.
We should support the different statistical tests or choose one specific and not let the choice of the users.
I don't see the point of the moment to have a different behaviour for this specific test.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It has too. You can see the section inference of the user guide.

When cross-validation (for instance, k-fold) is used to estimate CFI, the loss differences obtained from different folds are not independent. Consequently, performing a simple t-test on the loss differences is not valid. This issue can be addressed by a corrected t-test accounting for this dependence, such as the one proposed in Nadeau and Bengio[3].

Copy link
Collaborator

@bthirion bthirion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No further comment than those raised by @jpaillard

@jpaillard
Copy link
Collaborator

Regarding the statistical test, the current issue is that the cross-validation scheme has not yet been implemented. Currently, the statistical test is performed using a single train/test split. In that case, when considering the loss values for each individual sample of the test set, they can be considered as independent and we could use ttest instead of nb-ttest as the default.

The NB-t-test actually needs to be the default when CV is used, and losses over test sets cannot be considered as independent.

The comment regarding the nb-ttest implementation remains valid; however, the test fraction shouldn't be hardcoded. I will follow up on #449

@jpaillard
Copy link
Collaborator

  • I made 'ttest' as the default statistical_test for the current implem of CFI, which doesn't use CV.
  • We can keep the implementation of nb-ttest. I fixed the hardcoded test_frac. 'nb-ttest' will be the default statistical_test for LOCO_CV, CFI_CV ... in Cross Validation #449

Let me know if that's good for you. Sorry for the confusion.

@jpaillard
Copy link
Collaborator

If my last two comments are OK for you, @bthirion, this is ready to merge.
It's otherwise blocking #449

@lionelkusch
Copy link
Collaborator Author

@jpaillard I let you deal with this PR.

@lionelkusch lionelkusch mentioned this pull request Oct 27, 2025
5 tasks
@jpaillard jpaillard changed the title API 2: CFI, PFI, LOCO [API 2]: CFI, PFI, LOCO Nov 6, 2025
@jpaillard
Copy link
Collaborator

I take the opportunity to rename the function loco --> loco_analysis as discussed in #499

@jpaillard jpaillard requested a review from bthirion November 6, 2025 09:04
Copy link
Collaborator

@bthirion bthirion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very minor stuff pending. Thx !

@jpaillard
Copy link
Collaborator

Sorry again for the confusion regarding the default test. I explained the choice a few comments above.

Regarding the statistical test, the current issue is that the cross-validation scheme has not yet been implemented. Currently, the statistical test is performed using a single train/test split. In that case, when considering the loss values for each individual sample of the test set, they can be considered as independent and we could use ttest instead of nb-ttest as the default.

The NB-t-test actually needs to be the default when CV is used, and losses over test sets cannot be considered as independent.
...

@bthirion
Copy link
Collaborator

bthirion commented Nov 7, 2025

Sorry again for the confusion regarding the default test. I explained the choice a few comments above.

Regarding the statistical test, the current issue is that the cross-validation scheme has not yet been implemented. Currently, the statistical test is performed using a single train/test split. In that case, when considering the loss values for each individual sample of the test set, they can be considered as independent and we could use ttest instead of nb-ttest as the default.
The NB-t-test actually needs to be the default when CV is used, and losses over test sets cannot be considered as independent.
...

OK, makes sense.

@bthirion
Copy link
Collaborator

bthirion commented Nov 7, 2025

I think it's OK for merging.

@jpaillard jpaillard merged commit acb8e20 into mind-inria:main Nov 8, 2025
24 checks passed
@jpaillard jpaillard deleted the PR_CFI branch November 8, 2025 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

API 2 Refactoring following the second version of API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a methods for calculating the p-values for CPI, PI and LOCO

3 participants