@@ -26,13 +26,13 @@ class FastCan(SelectorMixin, BaseEstimator):
26
26
27
27
Parameters
28
28
----------
29
- n_features_to_select : int
29
+ n_features_to_select : int, default=1
30
30
The parameter is the absolute number of features to select.
31
31
32
32
inclusive_indices : array-like of shape (n_inclusions,), default=None
33
33
The indices of the prerequisite features.
34
34
35
- eta : bool, default=None
35
+ eta : bool, default=False
36
36
Whether to use eta-cosine method.
37
37
38
38
tol : float, default=0.01
@@ -94,16 +94,16 @@ class FastCan(SelectorMixin, BaseEstimator):
94
94
Interval (Integral , 1 , None , closed = "left" ),
95
95
],
96
96
"inclusive_indices" : [None , "array-like" ],
97
- "eta" : ["boolean" , None ],
97
+ "eta" : ["boolean" ],
98
98
"tol" : [Interval (Real , 0 , None , closed = "neither" )],
99
99
"verbose" : ["verbose" ],
100
100
}
101
101
102
102
def __init__ (
103
103
self ,
104
- n_features_to_select ,
104
+ n_features_to_select = 1 ,
105
105
inclusive_indices = None ,
106
- eta = None ,
106
+ eta = False ,
107
107
tol = 0.01 ,
108
108
verbose = 1 ,
109
109
):
@@ -132,8 +132,8 @@ def fit(self, X, y):
132
132
"""
133
133
self ._validate_params ()
134
134
# X y
135
- check_X_params = {"order" : "F" }
136
- check_y_params = {"ensure_2d" : False , "order" : "F" }
135
+ check_X_params = {"order" : "F" , "dtype" : float }
136
+ check_y_params = {"ensure_2d" : False , "order" : "F" , "dtype" : float }
137
137
X , y = self ._validate_data (
138
138
X = X ,
139
139
y = y ,
@@ -147,9 +147,9 @@ def fit(self, X, y):
147
147
148
148
# inclusive_indices
149
149
if self .inclusive_indices is None :
150
- self . inclusive_indices = np .zeros (0 , dtype = int )
150
+ inclusive_indices = np .zeros (0 , dtype = int )
151
151
else :
152
- self . inclusive_indices = check_array (
152
+ inclusive_indices = check_array (
153
153
self .inclusive_indices ,
154
154
ensure_2d = False ,
155
155
dtype = int ,
@@ -165,18 +165,12 @@ def fit(self, X, y):
165
165
f"must be <= n_features { n_features } ."
166
166
)
167
167
168
- if self . inclusive_indices .shape [0 ] >= n_features :
168
+ if inclusive_indices .shape [0 ] >= n_features :
169
169
raise ValueError (
170
- f"n_inclusions { self . inclusive_indices .shape [0 ]} must "
170
+ f"n_inclusions { inclusive_indices .shape [0 ]} must "
171
171
f"be < n_features { n_features } ."
172
172
)
173
173
174
- # Method determination
175
- if self .eta is None :
176
- if n_samples > n_features + n_outputs :
177
- self .eta = True
178
- else :
179
- self .eta = False
180
174
if n_samples < n_features + n_outputs and self .eta :
181
175
raise ValueError (
182
176
"`eta` cannot be True, when n_samples < n_features+n_outputs."
@@ -197,7 +191,7 @@ def fit(self, X, y):
197
191
y_transformed = y - y .mean (0 )
198
192
199
193
mask , indices , scores = self ._prepare_data (
200
- self . inclusive_indices ,
194
+ inclusive_indices ,
201
195
)
202
196
n_threads = _openmp_effective_n_threads ()
203
197
_forward_search (
0 commit comments