sklearn_pmml_model.svm._base#

Module Contents#

Classes#

PMMLBaseSVM

Abstract class for Support Vector Machines.

Functions#

get_vectors(vector_dictionary, s)

Return support vector values, parsed as a numpy array.

get_alt_svms(svms, classes, target_class)

Find alternative SVMs (e.g., for target class 0, find the svms classifying 0 against 1, and 0 against 2).

get_overlapping_vectors(svms)

Return support vector ids that are present in all provided SVM elements.

get_coefficients(classes, n_support, support_ids, svms)

Return support vector coefficients.

class sklearn_pmml_model.svm._base.PMMLBaseSVM#

Abstract class for Support Vector Machines.

The PMML model consists out of a <SupportVectorMachineModel> element, containing a <SupportVectorMachine> element that contains a <SupportVectors> element describing support vectors, and a <Coefficients> element describing the coefficients for each support vector. Support vectors are referenced from a <VectorDictionary> element, in which the true support vectors are described using <VectorInstance> elements. Furthermore, the model contains one out of <LinearKernelType>, <PolynomialKernelType>, <RadialBasisKernelType> or <SigmoidKernelType> describing the kernel function used.

Parameters:
pmmlstr, object

Filename or file object containing PMML data.

Notes

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

sklearn_pmml_model.svm._base.get_vectors(vector_dictionary, s)#

Return support vector values, parsed as a numpy array.

sklearn_pmml_model.svm._base.get_alt_svms(svms, classes, target_class)#

Find alternative SVMs (e.g., for target class 0, find the svms classifying 0 against 1, and 0 against 2).

Parameters:
svmslist

List of eTree.Element objects describing the different one-to-one support vector machines in the PMML.

classesnumpy.array

The classes to be predicted by the model.

target_classstr

The target class.

Returns:
alt_svmslist

List of eTree.Elements filtered to only include SVMs comparing the target class against alternate classes.

sklearn_pmml_model.svm._base.get_overlapping_vectors(svms)#

Return support vector ids that are present in all provided SVM elements.

Parameters:
svmslist

List of eTree.Element objects describing the different one-to-one support vector machines in the PMML.

Returns:
outputset

Set containing all integer vector ids that are present in all provided SVM elements.

sklearn_pmml_model.svm._base.get_coefficients(classes, n_support, support_ids, svms)#

Return support vector coefficients.

Parameters:
classesnumpy.array

The classes to be predicted by the model.

n_supportnumpy.array

Numpy array describing the number of support vectors for each class.

support_ids: list

A list describing the ids of all support vectors in the model.

svmslist

List of eTree.Element objects describing the different one-to-one support vector machines in the PMML.