:py:mod:`sklearn_pmml_model.linear_model` ========================================= .. py:module:: sklearn_pmml_model.linear_model .. autoapi-nested-parse:: The :mod:`sklearn_pmml_model.linear_model` module implements generalized linear models. .. !! processed by numpydoc !! Submodules ---------- .. toctree:: :titlesonly: :maxdepth: 1 base/index.rst implementations/index.rst Package Contents ---------------- Classes ~~~~~~~ .. autoapisummary:: sklearn_pmml_model.linear_model.PMMLLinearRegression sklearn_pmml_model.linear_model.PMMLLogisticRegression sklearn_pmml_model.linear_model.PMMLRidge sklearn_pmml_model.linear_model.PMMLRidgeClassifier sklearn_pmml_model.linear_model.PMMLLasso sklearn_pmml_model.linear_model.PMMLElasticNet .. py:class:: PMMLLinearRegression(pmml) Bases: :py:obj:`sklearn_pmml_model.base.OneHotEncodingMixin`, :py:obj:`sklearn_pmml_model.base.PMMLBaseRegressor`, :py:obj:`sklearn.linear_model.LinearRegression` Ordinary least squares Linear Regression. The PMML model consists out of a element, containing at least one element. Every table element contains a element for numerical fields and per value of a categorical field, describing the coefficients. :Parameters: **pmml** : str, object Filename or file object containing PMML data. .. rubric:: Notes Specification: http://dmg.org/pmml/v4-3/Regression.html .. !! processed by numpydoc !! .. py:method:: fit(x, y) Not supported: PMML models are already fitted. .. !! processed by numpydoc !! .. py:method:: _more_tags() .. py:class:: PMMLLogisticRegression(pmml) Bases: :py:obj:`sklearn_pmml_model.base.OneHotEncodingMixin`, :py:obj:`sklearn_pmml_model.base.PMMLBaseClassifier`, :py:obj:`sklearn.linear_model.LogisticRegression` Logistic Regression (aka logit, MaxEnt) classifier. The PMML model consists out of a element, containing at least one element. Every table element contains a element for numerical fields and per value of a categorical field, describing the coefficients. :Parameters: **pmml** : str, object Filename or file object containing PMML data. .. rubric:: Notes Specification: http://dmg.org/pmml/v4-3/Regression.html .. !! processed by numpydoc !! .. py:method:: fit(x, y) Not supported: PMML models are already fitted. .. !! processed by numpydoc !! .. py:method:: _more_tags() .. py:class:: PMMLRidge(alpha=1.0, *, fit_intercept=True, copy_X=True, max_iter=None, tol=0.0001, solver='auto', positive=False, random_state=None) Bases: :py:obj:`sklearn_pmml_model.linear_model.base.PMMLGeneralizedLinearRegressor`, :py:obj:`sklearn.linear_model.Ridge` Linear least squares with l2 regularization. Minimizes the objective function:: ||y - Xw||^2_2 + alpha * ||w||^2_2 This model solves a regression model where the loss function is the linear least squares function and regularization is given by the l2-norm. Also known as Ridge Regression or Tikhonov regularization. This estimator has built-in support for multi-variate regression (i.e., when y is a 2d-array of shape (n_samples, n_targets)). :Parameters: **pmml** : str, object Filename or file object containing PMML data. .. rubric:: Notes Specification: http://dmg.org/pmml/v4-3/GeneralRegression.html .. !! processed by numpydoc !! .. py:method:: fit(x, y) Fit Ridge regression model. :Parameters: **X** : {ndarray, sparse matrix} of shape (n_samples, n_features) Training data. **y** : ndarray of shape (n_samples,) or (n_samples, n_targets) Target values. **sample_weight** : float or ndarray of shape (n_samples,), default=None Individual weights for each sample. If given a float, every sample will have the same weight. :Returns: **self** : object Fitted estimator. .. !! processed by numpydoc !! .. py:method:: _more_tags() .. py:class:: PMMLRidgeClassifier(pmml) Bases: :py:obj:`sklearn_pmml_model.linear_model.base.PMMLGeneralizedLinearClassifier`, :py:obj:`sklearn.linear_model.RidgeClassifier` Classifier using Ridge regression. This classifier first converts the target values into ``{-1, 1}`` and then treats the problem as a regression task (multi-output regression in the multiclass case). :Parameters: **pmml** : str, object Filename or file object containing PMML data. .. rubric:: Notes Specification: http://dmg.org/pmml/v4-3/GeneralRegression.html .. !! processed by numpydoc !! .. py:method:: fit(x, y) Fit Ridge classifier model. :Parameters: **X** : {ndarray, sparse matrix} of shape (n_samples, n_features) Training data. **y** : ndarray of shape (n_samples,) Target values. **sample_weight** : float or ndarray of shape (n_samples,), default=None Individual weights for each sample. If given a float, every sample will have the same weight. .. versionadded:: 0.17 *sample_weight* support to RidgeClassifier. :Returns: **self** : object Instance of the estimator. .. !! processed by numpydoc !! .. py:method:: _more_tags() .. py:class:: PMMLLasso(pmml) Bases: :py:obj:`sklearn_pmml_model.linear_model.base.PMMLGeneralizedLinearRegressor`, :py:obj:`sklearn.linear_model.Lasso` Linear Model trained with L1 prior as regularizer (aka the Lasso). The optimization objective for Lasso is:: (1 / (2 * n_samples)) * ||y - Xw||^2_2 + alpha * ||w||_1 Technically the Lasso model is optimizing the same objective function as the Elastic Net with ``l1_ratio=1.0`` (no L2 penalty). :Parameters: **pmml** : str, object Filename or file object containing PMML data. .. rubric:: Notes Specification: http://dmg.org/pmml/v4-3/GeneralRegression.html .. !! processed by numpydoc !! .. py:method:: fit(x, y) Fit model with coordinate descent. :Parameters: **X** : {ndarray, sparse matrix} of (n_samples, n_features) Data. **y** : ndarray of shape (n_samples,) or (n_samples, n_targets) Target. Will be cast to X's dtype if necessary. **sample_weight** : float or array-like of shape (n_samples,), default=None Sample weights. Internally, the `sample_weight` vector will be rescaled to sum to `n_samples`. .. versionadded:: 0.23 **check_input** : bool, default=True Allow to bypass several input checking. Don't use this parameter unless you know what you do. :Returns: **self** : object Fitted estimator. .. rubric:: Notes Coordinate descent is an algorithm that considers each column of data at a time hence it will automatically convert the X input as a Fortran-contiguous numpy array if necessary. To avoid memory re-allocation it is advised to allocate the initial data in memory directly using that format. .. !! processed by numpydoc !! .. py:method:: _more_tags() .. py:class:: PMMLElasticNet(pmml) Bases: :py:obj:`sklearn_pmml_model.linear_model.base.PMMLGeneralizedLinearRegressor`, :py:obj:`sklearn.linear_model.ElasticNet` Linear regression with combined L1 and L2 priors as regularizer. Minimizes the objective function:: 1 / (2 * n_samples) * ||y - Xw||^2_2 + alpha * l1_ratio * ||w||_1 + 0.5 * alpha * (1 - l1_ratio) * ||w||^2_2 If you are interested in controlling the L1 and L2 penalty separately, keep in mind that this is equivalent to:: a * ||w||_1 + 0.5 * b * ||w||_2^2 where:: alpha = a + b and l1_ratio = a / (a + b) The parameter l1_ratio corresponds to alpha in the glmnet R package while alpha corresponds to the lambda parameter in glmnet. Specifically, l1_ratio = 1 is the lasso penalty. Currently, l1_ratio <= 0.01 is not reliable, unless you supply your own sequence of alpha. :Parameters: **pmml** : str, object Filename or file object containing PMML data. .. rubric:: Notes Specification: http://dmg.org/pmml/v4-3/GeneralRegression.html .. !! processed by numpydoc !! .. py:method:: fit(x, y) Fit model with coordinate descent. :Parameters: **X** : {ndarray, sparse matrix} of (n_samples, n_features) Data. **y** : ndarray of shape (n_samples,) or (n_samples, n_targets) Target. Will be cast to X's dtype if necessary. **sample_weight** : float or array-like of shape (n_samples,), default=None Sample weights. Internally, the `sample_weight` vector will be rescaled to sum to `n_samples`. .. versionadded:: 0.23 **check_input** : bool, default=True Allow to bypass several input checking. Don't use this parameter unless you know what you do. :Returns: **self** : object Fitted estimator. .. rubric:: Notes Coordinate descent is an algorithm that considers each column of data at a time hence it will automatically convert the X input as a Fortran-contiguous numpy array if necessary. To avoid memory re-allocation it is advised to allocate the initial data in memory directly using that format. .. !! processed by numpydoc !! .. py:method:: _more_tags()