    

 ## On this page

  

 

 # CustomModelInterface Struct Reference

 Last update: 16.07.2025 

This class provides an API for the CustomModels to be implemented in Python. It is exported as an director through SWIG and the user will be able to derive from it in Python. [More...](struct_custom_model_interface.xhtml#details)

## <a name="pub-methods"></a>Public Member Functions

<a id="a31de2088e35819f6e03dc305bcc22294"></a>virtual string [\_\_class\_name\_internal\_\_](struct_custom_model_interface.xhtml#a31de2088e35819f6e03dc305bcc22294) () Internal helper function to use with de-/serialization.   
 virtual [Matrix](class_matrix.xhtml) [activeVariables](struct_custom_model_interface.xhtml#aa6fb875d0085ac970498de0cf24647e0) () Returns a vector describing which input variable was active during training. [More...](#aa6fb875d0085ac970498de0cf24647e0)  
 <a id="a4b26dc532338309b6aaba464c015fe2c"></a> [CustomModelInterface](struct_custom_model_interface.xhtml#a4b26dc532338309b6aaba464c015fe2c) () Creates an default initialized instance of this class.   
 virtual [deserialize](struct_custom_model_interface.xhtml#acffc114f2bfcb5ebd08ffb8db009a434) (string state) This function allows an instance of the python model to deserialize its state from the given string. How this is done needs to be implemented in Python. [More...](#acffc114f2bfcb5ebd08ffb8db009a434)  
 virtual [Matrix](class_matrix.xhtml) [evaluate](struct_custom_model_interface.xhtml#a5c383d2586219fc4db627879e98f0d0d) ([Matrix](class_matrix.xhtml) samples) Destroys an instance of this class. [More...](#a5c383d2586219fc4db627879e98f0d0d)  
 <a id="a0a80533187874ed1fb8458190de5d3e5"></a>virtual [ModelDataWrapper](class_model_data_wrapper.xhtml) [getModelData](struct_custom_model_interface.xhtml#a0a80533187874ed1fb8458190de5d3e5) () Obtain data necessary to built a model, mainly used for hybrid models where the build is performed in python but the inference in C++.   
 <a id="a4a179290ad6c3a55cec6fcc203b9a58f"></a>virtual string [getModelName](struct_custom_model_interface.xhtml#a4a179290ad6c3a55cec6fcc203b9a58f) () Obtain the class name for which a c++ model will be created for hybrid approximation.   
 <a id="a606d9f4f5d66eab5fa0a749c04346563"></a>virtual bool [isHybrid](struct_custom_model_interface.xhtml#a606d9f4f5d66eab5fa0a749c04346563) () Indicates whether this model is hybrid and thus, the approximation happens on C++ side.   
 virtual int [numCoeffs](struct_custom_model_interface.xhtml#a9731fbb8f1d0c9b6680e3837887b0fdf) () Returns the number of model coefficients used for the regression. [More...](#a9731fbb8f1d0c9b6680e3837887b0fdf)  
 virtual int [numVariables](struct_custom_model_interface.xhtml#acc63ea1db26d95738466bccb94d6c7ad) () Returns the number of active variables selected during the training process of the model. [More...](#acc63ea1db26d95738466bccb94d6c7ad)  
 virtual quality\_measure::Residuals [residuals](struct_custom_model_interface.xhtml#ab6b1de8c8ced0af688df281adecfdfcc) () Return the residuals that from the training to evaluate the quality measure with. [More...](#ab6b1de8c8ced0af688df281adecfdfcc)  
 virtual string [serialize](struct_custom_model_interface.xhtml#a09bb54030260cdeef6d3b2d5ed92f075) () This function returns the serialized data from the Python of the [CustomModelInterface](struct_custom_model_interface.xhtml "This class provides an API for the CustomModels to be implemented in Python. It is exported as an dir...") to be included in the [CustomModel](class_custom_model.xhtml). It needs to be overloaded in Python. [More...](#a09bb54030260cdeef6d3b2d5ed92f075)  
 <a id="details" name="details"></a>## Detailed Description

This class provides an API for the CustomModels to be implemented in Python. It is exported as an director through SWIG and the user will be able to derive from it in Python.



## Member Function Documentation

<a id="aa6fb875d0085ac970498de0cf24647e0"></a>## [◆ ](#aa6fb875d0085ac970498de0cf24647e0)activeVariables()

 virtual [Matrix](class_matrix.xhtml) activeVariables  ( )   virtual 

Returns a vector describing which input variable was active during training.

Returnsvector v with v\[i\] == 0 if input i was not active, v\[i\] == 1 otherwise 



<a id="acffc114f2bfcb5ebd08ffb8db009a434"></a>## [◆ ](#acffc114f2bfcb5ebd08ffb8db009a434)deserialize()

 virtual deserialize  ( string  *state*)   virtual 

This function allows an instance of the python model to deserialize its state from the given string. How this is done needs to be implemented in Python.

Parameters stateThe serialization as produced by the serialize function 



<a id="a5c383d2586219fc4db627879e98f0d0d"></a>## [◆ ](#a5c383d2586219fc4db627879e98f0d0d)evaluate()

 virtual [Matrix](class_matrix.xhtml) evaluate  ( [Matrix](class_matrix.xhtml)  *samples*)   virtual 

Destroys an instance of this class.

Evaluate the model on the given sample inputs and return the values

Parameters samplesThe given values ReturnsThe models values on the given samples 



<a id="a9731fbb8f1d0c9b6680e3837887b0fdf"></a>## [◆ ](#a9731fbb8f1d0c9b6680e3837887b0fdf)numCoeffs()

 virtual int numCoeffs  ( )   virtual 

Returns the number of model coefficients used for the regression.

ReturnsAn integer 



<a id="acc63ea1db26d95738466bccb94d6c7ad"></a>## [◆ ](#acc63ea1db26d95738466bccb94d6c7ad)numVariables()

 virtual int numVariables  ( )   virtual 

Returns the number of active variables selected during the training process of the model.

ReturnsAn integer 



<a id="ab6b1de8c8ced0af688df281adecfdfcc"></a>## [◆ ](#ab6b1de8c8ced0af688df281adecfdfcc)residuals()

 virtual quality\_measure::Residuals residuals  ( )   virtual 

Return the residuals that from the training to evaluate the quality measure with.

ReturnsAn instance of the [Residuals](class_residuals.xhtml "The estimator class creates an abstraction for classes the QualityMeasure may be evaluated for in the...") class with the residuals from the training 



<a id="a09bb54030260cdeef6d3b2d5ed92f075"></a>## [◆ ](#a09bb54030260cdeef6d3b2d5ed92f075)serialize()

 virtual string serialize  ( )   virtual 

This function returns the serialized data from the Python of the [CustomModelInterface](struct_custom_model_interface.xhtml "This class provides an API for the CustomModels to be implemented in Python. It is exported as an dir...") to be included in the [CustomModel](class_custom_model.xhtml). It needs to be overloaded in Python.

ReturnsThe serialization of the python instance