Skip to content

Commit 3b60277

Browse files
authored
Merge pull request #7 from OpenTabular/main
added getters and setters to preprocessor class
2 parents 3cea0c1 + 06527ae commit 3b60277

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

pretab/preprocessor.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,53 @@ def __init__(
178178
self.embeddings = False
179179
self.embedding_dimensions = {}
180180

181+
def get_params(self, deep=True):
182+
"""Get parameters for the preprocessor.
183+
184+
Parameters
185+
----------
186+
deep : bool, default=True
187+
If True, will return parameters of subobjects that are estimators.
188+
189+
Returns
190+
-------
191+
params : dict
192+
Parameter names mapped to their values.
193+
"""
194+
params = {
195+
"n_bins": self.n_bins,
196+
"numerical_preprocessing": self.numerical_preprocessing,
197+
"categorical_preprocessing": self.categorical_preprocessing,
198+
"use_decision_tree_bins": self.use_decision_tree_bins,
199+
"binning_strategy": self.binning_strategy,
200+
"task": self.task,
201+
"cat_cutoff": self.cat_cutoff,
202+
"treat_all_integers_as_numerical": self.treat_all_integers_as_numerical,
203+
"degree": self.degree,
204+
"scaling_strategy": self.scaling_strategy,
205+
"n_knots": self.n_knots,
206+
"use_decision_tree_knots": self.use_decision_tree_knots,
207+
"knots_strategy": self.knots_strategy,
208+
}
209+
return params
210+
211+
def set_params(self, **params):
212+
"""Set parameters for the preprocessor.
213+
214+
Parameters
215+
----------
216+
**params : dict
217+
Parameter names mapped to their new values.
218+
219+
Returns
220+
-------
221+
self : object
222+
Preprocessor instance.
223+
"""
224+
for key, value in params.items():
225+
setattr(self, key, value)
226+
return self
227+
181228
def _detect_column_types(self, X):
182229
"""
183230
Detects categorical and numerical features in the input data.

0 commit comments

Comments
 (0)