Version: 9.15.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 72 of file PMMLlib.hxx.

Member Function Documentation

◆ _getProp()

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 694 of file PMMLlib.cxx.

696 {
697  std::string name("");
698  if (_doc != NULL)
699  {
700  xmlChar *xp = _stringToXmlChar(prop);
701  xmlChar * attr ;
702  attr = xmlGetProp(node, xp );
703  if ( attr )
704  {
705  name = _xmlCharToString(attr );
706  xmlFree(attr);
707  }
708  xmlFree(xp);
709  }
710  return name;
711 }
xmlChar * _stringToXmlChar(const std::string &s) const
Definition: PMMLlib.cxx:683
std::string _xmlCharToString(const xmlChar *xs) const
Definition: PMMLlib.cxx:669
xmlDocPtr _doc
Associated DOM documents.
Definition: PMMLlib.hxx:78

◆ _stringToXmlChar()

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 683 of file PMMLlib.cxx.

684 {
685  return xmlCharStrdup(s.c_str());
686 }

◆ _xmlCharToString()

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 669 of file PMMLlib.cxx.

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

References yacsorb.CORBAEngineTest::i.

Member Data Documentation

◆ _currentModelName

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

Name of the current model

Definition at line 82 of file PMMLlib.hxx.

◆ _currentModelNode

xmlNodePtr PMMLlib::PMMLlib::_currentModelNode
private

Pointer to the current model node

Definition at line 84 of file PMMLlib.hxx.

◆ _currentModelType

PMMLType PMMLlib::PMMLlib::_currentModelType
private

Type of the current model.

Definition at line 83 of file PMMLlib.hxx.

◆ _currentNode

xmlNodePtr PMMLlib::PMMLlib::_currentNode
private

Pointer to the current node

Definition at line 80 of file PMMLlib.hxx.

◆ _doc

xmlDocPtr PMMLlib::PMMLlib::_doc
private

Associated DOM documents.

Definition at line 78 of file PMMLlib.hxx.

◆ _log

bool PMMLlib::PMMLlib::_log
private

Log Printing.

Definition at line 76 of file PMMLlib.hxx.

◆ _nbModels

int PMMLlib::PMMLlib::_nbModels
private

Number of models (all kinds)

Definition at line 81 of file PMMLlib.hxx.

◆ _pmmlFile

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

Name of the associated PMML file.

Definition at line 77 of file PMMLlib.hxx.

◆ _rootNode

xmlNodePtr PMMLlib::PMMLlib::_rootNode
private

Root node of the document.

Definition at line 79 of file PMMLlib.hxx.


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