Model¶
This section documents the model components of the ensemble module.
model
¶
Defines sklearn.ensemble models interoperability.
This module provides wrappers around scikit-learn ensemble models, allowing them to be created using Nextmv option objects.
FUNCTION | DESCRIPTION |
---|---|
GradientBoostingRegressor |
Creates a sklearn.ensemble.GradientBoostingRegressor from options. |
RandomForestRegressor |
Creates a sklearn.ensemble.RandomForestRegressor from options. |
GradientBoostingRegressor
¶
GradientBoostingRegressor(
options: Options,
) -> GradientBoostingRegressor
Creates a sklearn.ensemble.GradientBoostingRegressor
from the provided
options.
You can import the GradientBoostingRegressor
function directly from ensemble
:
This function takes a Nextmv Options object and converts it to the appropriate parameters for the scikit-learn GradientBoostingRegressor.
PARAMETER | DESCRIPTION |
---|---|
|
Options for the GradientBoostingRegressor. Should contain parameters defined in GRADIENT_BOOSTING_REGRESSOR_PARAMETERS.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
GradientBoostingRegressor
|
A sklearn.ensemble.GradientBoostingRegressor instance. |
Examples:
>>> from nextmv_sklearn.ensemble.options import GradientBoostingRegressorOptions
>>> options = GradientBoostingRegressorOptions().to_nextmv()
>>> options.set("n_estimators", 100)
>>> options.set("learning_rate", 0.1)
>>> gbr = GradientBoostingRegressor(options)
Source code in nextmv-scikit-learn/nextmv_sklearn/ensemble/model.py
RandomForestRegressor
¶
RandomForestRegressor(
options: Options,
) -> RandomForestRegressor
Creates a sklearn.ensemble.RandomForestRegressor
from the provided options.
You can import the RandomForestRegressor
function directly from ensemble
:
This function takes a Nextmv Options object and converts it to the appropriate parameters for the scikit-learn RandomForestRegressor.
PARAMETER | DESCRIPTION |
---|---|
|
Options for the RandomForestRegressor. Should contain parameters defined in RANDOM_FOREST_REGRESSOR_PARAMETERS.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
RandomForestRegressor
|
A sklearn.ensemble.RandomForestRegressor instance. |
Examples:
>>> from nextmv_sklearn.ensemble.options import RandomForestRegressorOptions
>>> options = RandomForestRegressorOptions().to_nextmv()
>>> options.set("n_estimators", 100)
>>> options.set("max_depth", 10)
>>> rfr = RandomForestRegressor(options)