Model¶
This section documents the model components of the neural_network module.
model
¶
Defines sklearn.neural_network models interoperability.
This module provides functions for creating and configuring scikit-learn neural network models using Nextmv options.
FUNCTION | DESCRIPTION |
---|---|
MLPRegressor |
Create a Multi-layer Perceptron regressor with Nextmv options. |
MLPRegressor
¶
MLPRegressor(options: Options) -> MLPRegressor
Creates a sklearn.neural_network.MLPRegressor
from the provided options.
You can import the MLPRegressor
function directly from neural_network
:
This function takes Nextmv options and creates a scikit-learn MLPRegressor model with the specified parameters. The options must be compatible with the MLPRegressor parameters as defined in the options module.
PARAMETER | DESCRIPTION |
---|---|
|
Options for the MLPRegressor. These can include: - hidden_layer_sizes : str The ith element represents the number of neurons in the ith hidden layer. (e.g. "1,2,3") - activation : {'identity', 'logistic', 'tanh', 'relu'} Activation function for the hidden layer. - solver : {'lbfgs', 'sgd', 'adam'} The solver for weight optimization. - alpha : float Strength of the L2 regularization term. - And other parameters as defined in MLP_REGRESSOR_PARAMETERS.
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
MLPRegressor
|
A sklearn.neural_network.MLPRegressor instance configured with the provided options. |
Examples:
>>> import nextmv
>>> from nextmv_sklearn.neural_network import MLPRegressor
>>> from nextmv_sklearn.neural_network.options import MLPRegressorOptions
>>>
>>> # Create options
>>> options = MLPRegressorOptions().to_nextmv()
>>> options.set("hidden_layer_sizes", "100,50")
>>> options.set("activation", "relu")
>>>
>>> # Create regressor
>>> regressor = MLPRegressor(options)
>>> regressor.fit(X_train, y_train)
>>> predictions = regressor.predict(X_test)