sharkpy.saving
Functions
|
Save the trained model to a .joblib file with enhanced error handling. |
|
Load a saved SharkPy model from a .joblib file with enhanced error handling. |
Module Contents
- sharkpy.saving.save_model(self, model, name='shark_model', directory='models')[source]
Save the trained model to a .joblib file with enhanced error handling.
- Parameters:
model (object) – Trained ML model object
name (str, optional) – Filename without extension (default: “shark_model”)
directory (str, optional) – Folder where the model will be saved (default: “models”)
- Returns:
Path to the saved model if successful
- Return type:
str
- Raises:
ValueError – If model is None or not trained
OSError – If directory creation or file writing fails
- sharkpy.saving.load_model(self, model_path)[source]
Load a saved SharkPy model from a .joblib file with enhanced error handling.
- Parameters:
model_path (str) – Path to the saved .joblib model file
- Returns:
The loaded model object
- Return type:
object
- Raises:
FileNotFoundError – If model file doesn’t exist
ValueError – If file is not a valid model