-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathNGBRegression.Rd
executable file
·394 lines (342 loc) · 12.2 KB
/
NGBRegression.Rd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ngbreg.R
\name{NGBRegression}
\alias{NGBRegression}
\title{Constructor for NGBoost regression models.}
\description{
NGBRegressor is a wrapper for the generic NGBoost class that facilitates
regression.Use this class if you want to predict an outcome that could take
an infinite number of (ordered) values.
}
\examples{
\dontrun{
data(Boston, package = "MASS")
dta <- rsample::initial_split(Boston)
train <- rsample::training(dta)
test <- rsample::testing(dta)
x_train = train[,1:13]
y_train = train[,14]
x_test = test[,1:13]
y_test = test[,14]
model <- NGBRegression$new(Dist = Dist("Exponential"),
Base=DecisionTreeRegressor(
criterion="mae",
min_samples_split=2,
min_samples_leaf=1,
min_weight_fraction_leaf=0.0,
max_depth=5,
splitter="best",
random_state=NULL),
Score = Scores("MLE"),
natural_gradient=TRUE,
n_estimators= 600,
learning_rate= 0.002,
minibatch_frac= 0.8,
col_sample= 0.9,
verbose=TRUE,
verbose_eval=100,
tol=1e-5)
model$fit(X = x_train, Y = y_train, X_val = x_test, Y_val = y_test)
model$feature_importances()
model$plot_feature_importance()
model$predict(x_test)
}
}
\author{
Resul Akay
}
\section{Methods}{
\subsection{Public methods}{
\itemize{
\item \href{#method-NGBRegression-new}{\code{NGBRegression$new()}}
\item \href{#method-NGBRegression-fit}{\code{NGBRegression$fit()}}
\item \href{#method-NGBRegression-feature_importances}{\code{NGBRegression$feature_importances()}}
\item \href{#method-NGBRegression-plot_feature_importance}{\code{NGBRegression$plot_feature_importance()}}
\item \href{#method-NGBRegression-predict}{\code{NGBRegression$predict()}}
\item \href{#method-NGBRegression-staged_pred_dist}{\code{NGBRegression$staged_pred_dist()}}
\item \href{#method-NGBRegression-staged_pred}{\code{NGBRegression$staged_pred()}}
\item \href{#method-NGBRegression-set_params}{\code{NGBRegression$set_params()}}
\item \href{#method-NGBRegression-get_params}{\code{NGBRegression$get_params()}}
\item \href{#method-NGBRegression-pred_dist}{\code{NGBRegression$pred_dist()}}
\item \href{#method-NGBRegression-clone}{\code{NGBRegression$clone()}}
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-NGBRegression-new"></a>}}
\if{latex}{\out{\hypertarget{method-NGBRegression-new}{}}}
\subsection{Method \code{new()}}{
Initialize NGBoost regression model.
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{NGBRegression$new(
Dist = NULL,
Score = NULL,
Base = NULL,
natural_gradient = TRUE,
n_estimators = as.integer(500),
learning_rate = 0.01,
minibatch_frac = 1,
col_sample = 1,
verbose = TRUE,
verbose_eval = as.integer(100),
tol = 1e-04,
random_state = NULL
)}\if{html}{\out{</div>}}
}
\subsection{Arguments}{
\if{html}{\out{<div class="arguments">}}
\describe{
\item{\code{Dist}}{Assumed distributional form of Y|X=x.}
\item{\code{Score}}{Rule to compare probabilistic predictions to the observed
data. A score from ngboost.scores, e.g. LogScore}
\item{\code{Base}}{Base learner to use in the boosting algorithm.
Any instantiated sklearn regressor, e.g. DecisionTreeRegressor()}
\item{\code{natural_gradient}}{Logical flag indicating whether the natural
gradient should be used}
\item{\code{n_estimators}}{The number of boosting iterations to fit}
\item{\code{learning_rate}}{The learning rate}
\item{\code{minibatch_frac}}{The percent subsample of rows to use in each
boosting iteration}
\item{\code{col_sample}}{The percent subsample of columns to use in each
boosting iteration}
\item{\code{verbose}}{Flag indicating whether output should be printed during
fitting}
\item{\code{verbose_eval}}{Increment (in boosting iterations) at which output
should be printed}
\item{\code{tol}}{Numerical tolerance to be used in optimization}
\item{\code{random_state}}{Seed for reproducibility.}
\item{\code{A}}{Distribution from ngboost.distns, e.g. Normal}
}
\if{html}{\out{</div>}}
}
\subsection{Returns}{
An NGBRegressor object that can be fit.
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-NGBRegression-fit"></a>}}
\if{latex}{\out{\hypertarget{method-NGBRegression-fit}{}}}
\subsection{Method \code{fit()}}{
An NGBRegressor object that can be fit.
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{NGBRegression$fit(
X,
Y,
X_val = NULL,
Y_val = NULL,
sample_weight = NULL,
val_sample_weight = NULL,
train_loss_monitor = NULL,
val_loss_monitor = NULL,
early_stopping_rounds = NULL
)}\if{html}{\out{</div>}}
}
\subsection{Arguments}{
\if{html}{\out{<div class="arguments">}}
\describe{
\item{\code{X}}{DataFrame object or List or numpy array of predictors (n x p)
in Numeric format}
\item{\code{Y}}{DataFrame object or List or numpy array of outcomes (n)
in numeric format. Should be floats for regression and integers from 0
to K-1 for K-class classification}
\item{\code{X_val}}{DataFrame object or List or numpy array of validation-set
predictors in numeric format}
\item{\code{Y_val}}{DataFrame object or List or numpy array of validation-set
outcomes in numeric format}
\item{\code{sample_weight}}{how much to weigh each example in the training set.
numpy array of size (n) (defaults to 1)}
\item{\code{val_sample_weight}}{How much to weigh each example in the validation
set. (defaults to 1)}
\item{\code{train_loss_monitor}}{A custom score or set of scores to track on the
training set during training. Defaults to the score defined in the
NGBoost constructor.}
\item{\code{val_loss_monitor}}{A custom score or set of scores to track on the
validation set during training. Defaults to the score defined in the
NGBoost constructor}
\item{\code{early_stopping_rounds}}{The number of consecutive boosting
iterations during which the loss has to increase before the algorithm
stops early.}
}
\if{html}{\out{</div>}}
}
\subsection{Returns}{
NULL
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-NGBRegression-feature_importances"></a>}}
\if{latex}{\out{\hypertarget{method-NGBRegression-feature_importances}{}}}
\subsection{Method \code{feature_importances()}}{
Return the feature importances for all parameters in the
distribution (the higher, the more important the feature).
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{NGBRegression$feature_importances()}\if{html}{\out{</div>}}
}
\subsection{Returns}{
A data frame
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-NGBRegression-plot_feature_importance"></a>}}
\if{latex}{\out{\hypertarget{method-NGBRegression-plot_feature_importance}{}}}
\subsection{Method \code{plot_feature_importance()}}{
Plot feature importance
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{NGBRegression$plot_feature_importance()}\if{html}{\out{</div>}}
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-NGBRegression-predict"></a>}}
\if{latex}{\out{\hypertarget{method-NGBRegression-predict}{}}}
\subsection{Method \code{predict()}}{
Point prediction of Y at the points X=x
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{NGBRegression$predict(X, max_iter = NULL)}\if{html}{\out{</div>}}
}
\subsection{Arguments}{
\if{html}{\out{<div class="arguments">}}
\describe{
\item{\code{X}}{DataFrame object or List or numpy array of predictors (n x p)
in numeric Format}
\item{\code{max_iter}}{Get the prediction at the specified number of boosting
iterations}
}
\if{html}{\out{</div>}}
}
\subsection{Returns}{
Numpy array of the estimates of Y
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-NGBRegression-staged_pred_dist"></a>}}
\if{latex}{\out{\hypertarget{method-NGBRegression-staged_pred_dist}{}}}
\subsection{Method \code{staged_pred_dist()}}{
Predict the conditional distribution of Y at the points X=x
at multiple boosting iterations
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{NGBRegression$staged_pred_dist(X, max_iter = NULL)}\if{html}{\out{</div>}}
}
\subsection{Arguments}{
\if{html}{\out{<div class="arguments">}}
\describe{
\item{\code{X}}{DataFrame object or List or numpy array of predictors (n x p)
in numeric Format}
\item{\code{max_iter}}{Get the prediction at the specified number of boosting
iterations}
}
\if{html}{\out{</div>}}
}
\subsection{Returns}{
A list of NGBoost distribution objects, one per boosting stage
up to max_iter.
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-NGBRegression-staged_pred"></a>}}
\if{latex}{\out{\hypertarget{method-NGBRegression-staged_pred}{}}}
\subsection{Method \code{staged_pred()}}{
Point prediction of Y at the points X=x at multiple boosting
iterations.
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{NGBRegression$staged_pred(X, max_iter = NULL)}\if{html}{\out{</div>}}
}
\subsection{Arguments}{
\if{html}{\out{<div class="arguments">}}
\describe{
\item{\code{X}}{DataFrame object or List or numpy array of predictors (n x p)
in numeric Format}
\item{\code{max_iter}}{Get the prediction at the specified number of boosting
iterations}
}
\if{html}{\out{</div>}}
}
\subsection{Returns}{
A list of NGBoost distribution objects, one per boosting stage
up to max_iter.
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-NGBRegression-set_params"></a>}}
\if{latex}{\out{\hypertarget{method-NGBRegression-set_params}{}}}
\subsection{Method \code{set_params()}}{
Set the parameters of this estimator.
The method works on simple estimators as well as on nested objects
(such as :class:\code{~sklearn.pipeline.Pipeline}). The latter have
parameters of the form \verb{<component>__<parameter>} so that it's
possible to update each component of a nested object.
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{NGBRegression$set_params(...)}\if{html}{\out{</div>}}
}
\subsection{Arguments}{
\if{html}{\out{<div class="arguments">}}
\describe{
\item{\code{...}}{dict (a named R list). Estimator parameters.}
}
\if{html}{\out{</div>}}
}
\subsection{Returns}{
self : estimator instance. Estimator instance.
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-NGBRegression-get_params"></a>}}
\if{latex}{\out{\hypertarget{method-NGBRegression-get_params}{}}}
\subsection{Method \code{get_params()}}{
Get parameters for this estimator.
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{NGBRegression$get_params(deep = TRUE)}\if{html}{\out{</div>}}
}
\subsection{Arguments}{
\if{html}{\out{<div class="arguments">}}
\describe{
\item{\code{deep}}{bool, default = TRUE
If True, will return the parameters for this estimator and
contained subobjects that are estimators.}
}
\if{html}{\out{</div>}}
}
\subsection{Returns}{
params. A dict (R list). Parameter names mapped to their values.
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-NGBRegression-pred_dist"></a>}}
\if{latex}{\out{\hypertarget{method-NGBRegression-pred_dist}{}}}
\subsection{Method \code{pred_dist()}}{
Predict the conditional distribution of Y at the points X=x
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{NGBRegression$pred_dist(X, max_iter = NULL)}\if{html}{\out{</div>}}
}
\subsection{Arguments}{
\if{html}{\out{<div class="arguments">}}
\describe{
\item{\code{X}}{DataFrame object or List or numpy array of predictors (n x p) in
numeric format.}
\item{\code{max_iter}}{get the prediction at the specified number of boosting
iterations.}
}
\if{html}{\out{</div>}}
}
\subsection{Details}{
See for available methods \code{\link{NGBDistReg}}
}
\subsection{Returns}{
A NGBDistReg Class
}
}
\if{html}{\out{<hr>}}
\if{html}{\out{<a id="method-NGBRegression-clone"></a>}}
\if{latex}{\out{\hypertarget{method-NGBRegression-clone}{}}}
\subsection{Method \code{clone()}}{
The objects of this class are cloneable with this method.
\subsection{Usage}{
\if{html}{\out{<div class="r">}}\preformatted{NGBRegression$clone(deep = FALSE)}\if{html}{\out{</div>}}
}
\subsection{Arguments}{
\if{html}{\out{<div class="arguments">}}
\describe{
\item{\code{deep}}{Whether to make a deep clone.}
}
\if{html}{\out{</div>}}
}
}
}