@@ -18,27 +18,38 @@ class FiniteDiffRegressor(BaseModel, RegressorMixin):
18
18
19
19
Parameters
20
20
----------
21
+
21
22
base_model : str
22
23
The name of the base model (e.g., 'RidgeCV').
24
+
23
25
lr : float, optional
24
26
Learning rate for optimization (default=1e-4).
27
+
25
28
optimizer : {'gd', 'sgd', 'adam', 'cd'}, optional
26
29
Optimization algorithm: gradient descent ('gd'), stochastic gradient descent ('sgd'),
27
30
Adam ('adam'), or coordinate descent ('cd'). Default is 'gd'.
31
+
28
32
eps : float, optional
29
33
Scaling factor for adaptive finite difference step size (default=1e-3).
34
+
30
35
batch_size : int, optional
31
36
Batch size for 'sgd' optimizer (default=32).
37
+
32
38
alpha : float, optional
33
39
Elastic net penalty strength (default=0.0).
40
+
34
41
l1_ratio : float, optional
35
42
Elastic net mixing parameter (0 = Ridge, 1 = Lasso, default=0.0).
43
+
36
44
type_loss : {'mse', 'quantile'}, optional
37
45
Type of loss function to use (default='mse').
46
+
38
47
q : float, optional
39
48
Quantile for quantile loss (default=0.5).
49
+
40
50
**kwargs
41
51
Additional parameters to pass to the scikit-learn model.
52
+
42
53
"""
43
54
44
55
def __init__ (self , base_model ,
@@ -70,10 +81,13 @@ def _loss(self, X, y, **kwargs):
70
81
71
82
Parameters
72
83
----------
84
+
73
85
X : array-like of shape (n_samples, n_features)
74
86
Input data.
87
+
75
88
y : array-like of shape (n_samples,)
76
89
Target values.
90
+
77
91
**kwargs
78
92
Additional keyword arguments for loss calculation.
79
93
@@ -98,13 +112,16 @@ def _compute_grad(self, X, y):
98
112
99
113
Parameters
100
114
----------
115
+
101
116
X : array-like of shape (n_samples, n_features)
102
117
Input data.
118
+
103
119
y : array-like of shape (n_samples,)
104
120
Target values.
105
121
106
122
Returns
107
123
-------
124
+
108
125
ndarray
109
126
Gradient array with the same shape as W_.
110
127
"""
@@ -147,23 +164,31 @@ def fit(self, X, y, epochs=10, verbose=True, show_progress=True, sample_weight=N
147
164
148
165
Parameters
149
166
----------
167
+
150
168
X : array-like of shape (n_samples, n_features)
151
169
Training data.
170
+
152
171
y : array-like of shape (n_samples,)
153
172
Target values.
173
+
154
174
epochs : int, optional
155
175
Number of optimization steps (default=10).
176
+
156
177
verbose : bool, optional
157
178
Whether to print progress messages (default=True).
179
+
158
180
show_progress : bool, optional
159
181
Whether to show tqdm progress bar (default=True).
182
+
160
183
sample_weight : array-like, optional
161
184
Sample weights.
185
+
162
186
**kwargs
163
187
Additional keyword arguments.
164
188
165
189
Returns
166
190
-------
191
+
167
192
self : object
168
193
Returns self.
169
194
"""
@@ -255,18 +280,23 @@ def predict(self, X, level=95, method='splitconformal', **kwargs):
255
280
256
281
Parameters
257
282
----------
283
+
258
284
X : array-like of shape (n_samples, n_features)
259
285
Input data.
286
+
260
287
level : int, optional
261
288
Level of confidence for prediction intervals (default=95).
289
+
262
290
method : {'splitconformal', 'localconformal'}, optional
263
291
Method for conformal prediction (default='splitconformal').
292
+
264
293
**kwargs
265
294
Additional keyword arguments. Use `return_pi=True` for prediction intervals,
266
295
or `return_std=True` for standard deviation estimates.
267
296
268
297
Returns
269
298
-------
299
+
270
300
array or tuple
271
301
Model predictions, or a tuple with prediction intervals or standard deviations if requested.
272
302
"""
0 commit comments