skl_to_pmml module

skl_to_pmml.any_in(seq_a, seq_b)[source]
skl_to_pmml.get_PMML_kwargs(model, derived_col_names, col_names, target_name, mining_imp_val, categoric_values)[source]

It returns all the pmml elements.

Parameters:
  • model – An instance of Scikit-learn model.
  • derived_col_names (List) – Contains column names after preprocessing
  • col_names (List) – Contains list of feature/column names.
  • target_name (String) – Name of the target column .
  • mining_imp_val (tuple) – Contains the mining_attributes,mining_strategy, mining_impute_value
  • categoric_values (tuple) – Contains Categorical attribute names and its values
Returns:

algo_kwargs – Get the PMML model argument based on scikit learn model object

Return type:

Dictionary

skl_to_pmml.get_bayes_inputs(model, derived_col_names)[source]

It returns the Bayes Input element of the model .

Parameters:
  • model – An instance of Scikit-learn model.
  • derived_col_names (List) – Contains column names after preprocessing.
Returns:

Returns a BayesInput instance.

Return type:

bayes_inputs

skl_to_pmml.get_bayes_output(model, target_name)[source]

It returns the Bayes Output element of the model

Parameters:
  • model – An instance of Scikit-learn model.
  • target_name (String) – Name of the Target column.
Returns:

Returns a BayesOutput instance

Return type:

BayesOutput

skl_to_pmml.get_categoric_pred(row_idx, der_fld_idx, model_coef, class_lbls, class_attribute)[source]
Parameters:
  • row_idx (int) – Contains an integer value to index attribute/column names
  • der_fld_idx (int) – Contains an integer value to differentiate between linear and svm models
  • model_coef (array) – Contains the estimators coefficient values
  • class_lbls (list) – Contains the list of categorical values
  • class_attribute (tuple) – Contains Categorical attribute name
Returns:

categoric_predictor – Returns a list with instances of nyoka categorical predictor class

Return type:

list

skl_to_pmml.get_classid(class_attribute, feat_name)[source]
Parameters:
  • class_attribute – Contains the name of the attribute/column that contains categorical values
  • feat_name (string) – Contains the name of the attribute/column
Returns:

class_idx – Returns an integer value that will represent each categorical value

Return type:

int

skl_to_pmml.get_classificationMethod(model)[source]

It returns the Classification Model name of the model.

Parameters:model – A Scikit-learn model instance.
Returns:
Return type:Returns the classification method of the SVM model
skl_to_pmml.get_comparison_measure(model)[source]

It return the Comparison measure element.

Parameters:model – An instance of Scikit-learn model.
Returns:Returns a ComparisonMeasure instance.
Return type:comp_measure
skl_to_pmml.get_data_dictionary(model, feature_names, target_name, categoric_values)[source]

It returns the Data Dictionary element.

Parameters:
  • model – A Scikit-learn model instance.
  • feature_names (List) – Contains the list of feature/column name.
  • target_name (List) – Name of the Target column.
  • categoric_values (tuple) – Contains Categorical attribute names and its values
Returns:

Return the dataDictionary instance

Return type:

data_dict

skl_to_pmml.get_dtype(feat_value)[source]

It return the data type of the value.

Parameters:feat_value – Contains a value for finding the its data type.
Returns:
Return type:Returns the respective data type of that value.
skl_to_pmml.get_ensemble_models(model, derived_col_names, col_names, target_name, mining_imp_val, categoric_values)[source]

It returns the Mining Model element of the model

Parameters:
  • model – An instance of Scikit-learn model.
  • derived_col_names (List) – Contains column names after preprocessing.
  • col_names (List) – Contains list of feature/column names.
  • target_name (String) – Name of the Target column.
  • mining_imp_val (tuple) – Contains the mining_attributes,mining_strategy, mining_impute_value.
  • categoric_values (tuple) – Contains Categorical attribute names and its values
Returns:

mining_models – Returns the MiningModel of the respective ensemble model

Return type:

List

skl_to_pmml.get_funct(sk_model)[source]

It returns the activation fucntion of the model.

Parameters:model – A Scikit-learn model instance.
Returns:a_fn – Returns the activation function.
Return type:String
skl_to_pmml.get_header()[source]

It returns the Header element of the pmml.

header :
Returns the header of the pmml.
skl_to_pmml.get_inline_table(model)[source]

It Returns the Inline Table element of the model.

Parameters:model – An instance of Scikit-learn model.
Returns:Returns a InlineTable instance.
Return type:InlineTable
skl_to_pmml.get_inner_segments(model, derived_col_names, col_names, index)[source]

It returns the Inner segments of the model.

Parameters:
  • model – A Scikit-learn model instance.
  • derived_col_names (List) – Contains column names after preprocessing.
  • col_names (List) – Contains list of feature/column names.
  • index (Integer) – The index of the estimator for the model
Returns:

segments – Get the Segments for the Segmentation element.

Return type:

List

skl_to_pmml.get_instance_fields(derived_col_names, target_name)[source]

It returns the Instance field element.

Parameters:
  • derived_col_names (List) – Contains column names after preprocessing.
  • target_name (String) – Name of the Target column.
Returns:

Returns a InstanceFields instance

Return type:

InstanceFields

skl_to_pmml.get_kernel_type(model)[source]

It returns the kernel type element.

Parameters:model – A Scikit-learn model instance.
Returns:kernel_kwargs – Get the respective kernel type of the SVM model.
Return type:Dictionary
skl_to_pmml.get_knn_inputs(col_names)[source]

It returns the KNN Inputs element.

Parameters:col_names (List) – Contains list of feature/column names.
Returns:Returns a KNNInputs instance.
Return type:KNNInputs
skl_to_pmml.get_mining_func(model)[source]

It returns the name of the mining function of the model.

Parameters:model – A Scikit-learn model instance.
Returns:func_name – Returns the function name of the model
Return type:String
skl_to_pmml.get_mining_schema(model, feature_names, target_name, mining_imp_val)[source]

It returns the Mining Schema of the model.

Parameters:
  • model – A Scikit-learn model instance.
  • feature_names (List) – Contains the list of feature/column name.
  • target_name (String) – Name of the Target column.
  • mining_imp_val (tuple) – Contains the mining_attributes,mining_strategy, mining_impute_value.
Returns:

Get the MiningSchema element

Return type:

MiningSchema

skl_to_pmml.get_model_kwargs(model, col_names, target_name, mining_imp_val)[source]

It returns all the model element for a specific model.

Parameters:
  • model – An instance of Scikit-learn model.
  • col_names (List) – Contains list of feature/column names.
  • target_name (String) – Name of the Target column.
  • mining_imp_val (tuple) – Contains the mining_attributes,mining_strategy, mining_impute_value
Returns:

model_kwargs – Returns functionname, MiningSchema and Output of the sk_model object

Return type:

Dictionary

skl_to_pmml.get_multiple_model_method(model)[source]

It returns the name of the Multiple Model Chain element of the model.

Parameters:model – A Scikit-learn model instance
Returns:
Return type:The multiple model method for a mining model.
skl_to_pmml.get_naiveBayesModel(model, derived_col_names, col_names, target_name, mining_imp_val)[source]

It returns the Naive Bayes Model element of the model.

Parameters:
  • model – An instance of Scikit-learn model.
  • derived_col_names (List) – Contains column names after preprocessing.
  • col_names (List) – Contains list of feature/column names.
  • target_name (String) – Name of the Target column.
Returns:

naive_bayes_model – Returns the NaiveBayesModel

Return type:

List

skl_to_pmml.get_nearestNeighbour_model(model, derived_col_names, col_names, target_name, mining_imp_val)[source]

It returns the Nearest Neighbour model element.

Parameters:
  • model – An instance of Scikit-learn model.
  • derived_col_names (List) – Contains column names after preprocessing
  • col_names (List) – Contains list of feature/column names.
  • target_name (String) – Name of the Target column.
Returns:

Returns a nearest neighbour model instance

Return type:

nearest_neighbour_model

skl_to_pmml.get_neural_layer(model, feature_names, target_name)[source]

It returns the Neural Layer and Neural Ouptput element.

Parameters:
  • model – A Scikit-learn model instance.
  • feature_names (List) – Contains the list of feature/column name.
  • target_name (String) – Name of the Target column.
Returns:

  • all_neuron_layer (List) – Return the list of NeuralLayer elelemt.
  • neural_output_element – Return the NeuralOutput element instance

skl_to_pmml.get_neural_models(model, derived_col_names, col_names, target_name, mining_imp_val)[source]

It returns Neural Network element of the model.

Parameters:
  • model – A Scikit-learn model instance.
  • derived_col_names (List) – Contains column names after preprocessing.
  • col_names (List) – Contains list of feature/column names.
  • target_name (String) – Name of the Target column.
  • mining_imp_val (tuple) – Contains the mining_attributes,mining_strategy, mining_impute_value.
Returns:

neural_model – Model attributes for PMML file.

Return type:

List

skl_to_pmml.get_neuron_input(feature_names)[source]

It returns the Neural Input element.

Parameters:feature_names (List) – Contains the list of feature/column name.
Returns:Returns the NeuralInputs element
Return type:neural_input_element
skl_to_pmml.get_node(model, features_names, main_model=None)[source]

It return the Node element of the model.

Parameters:
  • model – An instance of the estimator of the tree object.
  • features_names (List) – Contains the list of feature/column name.
  • main_model – A Scikit-learn model instance.
Returns:

Get all the underlying Nodes.

Return type:

_getNode

skl_to_pmml.get_numeric_pred(row_idx, der_fld_idx, model_coef, der_fld_name)[source]
Parameters:
  • row_idx (int) – Contains an integer value to index attribute/column names
  • der_fld_idx (int) – Contains an integer value to differentiate between linear and svm models
  • model_coef (array) – Contains the estimators coefficient values
  • der_fld_name (string) – Contains the name of the attribute
Returns:

Returns an instances of nyoka numeric predictor class

Return type:

num_pred

skl_to_pmml.get_outer_segmentation(model, derived_col_names, col_names, target_name, mining_imp_val, categoric_values)[source]

It returns the Segmentation element of the model.

Parameters:
  • model – A Scikit-learn model instance.
  • derived_col_names (List) – Contains column names after preprocessing.
  • col_names (List) – Contains list of feature/column names.
  • target_name (String) – Name of the Target column.
  • mining_imp_val (tuple) – Contains the mining_attributes,mining_strategy, mining_impute_value
  • categoric_values (tuple) – Contains Categorical attribute names and its values
Returns:

A segmentation instance.

Return type:

segmentation

skl_to_pmml.get_output(model, target_name)[source]

It returns the output element of the model.

Parameters:
  • model – A Scikit-learn model instance.
  • target_name (String) – Name of the Target column.
Returns:

Get the Output element.

Return type:

Output

skl_to_pmml.get_regr_predictors(model_coef, row_idx, feat_names, categoric_values)[source]
Parameters:
  • model_coef (array) – Contains the estimators coefficient values
  • row_idx (int) – Contains an integer value to differentiate between linear and svm models
  • feat_names (list) – Contains the list of feature/column names
  • categoric_values (tuple) – Contains Categorical attribute names and its values
Returns:

predictors – Returns a list with instances of nyoka numeric/categorical predictor class

Return type:

list

skl_to_pmml.get_regrs_models(model, derived_col_names, col_names, target_name, mining_imp_val, categoric_values)[source]

It returns the Regression Model element of the model

Parameters:
  • model – A Scikit-learn model instance.
  • derived_col_names (List) – Contains column names after preprocessing.
  • col_names (List) – Contains list of feature/column names.
  • target_name (String) – Name of the Target column.
  • mining_imp_val (tuple) – Contains the mining_attributes,mining_strategy, mining_impute_value
  • categoric_values (tuple) – Contains Categorical attribute names and its values
Returns:

regrs_models – Returns a regression model of the respective model

Return type:

List

skl_to_pmml.get_regrs_tabl(model, feature_names, target_name, categoric_values)[source]

It returns the Regression Table element of the model.

Parameters:
  • model – A Scikit-learn model instance.
  • derived_col_names (List) – Contains column names after preprocessing.
  • target_name (String) – Name of the Target column.
  • categoric_values (tuple) – Contains Categorical attribute names and its values
Returns:

merge – Returns a list of Regression Table.

Return type:

List

skl_to_pmml.get_segments(model, derived_col_names, col_names, target_name, mining_imp_val, categoric_values)[source]

It returns the Segment element of the model.

Parameters:
  • model – A Scikit-learn model instance.
  • derived_col_names (List) – Contains column names after preprocessing.
  • col_names (List) – Contains list of feature/column names.
  • target_name (String) – Name of the Target column.
  • mining_imp_val (tuple) – Contains the mining_attributes,mining_strategy, mining_impute_value
  • categoric_values (tuple) – Contains Categorical attribute names and its values
Returns:

A list of segment instances.

Return type:

segments

skl_to_pmml.get_segments_for_gbc(model, derived_col_names, col_names, target_name, mining_imp_val, categoric_values)[source]

It returns list of Segments element of the model.

Parameters:
  • model – A Scikit-learn model instance.
  • derived_col_names (List) – Contains column names after preprocessing.
  • col_names (List) – Contains list of feature/column names.
  • target_name (String) – Name of the Target column.
  • mining_imp_val (tuple) – Contains the mining_attributes,mining_strategy, mining_impute_value
  • categoric_values (tuple) – Contains Categorical attribute names and its values
Returns:

segments – Get the Segments for the Segmentation element.

Return type:

List

skl_to_pmml.get_super_cls_names(model_inst)[source]

It returns the set of Super class of the model.

model_inst:
Instance of the scikit-learn model
Returns:parents – Returns all the parent class of the model instance.
Return type:Set
skl_to_pmml.get_supportVectorMachine(model)[source]

It return the Support Vector Machine element.

Parameters:model – A Scikit-learn model instance.
Returns:support_vector_machines – Get the Support Vector Machine element which conatains targetCategory, alternateTargetCategory, SupportVectors, Coefficients
Return type:List
skl_to_pmml.get_supportVectorMachine_models(model, derived_col_names, col_names, target_names, mining_imp_val, categoric_values)[source]

It returns the Support Vector Machine Model element.

Parameters:
  • model – An instance of Scikit-learn model.
  • derived_col_names (List) – Contains column names after preprocessing.
  • col_names (List) – Contains list of feature/column names.
  • target_names (String) – Name of the Target column.
  • mining_imp_val (tuple) – Contains the mining_attributes,mining_strategy, mining_impute_value
  • categoric_values (tuple) – Contains Categorical attribute names and its values
Returns:

supportVector_models – Returns SupportVectorMachineModel elements which contains classificationMethod, VectorDictionary, SupportVectorMachine, kernelType

Return type:

List

skl_to_pmml.get_targets(model, target_name)[source]

It returns the Target element of the model.

Parameters:
  • model – A Scikit-learn model instance.
  • target_name (String) – Name of the Target column.
Returns:

Returns a Target instance.

Return type:

targets

skl_to_pmml.get_threshold()[source]

It returns the Threshold value.

Returns:
Return type:Returns the Threshold value
skl_to_pmml.get_training_instances(model, derived_col_names, target_name)[source]

It returns the Training Instance element.

Parameters:
  • model – An instance of Scikit-learn model.
  • derived_col_names (List) – Contains column names after preprocessing
  • target_name (String) – Name of the Target column.
Returns:

Returns a TrainingInstances instance

Return type:

TrainingInstances

skl_to_pmml.get_tree_models(model, derived_col_names, col_names, target_name, mining_imp_val)[source]

It return Tree Model element of the model

Parameters:
  • model – A Scikit-learn model instance.
  • derived_col_names – Contains column names after preprocessing.
  • col_names (List) – Contains list of feature/column names.
  • target_name (String) – Name of the Target column.
  • mining_imp_val (tuple) – Contains the mining_attributes,mining_strategy, mining_impute_value
Returns:

tree_models – Get the TreeModel element.

Return type:

List

skl_to_pmml.get_vectorDictionary(model, derived_col_names, categoric_values)[source]

It return the Vector Dictionary element.

Parameters:
  • model – A Scikit-learn model instance.
  • derived_col_names (List) – Contains column names after preprocessing.
  • categoric_values (tuple) – Contains Categorical attribute names and its values
Returns:

A Vector Dictionary instance.

Return type:

VectorDictionary

skl_to_pmml.get_vectorfields(model_coef, feat_names, categoric_values)[source]

It return the Vector Fields .

Parameters:
  • model – A Scikit-learn model instance.
  • derived_col_names (List) – Contains column names after preprocessing.
  • categoric_values (tuple) – Contains Categorical attribute names and its values
Returns:

Return type:

Returns the Vector Dictionary instance for Support Vector model.

skl_to_pmml.get_version()[source]

It returns the pmml version .

Returns:version – Returns the version of the pmml.
Return type:String
skl_to_pmml.is_labelbinarizer(feat_name)[source]
Parameters:feat_name (string) – Contains the name of the attribute
Returns:
Return type:Returns a boolean value that states whether label binarizer has been applied or not
skl_to_pmml.is_stdscaler(feat_name)[source]
Parameters:feat_name (string) – Contains the name of the attribute
Returns:
Return type:Returns a boolean value that states whether standard scaler has been applied or not
skl_to_pmml.skl_to_pmml(pipeline, col_names, target_name, pmml_f_name='from_sklearn.pmml')[source]

Exports scikit-learn pipeline object into pmml

Parameters:
  • pipeline – Contains an instance of Pipeline with preprocessing and final estimator
  • col_names (List) – Contains list of feature/column names.
  • target_name (String) – Name of the target column.
  • pmml_f_name (String) – Name of the pmml file. (Default=’from_sklearn.pmml’)
Returns:

Return type:

Returns a pmml file