sklearn_pmml_model.base
#
Module Contents#
Classes#
Base class for estimators, saving basic information on DataFields. |
|
Base class for classifiers, preparing classes, target fields. |
|
Base class for regressors. |
|
Mixin class to automatically one-hot encode categorical variables. |
|
Mixin class to automatically integer encode categorical variables. |
Functions#
|
Parse type defined in <DataField> object and returns it. |
|
Safe helper method to find XML elements with guaranteed return type. |
|
Convert <Array> or <SparseArray> element into list. |
|
Convert <SparseArray> element into list. |
Attributes#
- sklearn_pmml_model.base.array_regex#
- class sklearn_pmml_model.base.PMMLBaseEstimator(pmml)#
Bases:
sklearn.base.BaseEstimator
Base class for estimators, saving basic information on DataFields.
- Parameters:
- pmmlstr, object
Filename or file object containing PMML data.
- field_mapping()#
Map field name to a column index and lambda function that converts a value to the proper type.
- Returns:
- { str: (int, callable) }
Dictionary mapping column names to tuples with 1) index of the column and 2) type of the column.
- classmethod _get_param_names()#
Get parameter names for the estimator
- fields()#
Return an ordered mapping from field name to XML DataField or DerivedField element.
- Returns:
- OrderedDict { str: eTree.Element }
Where keys indicate field names, and values are XML elements.
- target_field()#
Return the XML DataField or DerivedField element corresponding to the classification target.
- Returns:
- eTree.Element
Representing the target field for classification, or None if no MiningSchema or MiningField specified.
- fit(x, y)#
Not supported: PMML models are already fitted.
- _prepare_data(X)#
- predict(X, *args, **kwargs)#
Predict class or regression value for X.
This call is preceded with a data preprocessing step, that enables data scaling and categorical feature encoding.
For more information on parameters, check out the specific implementation in the scikit-learn subclass.
- predict_proba(X, *args, **kwargs)#
Predict class probabilities for X.
This call is preceded with a data preprocessing step, that enables data scaling and categorical feature encoding.
For more information on parameters, check out the specific implementation in the scikit-learn subclass.
- sklearn_pmml_model.base.get_type(data_field, derives=None)#
Parse type defined in <DataField> object and returns it.
- Parameters:
- data_fieldeTree.Element
<DataField> or <DerivedField> XML element that describes a column.
- deriveseTree.Element
<DataField> XML element that the derived field derives.
- Returns:
- callable
Type of the value, as a callable function.
- class sklearn_pmml_model.base.PMMLBaseClassifier(pmml)#
Bases:
PMMLBaseEstimator
Base class for classifiers, preparing classes, target fields.
- Parameters:
- pmmlstr, object
Filename or file object containing PMML data.
- class sklearn_pmml_model.base.PMMLBaseRegressor(pmml)#
Bases:
PMMLBaseEstimator
Base class for regressors.
- Parameters:
- pmmlstr, object
Filename or file object containing PMML data.
- sklearn_pmml_model.base.findall(element, path)#
Safe helper method to find XML elements with guaranteed return type.
- sklearn_pmml_model.base.parse_array(array)#
Convert <Array> or <SparseArray> element into list.
- Parameters:
- arrayeTree.Element (Array or SparseArray)
PMML <Array> or <SparseArray> element, or type-prefixed variant (e.g., <REAL-Array>).
- Returns:
- outputlist
Python list containing the items described in the PMML array element.
- sklearn_pmml_model.base.parse_sparse_array(array)#
Convert <SparseArray> element into list.
- Parameters:
- arrayeTree.Element (SparseArray)
PMML <SparseArray> element, or type-prefixed variant (e.g., <REAL-SparseArray>).
- Returns:
- outputlist
Python list containing the items described in the PMML sparse array element.