@@ -110,27 +110,25 @@ def fit(self, X, y):
110110 self .clustering_ = self .clustering .fit (X [self .clustering_samples_ , :])
111111 X_reduced = self .clustering_ .transform (X )
112112
113- # Desparsified lasso inference
114113 if hasattr (self .vi_estimator , "random_state" ):
115114 self .vi_estimator .random_state = self .random_state
116115 self .vi_estimator_ = self .vi_estimator .fit (X_reduced , y )
117116 return self
118117
119- def importance (self , X = None , y = None ):
118+ def importance (self , X , y ):
120119 """
121120 Compute feature importance using desparsified lasso. Then map the importance
122121 scores from cluster level back to feature level.
123122
124123 Parameters
125124 ----------
126- X :
127- Not used, present for API consistency by convention .
128- y :
129- Not used, present for API consistency by convention .
125+ X : ndarray, shape (n_samples, n_features)
126+ Input data matrix .
127+ y : ndarray, shape (n_samples,) or (n_samples, n_tasks)
128+ Target variable(s) .
130129 """
131- del y
132- del X
133- self .vi_estimator_ .importance ()
130+ X_reduced = self .clustering_ .transform (X )
131+ self .vi_estimator_ .importance (X_reduced , y )
134132
135133 self .pvalues_ = self .clustering_ .inverse_transform (
136134 self .vi_estimator_ .pvalues_
@@ -410,33 +408,31 @@ def importance(self, X=None, y=None):
410408
411409 Parameters
412410 ----------
413- X :
414- Not used, present for API consistency by convention .
415- y :
416- Not used, present for API consistency by convention .
411+ X : ndarray, shape (n_samples, n_features)
412+ Input data matrix .
413+ y : ndarray, shape (n_samples,) or (n_samples, n_tasks)
414+ Target variable(s) .
417415
418416 Returns
419417 -------
420418 importances_ : ndarray, shape (n_features,) or (n_features, n_tasks)
421419 Estimated importance values at feature level.
422420 """
423- del y
424- del X
425421 for i in tqdm (
426422 range (self .n_bootstraps ),
427423 desc = "Computing importances" ,
428424 total = self .n_bootstraps ,
429425 ):
430- self .clustering_vi_estimators_ [i ].importance ()
426+ self .clustering_vi_estimators_ [i ].importance (X , y )
431427
432428 self .importances_ = np .mean (
433- [clu_dl .importances_ for clu_dl in self .clustering_vi_estimators_ ],
429+ [clu_vi .importances_ for clu_vi in self .clustering_vi_estimators_ ],
434430 axis = 0 ,
435431 )
436432
437433 self .pvalues_ = quantile_aggregation (
438434 np .array (
439- [clu_dl .pvalues_ for clu_dl in self .clustering_vi_estimators_ ]
435+ [clu_vi .pvalues_ for clu_vi in self .clustering_vi_estimators_ ]
440436 ),
441437 gamma = self .gamma ,
442438 adaptive = self .adaptive_aggregation ,
0 commit comments