Base Model¶
-
class
python.model.base.
BaseModel
(file_name)[source]¶ Bases:
object
Abstract class that handles the loaded model.
-
family
= ''¶
-
features
()[source]¶ Get the features of the model
The returned list contains records. Each record contais (at least) the name and type of the variable. If the model supports feature importances calculation (if the clasifier has feature_importances_ atribute), they will also be present.
- Returns
Model features.
- Return type
- Raises
RuntimeError – If the model is not ready.
-
property
info
¶ Get model information.
This function gives complete description of the model. The returned ibject contais the following keys:
metadata (
dict
): Model metadata (seemetadata()
).- model (
dict
): Context information of the learnt model. - type (
str
): Type of the underlying model object.
- predictor_type (
str
): It could be the same as ‘type’. However, for sklearn.pipeline.Pipeline it will output the class of the predictor inside it.
- is_explainable (
bool
): True if the model class allows SHAP explanations to be computed.
- task (
str
): Task type. Either ‘BINARY_CLASSIFICATION’, ‘MULTILABEL_CLASSIFICATION’ or ‘REGRESSION’
- class_names (
list
orNone
): Class names if defined (for classification only).
- type (
- Returns
Information about the model.
- Return type
- Raises
RuntimeError – If the model is not ready.
- model (
-
is_ready
()[source]¶ Check if model is already loaded.
- Returns
Is the model already loaded and ready for predictions?
- Return type
-
load
()[source]¶ Launch model loading in a separated thread
Once it finishes, the instance _is_ready parameter is set to True.
The loaded object is expected to be a
dict
containing the following keys: model (model object) and metadata (dict
). The later contains one or two elements: features (list
ofdict
) with at least the name and type of the variables and optional class_names (list
ofstr
) with the list of class-names in order (for classification).
-
property
metadata
¶ Get metadata of the model_name.
- Returns
Metadata of the model containing information about the features and classes (optional)
- Return type
- Raises
RuntimeError – If the model is not ready.
-
task_type
(as_text=False)[source]¶ Get task type of the model
Either ‘REGRESSION’, ‘CLASSIFICATION’, ‘BINARY_CLASSIFICATION’ or ‘MULTILABEL_CLASSIFICATION’.
- Returns
If as_text=False, returns the task of the model (classification, regression, etc.) as a
Task
class instance. If as_text=True, returns the task of the model as text.- Return type
Task
orstr
- Raises
RuntimeError – If the model is not ready.
-