sklearn_pmml_model.linear_model.base#

Module Contents#

Classes#

PMMLGeneralizedLinearRegressor

Abstract class for Generalized Linear Models (GLMs).

PMMLGeneralizedLinearClassifier

Abstract class for Generalized Linear Models (GLMs).

Functions#

_get_coefficients(linear_model, model)

Obtain the coefficients for the GLM regression.

_get_intercept(model)

Find all parameters that are not included in the <ParamMatrix>.

class sklearn_pmml_model.linear_model.base.PMMLGeneralizedLinearRegressor(pmml)#

Bases: sklearn_pmml_model.base.OneHotEncodingMixin, sklearn_pmml_model.base.PMMLBaseRegressor

Abstract class for Generalized Linear Models (GLMs).

The PMML model consists out of a <GeneralRegressionModel> element, containing a <ParamMatrix> element that contains zero or more <PCell> elements describing the coefficients for each parameter. Parameters are described in the <PPMatrix> element, that maps parameters to fields in the data.

Parameters:
pmmlstr, object

Filename or file object containing PMML data.

Notes

Specification: http://dmg.org/pmml/v4-3/GeneralRegression.html

class sklearn_pmml_model.linear_model.base.PMMLGeneralizedLinearClassifier(pmml)#

Bases: sklearn_pmml_model.base.OneHotEncodingMixin, sklearn_pmml_model.base.PMMLBaseClassifier

Abstract class for Generalized Linear Models (GLMs).

The PMML model consists out of a <GeneralRegressionModel> element, containing a <ParamMatrix> element that contains zero or more <PCell> elements describing the coefficients for each parameter. Parameters are described in the <PPMatrix> element, that maps parameters to fields in the data.

Parameters:
pmmlstr, object

Filename or file object containing PMML data.

Notes

Specification: http://dmg.org/pmml/v4-3/GeneralRegression.html

sklearn_pmml_model.linear_model.base._get_coefficients(linear_model, model)#

Obtain the coefficients for the GLM regression.

Raises an exception when we notice non linear parameter configurations.

Parameters:
linear_modelPMMLGeneralizedLinearRegressor, PMMLGeneralizedLinearClassifier

The PMML class representing the classifier. Should contain at least target_field, fields and field_mapping properties.

modeleTree.Element

The <GeneralRegressionModel> element that is assumed to contains a <PPMatrix> and <ParamMatrix> element.

Returns:
coefficients: numpy.ndarray

Coefficient value for every field. Zero if not present.

sklearn_pmml_model.linear_model.base._get_intercept(model)#

Find all parameters that are not included in the <ParamMatrix>.

These constitute the intercept. In the very unlikely case there are multiple parameters fitting this criteria, we sum the result.

Parameters:
modeleTree.Element

The <GeneralRegressionModel> element that is assumed to contains a <PPMatrix> and <ParamMatrix> element.

Returns:
interceptfloat

Value of the intercept of the method.