Skip to content

Options

This section documents the options components of the linear_model module.

options

Defines sklearn.linear_model options interoperability.

This module provides options for scikit-learn linear models to be used with Nextmv.

CLASS DESCRIPTION
LinearRegressionOptions

Options for the sklearn.linear_model.LinearRegression.

Variables

LINEAR_REGRESSION_PARAMETERS : list List of parameters for LinearRegression.

LINEAR_REGRESSION_PARAMETERS module-attribute

LINEAR_REGRESSION_PARAMETERS = [
    Option(
        name="fit_intercept",
        option_type=bool,
        description="Whether to calculate the intercept for this model.",
    ),
    Option(
        name="copy_X",
        option_type=bool,
        description="If True, X will be copied; else, it may be overwritten.",
    ),
    Option(
        name="n_jobs",
        option_type=int,
        description="The number of jobs to use for the computation.",
    ),
    Option(
        name="positive",
        option_type=bool,
        description="When set to True, forces the coefficients to be positive.",
    ),
]

List of parameters for scikit-learn's LinearRegression model.

You can import LINEAR_REGRESSION_PARAMETERS directly from linear_model:

from nextmv_sklearn.linear_model import LINEAR_REGRESSION_PARAMETERS

This list contains all the parameters that can be configured for a scikit-learn LinearRegression model when using it through Nextmv.

PARAMETER DESCRIPTION

fit_intercept

Whether to calculate the intercept for this model.

TYPE: bool

copy_X

If True, X will be copied; else, it may be overwritten.

TYPE: bool

n_jobs

The number of jobs to use for the computation.

TYPE: int

positive

When set to True, forces the coefficients to be positive.

TYPE: bool

See Also

LinearRegressionOptions : Class that provides options for LinearRegression.

LinearRegressionOptions

LinearRegressionOptions()

Options for the sklearn.linear_model.LinearRegression.

You can import the LinearRegressionOptions class directly from linear_model:

from nextmv_sklearn.linear_model import LinearRegressionOptions

This class provides an interface for configuring scikit-learn's LinearRegression model to work with Nextmv.

ATTRIBUTE DESCRIPTION
params

List of LinearRegression parameters.

TYPE: list

Examples:

>>> from nextmv_sklearn.linear_model import LinearRegressionOptions
>>> options = LinearRegressionOptions()
>>> nextmv_options = options.to_nextmv()
Source code in nextmv-scikit-learn/nextmv_sklearn/linear_model/options.py
def __init__(self):
    self.params = LINEAR_REGRESSION_PARAMETERS

params instance-attribute

to_nextmv

to_nextmv() -> Options

Converts the options to a Nextmv options object.

RETURNS DESCRIPTION
Options

A Nextmv options object containing the LinearRegression parameters.

Examples:

>>> options = LinearRegressionOptions()
>>> nextmv_options = options.to_nextmv()
Source code in nextmv-scikit-learn/nextmv_sklearn/linear_model/options.py
def to_nextmv(self) -> nextmv.Options:
    """Converts the options to a Nextmv options object.

    Returns
    -------
    nextmv.Options
        A Nextmv options object containing the LinearRegression parameters.

    Examples
    --------
    >>> options = LinearRegressionOptions()
    >>> nextmv_options = options.to_nextmv()
    """

    return nextmv.Options(*self.params)