Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
df93c78
New API for CFI, PFI, LOCO
lionelkusch Sep 2, 2025
ccb60ed
fix test for new API
lionelkusch Sep 2, 2025
7c827ad
fix example
lionelkusch Sep 2, 2025
82d61e6
add test for new check
lionelkusch Sep 2, 2025
28593e4
add pvalue and fit_importance and function
lionelkusch Sep 2, 2025
cabfb63
Add new function
lionelkusch Sep 2, 2025
7d7fd7d
fix docstring
lionelkusch Sep 2, 2025
b958cc7
Improve cross validation
lionelkusch Sep 3, 2025
1f97d60
update docstring
lionelkusch Sep 3, 2025
db96bb6
update doctring
lionelkusch Sep 3, 2025
d656f17
fix error
lionelkusch Sep 3, 2025
0493b6f
fix docstring
lionelkusch Sep 3, 2025
9c54e1b
Apply suggestions from code review
lionelkusch Sep 5, 2025
7bf75e4
Update default
lionelkusch Sep 5, 2025
b3cd78a
fix tests
lionelkusch Sep 5, 2025
7825490
Apply suggestions from code review
lionelkusch Sep 8, 2025
084ad24
chnage group by features_groups
lionelkusch Sep 8, 2025
7379ec1
fix format
lionelkusch Sep 8, 2025
02ae5ba
improve test
lionelkusch Sep 8, 2025
1e91c65
fix docstring
lionelkusch Sep 8, 2025
46b8fa5
Merge branch 'main' into PR_CFI
lionelkusch Sep 8, 2025
58a57f8
fix test
lionelkusch Sep 8, 2025
03b919a
Merge branch 'main' into PR_CFI
lionelkusch Sep 10, 2025
c4ea731
improve loco
lionelkusch Sep 11, 2025
43d3f99
fix computation of pvalues
lionelkusch Sep 11, 2025
5fd99b0
Update src/hidimstat/_utils/utils.py
lionelkusch Sep 12, 2025
3c52789
change name
lionelkusch Sep 12, 2025
c93f14c
remove the cross validation in fit_importance
lionelkusch Sep 24, 2025
aa583d5
change fit_importance
lionelkusch Sep 24, 2025
01cbc44
more flexible for the computation of the statistic
lionelkusch Sep 24, 2025
b1c5f40
update the computation of pvalue for loco
lionelkusch Sep 24, 2025
1a47330
Merge branch 'main' into PR_CFI
lionelkusch Oct 10, 2025
1ef69a6
fix merge
lionelkusch Oct 13, 2025
d00566b
Merge branch 'main' into PR_CFI
lionelkusch Oct 13, 2025
83ae849
fix example
lionelkusch Oct 13, 2025
a3cd681
fix example
lionelkusch Oct 13, 2025
b3f336a
fix import
lionelkusch Oct 13, 2025
a364a93
Merge branch 'main' into PR_CFI
lionelkusch Oct 14, 2025
6dc8d67
Update src/hidimstat/leave_one_covariate_out.py
lionelkusch Oct 14, 2025
afd03cb
Update src/hidimstat/base_perturbation.py
lionelkusch Oct 14, 2025
3fa9d01
fix modification
lionelkusch Oct 14, 2025
1202426
Remove the wrong merge
lionelkusch Oct 14, 2025
75d6578
Add check_test_statistic
lionelkusch Oct 15, 2025
ae3dfa9
change name
lionelkusch Oct 15, 2025
035f4c8
fix import
lionelkusch Oct 15, 2025
84ff550
Merge branch 'main' into PR_CFI
lionelkusch Oct 15, 2025
251584c
change name
lionelkusch Oct 15, 2025
1c15c5b
Update src/hidimstat/_utils/utils.py
lionelkusch Oct 16, 2025
9414368
Update src/hidimstat/conditional_feature_importance.py
lionelkusch Oct 16, 2025
8a8587f
Update src/hidimstat/conditional_feature_importance.py
lionelkusch Oct 16, 2025
631ee83
Update src/hidimstat/permutation_feature_importance.py
lionelkusch Oct 16, 2025
39ebce1
Update src/hidimstat/_utils/utils.py
lionelkusch Oct 16, 2025
971da61
Update test/test_conditional_feature_importance.py
lionelkusch Oct 16, 2025
c7adec9
Update test/test_conditional_feature_importance.py
lionelkusch Oct 16, 2025
a3c7906
Update src/hidimstat/conditional_feature_importance.py
lionelkusch Oct 16, 2025
f4c8ce4
Update src/hidimstat/leave_one_covariate_out.py
lionelkusch Oct 16, 2025
c983eab
Update src/hidimstat/leave_one_covariate_out.py
lionelkusch Oct 16, 2025
f91ac6c
Update src/hidimstat/leave_one_covariate_out.py
lionelkusch Oct 16, 2025
38c6bc7
Update src/hidimstat/permutation_feature_importance.py
lionelkusch Oct 16, 2025
0bb880e
Update src/hidimstat/permutation_feature_importance.py
lionelkusch Oct 16, 2025
a92ea83
Update src/hidimstat/permutation_feature_importance.py
lionelkusch Oct 16, 2025
2166f2c
fix format
lionelkusch Oct 16, 2025
4cc3598
fix modification
lionelkusch Oct 16, 2025
0e6b929
fix order import
lionelkusch Oct 16, 2025
4389796
remove unecessary merge
lionelkusch Oct 16, 2025
9a640b1
Update src/hidimstat/_utils/utils.py
lionelkusch Oct 16, 2025
431d9a6
update error
lionelkusch Oct 16, 2025
e7bbb30
Merge branch 'main' into PR_CFI
lionelkusch Oct 22, 2025
e003345
add the NB-ttest as default
lionelkusch Oct 22, 2025
1973bcc
move sampler in separate module
lionelkusch Oct 22, 2025
57ca067
move sampler in a separate folder
lionelkusch Oct 22, 2025
e4d686c
fix import
lionelkusch Oct 22, 2025
a9cd709
fix tests
lionelkusch Oct 22, 2025
75e81d7
Merge branch 'main' into PR_CFI
lionelkusch Oct 22, 2025
9ab658a
fix tests
lionelkusch Oct 22, 2025
329bf43
fix example
lionelkusch Oct 22, 2025
9f488d6
change nane of nb-test
lionelkusch Oct 22, 2025
17f8d6e
fix import order
lionelkusch Oct 22, 2025
d33205c
fix assert and add assert
lionelkusch Oct 22, 2025
cfc12d0
Update src/hidimstat/base_perturbation.py
bthirion Oct 23, 2025
7a4f44a
Merge branch 'main' into PR_CFI
lionelkusch Oct 24, 2025
d14b835
Remove unecessary check
lionelkusch Oct 24, 2025
87e2029
update loco
lionelkusch Oct 24, 2025
c61bb44
make ttest the default without CV
jpaillard Oct 26, 2025
b0c4ec0
Merge branch 'main' into PR_CFI
jpaillard Oct 29, 2025
359118a
Merge branch 'main' of github.com:mind-inria/hidimstat into PR_CFI
jpaillard Nov 6, 2025
1deae93
rename functions
jpaillard Nov 6, 2025
911f11c
fix import
jpaillard Nov 6, 2025
bc4ee65
Update src/hidimstat/_utils/utils.py
jpaillard Nov 7, 2025
e93b97f
add test_frac
jpaillard Nov 7, 2025
e03266e
Merge branch 'main' of github.com:mind-inria/hidimstat into PR_CFI
jpaillard Nov 7, 2025
eca0c0c
init
jpaillard Nov 7, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/plot_conditional_vs_marginal_xor_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
random_state=0,
)
vim.fit(X_train, y_train)
importances.append(vim.importance(X_test, y_test)["importance"])
importances.append(vim.importance(X_test, y_test))

importances = np.array(importances).T

Expand Down
12 changes: 6 additions & 6 deletions examples/plot_diabetes_variable_importance_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,14 +184,14 @@ def compute_pval(vim):
# -------------------


cfi_vim_arr = np.array([x["importance"] for x in cfi_importance_list]) / 2
cfi_vim_arr = np.array(cfi_importance_list) / 2
cfi_pval = compute_pval(cfi_vim_arr)

vim = [
pd.DataFrame(
{
"var": np.arange(cfi_vim_arr.shape[1]),
"importance": x["importance"],
"importance": x,
"fold": i,
"pval": cfi_pval,
"method": "CFI",
Expand All @@ -200,14 +200,14 @@ def compute_pval(vim):
for x in cfi_importance_list
]

loco_vim_arr = np.array([x["importance"] for x in loco_importance_list])
loco_vim_arr = np.array(loco_importance_list)
loco_pval = compute_pval(loco_vim_arr)

vim += [
pd.DataFrame(
{
"var": np.arange(loco_vim_arr.shape[1]),
"importance": x["importance"],
"importance": x,
"fold": i,
"pval": loco_pval,
"method": "LOCO",
Expand All @@ -216,14 +216,14 @@ def compute_pval(vim):
for x in loco_importance_list
]

pfi_vim_arr = np.array([x["importance"] for x in pfi_importance_list])
pfi_vim_arr = np.array(pfi_importance_list)
pfi_pval = compute_pval(pfi_vim_arr)

vim += [
pd.DataFrame(
{
"var": np.arange(pfi_vim_arr.shape[1]),
"importance": x["importance"],
"importance": x,
"fold": i,
"pval": pfi_pval,
"method": "PFI",
Expand Down
2 changes: 1 addition & 1 deletion examples/plot_importance_classification_iris.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def run_one_fold(X, y, model, train_index, test_index, vim_name="CFI", groups=No
)

vim.fit(X[train_index], y[train_index], groups=groups)
importance = vim.importance(X[test_index], y[test_index])["importance"]
importance = vim.importance(X[test_index], y[test_index])

return pd.DataFrame(
{
Expand Down
6 changes: 2 additions & 4 deletions examples/plot_model_agnostic_importance.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,8 @@
vim_linear.fit(X[train], y[train])
vim_non_linear.fit(X[train], y[train])

importances_linear.append(vim_linear.importance(X[test], y[test])["importance"])
importances_non_linear.append(
vim_non_linear.importance(X[test], y[test])["importance"]
)
importances_linear.append(vim_linear.importance(X[test], y[test]))
importances_non_linear.append(vim_non_linear.importance(X[test], y[test]))


################################################################################
Expand Down
4 changes: 2 additions & 2 deletions examples/plot_pitfalls_permutation_importance.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
)
pfi.fit(X_test, y_test)

permutation_importances.append(pfi.importance(X_test, y_test)["importance"])
permutation_importances.append(pfi.importance(X_test, y_test))
permutation_importances = np.stack(permutation_importances)
pval_pfi = ttest_1samp(
permutation_importances, 0.0, axis=0, alternative="greater"
Expand Down Expand Up @@ -200,7 +200,7 @@
)
cfi.fit(X_test, y_test)

conditional_importances.append(cfi.importance(X_test, y_test)["importance"])
conditional_importances.append(cfi.importance(X_test, y_test))


cfi_pval = ttest_1samp(
Expand Down
9 changes: 6 additions & 3 deletions src/hidimstat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
desparsified_group_lasso_pvalue,
)
from .distilled_conditional_randomization_test import d0crt, D0CRT
from .conditional_feature_importance import CFI
from .conditional_feature_importance import cfi, CFI
from .knockoffs import (
model_x_knockoff,
model_x_knockoff_pvalue,
model_x_knockoff_bootstrap_quantile,
model_x_knockoff_bootstrap_e_value,
)
from .leave_one_covariate_out import LOCO
from .leave_one_covariate_out import loco, LOCO
from .noise_std import reid
from .permutation_feature_importance import PFI
from .permutation_feature_importance import pfi, PFI

from .statistical_tools.aggregation import quantile_aggregation

Expand All @@ -49,6 +49,9 @@
"model_x_knockoff_bootstrap_quantile",
"model_x_knockoff_bootstrap_e_value",
"CFI",
"cfi",
"LOCO",
"loco",
"PFI",
"pfi",
]
31 changes: 31 additions & 0 deletions src/hidimstat/_utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,34 @@ def _check_vim_predict_method(method):
"The method {} is not a valid method "
"for variable importance measure prediction".format(method)
)


def get_generated_attributes(cls):
"""
Get all attributes from a class that end with a single underscore
and doesn't start with one underscore.

Parameters
----------
cls : class
The class to inspect for attributes.

Returns
-------
list
A list of attribute names that end with a single underscore but not double underscore.
"""
# Get all attributes and methods of the class
all_attributes = dir(cls)

# Filter out attributes that start with an underscore
filtered_attributes = [attr for attr in all_attributes if not attr.startswith("_")]

# Filter out attributes that do not end with a single underscore
result = [
attr
for attr in filtered_attributes
if attr.endswith("_") and not attr.endswith("__")
]

return result
Loading
Loading