Version: 8.3.0
PMMLlib::PMMLlib Class Reference

#include <PMMLlib.hxx>

Collaboration diagram for PMMLlib::PMMLlib:

Public Member Functions

PMMLLIB_EXPORT PMMLlib (std::string file, bool log=false)
 
PMMLLIB_EXPORT PMMLlib (bool log=false)
 This constructor is mandatory for Swig because it can be used with no parameters. More...
 
PMMLLIB_EXPORT ~PMMLlib ()
 
PMMLLIB_EXPORT void SetCurrentModel (std::string modelName, PMMLType type)
 
PMMLLIB_EXPORT void SetCurrentModel (std::string modelName)
 Throw an exception if there is no model or more than one model with name "modelName" in the PMML file. More...
 
PMMLLIB_EXPORT void SetCurrentModel ()
 Throw an exception if no model is found or if there are more than one model in the PMLL file. More...
 
PMMLLIB_EXPORT std::string makeLog () const
 
PMMLLIB_EXPORT void printLog () const
 
PMMLLIB_EXPORT void AddDataField (std::string name, std::string displayName, std::string optype, std::string dataType, std::string closure, double leftMargin, double rightMargin, bool interval=false)
 
PMMLLIB_EXPORT void AddMiningSchema (std::string name, std::string usageType)
 Common to all models. More...
 
PMMLLIB_EXPORT void SetHeader (std::string copyright, std::string description, std::string appName, std::string appVersion, std::string annotation)
 
PMMLLIB_EXPORT void UnlinkNode ()
 
PMMLLIB_EXPORT void BackupNode ()
 
PMMLLIB_EXPORT int GetModelsNb ()
 
PMMLLIB_EXPORT void Write ()
 
PMMLLIB_EXPORT void Write (std::string file)
 
PMMLLIB_EXPORT PMMLType GetCurrentModelType ()
 type is kUNDEFINED if no model is set or if model type is not handled More...
 
PMMLLIB_EXPORT std::string GetCurrentModelName ()
 name is "" if no model is set More...
 
PMMLLIB_EXPORT void AddNeuralNetwork (std::string modelName, PMMLMiningFunction functionName)
 Specific to NeuralNetwork. More...
 
PMMLLIB_EXPORT void AddNeuralInput (int id, std::string inputName, std::string optype, std::string dataType, double orig1, double norm1, double orig2, double norm2)
 Specific to NeuralNetwork. More...
 
PMMLLIB_EXPORT void AddNeuralLayer (PMMLActivationFunction activationFunction)
 Specific to NeuralNetwork. More...
 
PMMLLIB_EXPORT void AddNeuron (int id, double bias, int conNb, int firstFrom, std::vector< double > weights)
 Specific to NeuralNetwork. More...
 
PMMLLIB_EXPORT void AddNeuralOutput (int outputNeuron, std::string outputName, std::string optype, std::string dataType, double orig1, double norm1, double orig2, double norm2)
 Specific to NeuralNetwork. More...
 
PMMLLIB_EXPORT int GetNbInputs ()
 Specific to NeuralNetwork. More...
 
PMMLLIB_EXPORT int GetNbOutputs ()
 Specific to NeuralNetwork. More...
 
PMMLLIB_EXPORT std::string GetNameInput (int input_index)
 Specific to NeuralNetwork. More...
 
PMMLLIB_EXPORT std::string GetNameOutput (int output_index)
 Specific to NeuralNetwork. More...
 
PMMLLIB_EXPORT int GetNormalizationType ()
 Specific to NeuralNetwork. More...
 
PMMLLIB_EXPORT void GetNormalisationInput (int input_index, double *dnorm)
 Specific to NeuralNetwork. More...
 
PMMLLIB_EXPORT void GetNormalisationOutput (int output_index, double *dnorm)
 Specific to NeuralNetwork. More...
 
PMMLLIB_EXPORT int GetNbHiddenLayers ()
 Specific to NeuralNetwork. More...
 
PMMLLIB_EXPORT int GetNbLayers ()
 
PMMLLIB_EXPORT int GetNbNeuronsAtLayer (int layer_index)
 
PMMLLIB_EXPORT double GetNeuronBias (int layer_index, int neu_index)
 Specific to NeuralNetwork. More...
 
PMMLLIB_EXPORT double GetPrecNeuronSynapse (int layer_index, int neu_index, int prec_index)
 Specific to NeuralNetwork. More...
 
PMMLLIB_EXPORT void SetNeuralNetName (int ann_index, std::string ann_name)
 Not tested. More...
 
PMMLLIB_EXPORT std::string ReadNetworkStructure ()
 Specific to NeuralNetwork. More...
 
PMMLLIB_EXPORT void AddRegressionModel (std::string modelName, PMMLMiningFunction functionName, std::string targetFieldName)
 Specific to RegressionModel. More...
 
PMMLLIB_EXPORT void AddRegressionTable ()
 No property "intercept" will be set. More...
 
PMMLLIB_EXPORT void AddRegressionTable (double intercept)
 Specific to RegressionModel. More...
 
PMMLLIB_EXPORT void AddNumericPredictor (std::string neuronName, int exponent, double coefficient)
 Specific to RegressionModel. More...
 
PMMLLIB_EXPORT void AddPredictorTerm (double coefficient, std::vector< std::string > fieldRef)
 Specific to RegressionModel. More...
 
PMMLLIB_EXPORT bool HasIntercept ()
 Specific to RegressionModel. More...
 
PMMLLIB_EXPORT double GetRegressionTableIntercept ()
 Specific to RegressionModel. More...
 
PMMLLIB_EXPORT int GetNumericPredictorNb ()
 Specific to RegressionModel. More...
 
PMMLLIB_EXPORT int GetPredictorTermNb ()
 Specific to RegressionModel. More...
 
PMMLLIB_EXPORT std::string GetNumericPredictorName (int num_pred_index)
 Specific to RegressionModel. More...
 
PMMLLIB_EXPORT std::string GetPredictorTermName (int num_pred_index)
 Specific to RegressionModel. More...
 
PMMLLIB_EXPORT double GetNumericPredictorCoefficient (int num_pred_index)
 (The coefficient is the value of property "coefficient") More...
 
PMMLLIB_EXPORT double GetPredictorTermCoefficient (int pred_term_index)
 (The coefficient is the value of property "coefficient") More...
 
PMMLLIB_EXPORT int GetPredictorTermFieldRefNb (int pred_term_index)
 Specific to RegressionModel. More...
 
PMMLLIB_EXPORT std::string GetPredictorTermFieldRefName (int pred_term_index, int field_index)
 (The name is the value of property "field") More...
 
PMMLLIB_EXPORT std::string ReadRegressionStructure ()
 Specific to RegressionModel. More...
 
PMMLLIB_EXPORT void ExportCpp (std::string file, std::string functionName, std::string header)
 
PMMLLIB_EXPORT void ExportFortran (std::string file, std::string functionName, std::string header)
 
PMMLLIB_EXPORT void ExportPython (std::string file, std::string functionName, std::string header)
 
PMMLLIB_EXPORT std::string ExportPyStr (std::string functionName, std::string header)
 

Private Member Functions

xmlNodePtr GetChildByName (xmlNodePtr node, std::string nodename)
 
xmlNodePtr GetPtr (int ann_index, std::string name)
 
xmlNodePtr GetPtr (std::string ann_name, std::string name)
 
void CountModels ()
 
int CountNeuralNetModels ()
 
int CountRegressionModels ()
 
void SetRootNode ()
 
std::string GetModelName (xmlNodePtr node)
 
std::string GetTypeString ()
 
xmlNodePtr GetNeuralNetPtr (std::string ann_name)
 
xmlNodePtr GetNeuralNetPtr (int ann_index)
 
void CheckNeuralNetwork ()
 Called in all methods specific to the NeuralNetwork model. More...
 
xmlNodePtr GetRegressionPtr (int reg_index)
 
xmlNodePtr GetRegressionPtr (std::string reg_name)
 
void CheckRegression ()
 Called in all methods specific to the RegressionModel model. More...
 
void fillVectorsForExport (int nInput, int nOutput, int nHidden, int normType, std::vector< double > &minInput, std::vector< double > &maxInput, std::vector< double > &minOutput, std::vector< double > &maxOutput, std::vector< double > &valW)
 Specific to NeuralNetwork. More...
 
void ExportNeuralNetworkCpp (std::string file, std::string functionName, std::string header)
 Specific to NeuralNetwork. More...
 
void ExportNeuralNetworkFortran (std::string file, std::string functionName, std::string header)
 Specific to NeuralNetwork. More...
 
void ExportNeuralNetworkPython (std::string file, std::string functionName, std::string header)
 Specific to NeuralNetwork. More...
 
std::string ExportNeuralNetworkPyStr (std::string functionName, std::string header)
 Specific to NeuralNetwork. More...
 
void ExportLinearRegressionCpp (std::string, std::string, std::string)
 Specific to RegressionModel. More...
 
void ExportLinearRegressionFortran (std::string, std::string, std::string)
 Specific to Regression. More...
 
void ExportLinearRegressionPython (std::string, std::string, std::string)
 Specific to Regression. More...
 
std::string ExportLinearRegressionPyStr (std::string functionName, std::string header)
 Specific to Regression. More...
 
std::string _xmlCharToString (const xmlChar *xs) const
 
xmlChar * _stringToXmlChar (const std::string &s) const
 
std::string _getProp (const xmlNodePtr node, std::string const &prop) const
 

Private Attributes

bool _log
 Log Printing. More...
 
std::string _pmmlFile
 Name of the associated PMML file. More...
 
xmlDocPtr _doc
 Associated DOM documents. More...
 
xmlNodePtr _rootNode
 Root node of the document. More...
 
xmlNodePtr _currentNode
 Pointer to the current node. More...
 
int _nbModels
 Number of models (all kinds) More...
 
std::string _currentModelName
 Name of the current model. More...
 
PMMLType _currentModelType
 Type of the current model. More...
 
xmlNodePtr _currentModelNode
 Pointer to the current model node. More...
 

Detailed Description

Class PMMLlib

Definition at line 73 of file PMMLlib.hxx.

Member Function Documentation

std::string PMMLlib::PMMLlib::_getProp ( const xmlNodePtr  node,
std::string const &  prop 
) const
private

Get the value of a node property.

Parameters
nodeTag
propProperty
Returns
Constant libxml string.

Definition at line 695 of file PMMLlib.cxx.

References _doc, _stringToXmlChar(), and _xmlCharToString().

Referenced by AddNeuralInput(), AddNeuralLayer(), AddNeuralOutput(), AddNeuron(), fillVectorsForExport(), GetCurrentModelName(), GetModelName(), GetNameInput(), GetNameOutput(), GetNeuronBias(), GetNormalisationInput(), GetNormalisationOutput(), GetNormalizationType(), GetNumericPredictorCoefficient(), GetNumericPredictorName(), GetPrecNeuronSynapse(), GetPredictorTermCoefficient(), GetPredictorTermFieldRefName(), GetPredictorTermName(), GetPtr(), GetRegressionTableIntercept(), ReadNetworkStructure(), ReadRegressionStructure(), and SetCurrentModel().

697 {
698  std::string name("");
699  if (_doc != NULL)
700  {
701  xmlChar *xp = _stringToXmlChar(prop);
702  xmlChar * attr ;
703  attr = xmlGetProp(node, xp );
704  if ( attr )
705  {
706  name = _xmlCharToString(attr );
707  xmlFree(attr);
708  }
709  xmlFree(xp);
710  }
711  return name;
712 }
xmlChar * PMMLlib::PMMLlib::_stringToXmlChar ( const std::string &  s) const
private

Conversion from a standard C++ string to a libxml2 string (xmlChar *)

Parameters
sa constant C++ std::string.
Returns
a libxml string (contains the same text as s)

The caller of this function must free the result when it's not needed anymore (using xmlFree)

Conversion from a a standard C++ string to a libxml2 string (xmlChar *).

Parameters
sConstant C++ std::string (contains the same text as xs)
Returns
Constant libxml string.

Definition at line 684 of file PMMLlib.cxx.

Referenced by _getProp(), HasIntercept(), and SetRootNode().

685 {
686  return xmlCharStrdup(s.c_str());
687 }
std::string PMMLlib::PMMLlib::_xmlCharToString ( const xmlChar *  xs) const
private
  • Conversion from a libxml2 string (xmlChar *) to a standard C++ string.
Parameters
xsa constant libxml string.
Returns
a C++ std::string (contains the same text as xs).

Conversion from a libxml2 string (xmlChar *) to a standard C++ string.

Parameters
xsa constant libxml string.
Returns
a C++ std::string (contains the same text as xs).

Definition at line 670 of file PMMLlib.cxx.

References CORBAEngineTest::i.

Referenced by _getProp(), CountNeuralNetModels(), CountRegressionModels(), GetChildByName(), and GetCurrentModelType().

671 {
672  size_t i, L = xmlStrlen(xs);
673  std::string s;
674  s.resize(L);
675  for (i=0; *xs; s[i++] = *xs++);
676  return s;
677 }

Member Data Documentation

std::string PMMLlib::PMMLlib::_currentModelName
private

Name of the current model.

Definition at line 83 of file PMMLlib.hxx.

Referenced by AddNeuralNetwork(), AddRegressionModel(), BackupNode(), and SetCurrentModel().

PMMLType PMMLlib::PMMLlib::_currentModelType
private
xmlNodePtr PMMLlib::PMMLlib::_currentNode
private

Pointer to the current node.

Definition at line 81 of file PMMLlib.hxx.

Referenced by AddNeuralLayer(), AddNeuron(), AddNumericPredictor(), AddPredictorTerm(), and AddRegressionTable().

xmlDocPtr PMMLlib::PMMLlib::_doc
private

Associated DOM documents.

Definition at line 79 of file PMMLlib.hxx.

Referenced by _getProp(), GetPtr(), PMMLlib(), SetNeuralNetName(), SetRootNode(), Write(), and ~PMMLlib().

bool PMMLlib::PMMLlib::_log
private

Log Printing.

Definition at line 77 of file PMMLlib.hxx.

Referenced by BackupNode(), CountModels(), CountNeuralNetModels(), CountRegressionModels(), makeLog(), Write(), and ~PMMLlib().

int PMMLlib::PMMLlib::_nbModels
private

Number of models (all kinds)

Definition at line 82 of file PMMLlib.hxx.

Referenced by CountModels(), GetModelsNb(), and SetCurrentModel().

std::string PMMLlib::PMMLlib::_pmmlFile
private

Name of the associated PMML file.

Definition at line 78 of file PMMLlib.hxx.

Referenced by makeLog(), PMMLlib(), SetNeuralNetName(), and Write().

xmlNodePtr PMMLlib::PMMLlib::_rootNode
private

The documentation for this class was generated from the following files: