MCPcopy Create free account
hub / github.com/antmachineintelligence/mtgbmcode / fit

Method fit

python-package/lightgbmmt/sklearn.py:373–620  ·  view source on GitHub ↗

Build a gradient boosting model from the training set (X, y). Parameters ---------- X : array-like or sparse matrix of shape = [n_samples, n_features] Input feature matrix. y : array-like of shape = [n_samples] The target values (class labels

(self, X, y,
            sample_weight=None, init_score=None, group=None,
            eval_set=None, eval_names=None, eval_sample_weight=None,
            eval_class_weight=None, eval_init_score=None, eval_group=None,
            eval_metric=None, early_stopping_rounds=None, verbose=True,
            feature_name='auto', categorical_feature='auto',
            callbacks=None, init_model=None)

Source from the content-addressed store, hash-verified

371 return self
372
373 def fit(self, X, y,
374 sample_weight=None, init_score=None, group=None,
375 eval_set=None, eval_names=None, eval_sample_weight=None,
376 eval_class_weight=None, eval_init_score=None, eval_group=None,
377 eval_metric=None, early_stopping_rounds=None, verbose=True,
378 feature_name='auto', categorical_feature='auto',
379 callbacks=None, init_model=None):
380 """Build a gradient boosting model from the training set (X, y).
381
382 Parameters
383 ----------
384 X : array-like or sparse matrix of shape = [n_samples, n_features]
385 Input feature matrix.
386 y : array-like of shape = [n_samples]
387 The target values (class labels in classification, real numbers in regression).
388 sample_weight : array-like of shape = [n_samples] or None, optional (default=None)
389 Weights of training data.
390 init_score : array-like of shape = [n_samples] or None, optional (default=None)
391 Init score of training data.
392 group : array-like or None, optional (default=None)
393 Group data of training data.
394 eval_set : list or None, optional (default=None)
395 A list of (X, y) tuple pairs to use as validation sets.
396 eval_names : list of strings or None, optional (default=None)
397 Names of eval_set.
398 eval_sample_weight : list of arrays or None, optional (default=None)
399 Weights of eval data.
400 eval_class_weight : list or None, optional (default=None)
401 Class weights of eval data.
402 eval_init_score : list of arrays or None, optional (default=None)
403 Init score of eval data.
404 eval_group : list of arrays or None, optional (default=None)
405 Group data of eval data.
406 eval_metric : string, list of strings, callable or None, optional (default=None)
407 If string, it should be a built-in evaluation metric to use.
408 If callable, it should be a custom evaluation metric, see note below for more details.
409 In either case, the ``metric`` from the model parameters will be evaluated and used as well.
410 Default: 'l2' for LGBMRegressor, 'logloss' for LGBMClassifier, 'ndcg' for LGBMRanker.
411 early_stopping_rounds : int or None, optional (default=None)
412 Activates early stopping. The model will train until the validation score stops improving.
413 Validation score needs to improve at least every ``early_stopping_rounds`` round(s)
414 to continue training.
415 Requires at least one validation data and one metric.
416 If there's more than one, will check all of them. But the training data is ignored anyway.
417 To check only the first metric, set the ``first_metric_only`` parameter to ``True``
418 in additional parameters ``**kwargs`` of the model constructor.
419 verbose : bool or int, optional (default=True)
420 Requires at least one evaluation data.
421 If True, the eval metric on the eval set is printed at each boosting stage.
422 If int, the eval metric on the eval set is printed at every ``verbose`` boosting stage.
423 The last boosting stage or the boosting stage found by using ``early_stopping_rounds`` is also printed.
424
425 .. rubric:: Example
426
427 With ``verbose`` = 4 and at least one item in ``eval_set``,
428 an evaluation metric is printed every 4 (instead of 1) boosting stages.
429
430 feature_name : list of strings or 'auto', optional (default='auto')

Callers 12

fitMethod · 0.45
fitMethod · 0.45
fitMethod · 0.45
test_grid_searchMethod · 0.45
test_pandas_sparseMethod · 0.45
test_predictMethod · 0.45
test_metricsMethod · 0.45
test_inf_handleMethod · 0.45
test_nan_handleMethod · 0.45
fit_and_checkMethod · 0.45

Calls 9

get_paramsMethod · 0.95
typeEnum · 0.85
trainFunction · 0.85
popMethod · 0.80
appendMethod · 0.80
free_datasetMethod · 0.80
getMethod · 0.45

Tested by 9

test_grid_searchMethod · 0.36
test_pandas_sparseMethod · 0.36
test_predictMethod · 0.36
test_metricsMethod · 0.36
test_inf_handleMethod · 0.36
test_nan_handleMethod · 0.36
fit_and_checkMethod · 0.36