Salome HOME
PMML feature
[modules/yacs.git] / src / pmml / doc / doxygen / doxfiles / pyexamples.dox
1 /*!
2 \page pyexamples PMMLlib Python examples
3
4 \section sectionC Update a model in an existing PMML file :
5 The updating is done in two steps:
6 - 1 : delete the XML node of the model with method UnlinkNode();
7 - 2 : re-create the model.
8 \verbatim
9 PMMLlib p ( fileName, log );
10
11 # Set the model
12 p.SetCurrentModel( modelName, modelType );
13
14 # Delete the XML node of the model
15 p.UnlinkNode( );
16 # Recreate the model with new parameters
17 p.AddRegressionModel(« monModele », PMMLlib::kREGRESSION,  « regression » );
18 p.AddDataField( ….);
19
20 # Save the PMML file
21 p.Write( );
22 \endverbatim
23
24
25
26
27 \section sectionD Backup and update a model in an existing PMML file :
28 It is done in two steps:
29 - 1 : backup the model in an XML node with name modelName_<i> with method BackupNode();
30 - 2 : re-create the model.
31 \verbatim
32 PMMLlib p ( fileName, log );
33
34 # Set the model
35 p.SetCurrentModel( « monModele », modelType );
36
37 # Save the model in a new XML node
38 p.BackupNode( );
39 # Modify
40 p.AddRegressionModel(« monModele », PMMLlib::kREGRESSION,  « regression » );
41 p.AddDataField( ….);
42
43 # Save the PMML file
44 p.Write( );
45 \endverbatim
46
47
48
49 \section sectionE Add a model in an existing PMML file :
50
51 \verbatim
52 PMMLlib p ( fileName, log );
53
54 # Create the model
55 p.AddRegressionModel(« monModele », PMMLlib::kREGRESSION,  « regression » );
56 p.AddDataField( ….);
57
58 # Save the PMML file
59 p.Write( );
60 \endverbatim
61
62 \section sectionF Read a model and execute it :
63
64 \verbatim
65 P = PMMLlib( fileName, log );
66 p.SetCurrentModel( modelName, modelType );
67
68 pyStrCode = p.ExportPythonStr( « myPyFunc », « function header » ); 
69 exec pyStrCode;
70
71 # Eval myPyFunc which is now known as a python function
72 inputs = [1.,2.,3.,4.]
73 res = myPyFunc(inputs)
74 \endverbatim
75
76
77 */