focal.mlflow_utils module¶
- focal.mlflow_utils.log_classifier_test_results(tester: Any, run_name: str, model_path: str, dataset_path: str, confusion_matrix_path: str, classification_path: str, roc_path: str, true_labels: List[int], pred_labels: List[int], predictions: List[float], image_only: bool | None = False) None[source]¶
Logs summary to mlflow for testing cnn.
- Parameters:
tester (Any) – TestCNN class instance
run_name (str) – name of the mlflow run
model_path (str) – path to the cnn model
dataset_path (str) – path to the csv dataset
confusion_matrix_path (str) – path to save confusion matrix
classification_path (str) – path to save classification report
roc_path (str) – path to save roc plot
true_labels (List[int]) – true prediction labels
pred_labels (List[int]) – prediction results
predictions (List[float]) – float values of predictions
image_only (Optional[bool], optional) – if you want to test on only images
- focal.mlflow_utils.log_cnn_hyperparameter(config: dict, best_hp: dict, run_name: str, experiment_name: str | None = 'cnn_hyperparameter') None[source]¶
Logs cnn hyperparameter search to mlflow.
- Parameters:
config (json file) – configuration file with parameters
best_hp (Dict) – best hyperparameters from search
run_name (str) – name of mlflow run
experiment_name (str, optional) – Defaults to “cnn_hyperparameter”.
- focal.mlflow_utils.log_cnn_training_run(config: dict, model: Model, history: Any, dataset_path: str, artifacts: Dict[str, str | None] | None = None) None[source]¶
Logs training run details for CNN models using MLflow.
- Parameters:
config – Config object with hyperparameters.
model – Trained TensorFlow model.
history – Training history from model.fit().
artifacts (dict) – Optional dict with keys like “model”, “history”.
- focal.mlflow_utils.log_image_training_run(config: dict, model: Model, history: Any, dataset_path: str, artifacts: Dict[str, str | None] | None = None) None[source]¶
Logs training run details for CNN models (image_only) using MLflow.
- Parameters:
config – Config object with hyperparameters.
model – Trained TensorFlow model.
history – Training history from model.fit().
artifacts (dict) – Optional dict with keys like “model”, “history”.
- focal.mlflow_utils.log_mlp_hyperparameter(config: dict, best_hp: dict, run_name: str, experiment_name: str | None = 'mlp_hyperparameter') None[source]¶
Logs mlp hyperparamter results to mlflow.
- Parameters:
config (Any) – json config file
best_hp (Any) – best hyperparameters from search
run_name (str) – name of mlflow run
experiment_name (Optional[str], optional) – Defaults to “mlp_hyperparameter”.
- focal.mlflow_utils.log_mlp_training_run(config: dict, model: Model, history: Any, dataset_path: str, artifacts: Dict[str, str | None] | None = None) None[source]¶
Logs training run details for MLP models using MLflow.
- Parameters:
config – Config object with hyperparameters.
model – Trained TensorFlow model.
history – Training history from model.fit().
artifacts (dict) – Optional dict with keys like “model”, “history”.
- focal.mlflow_utils.log_regressor_test_results(model_path: str, run_name: str, dataset_path: str, experiment_name: str, tensions: List[float], predicted_delta: List[float], predictions: List[float], true_delta: List[float], mean: float) None[source]¶
Log mlp or xgb regression results to mlflow.
- Parameters:
model_path (str) – path to the trained model
run_name (str) – name of mlflow run
dataset_path (str) – path to the csv dataset
experiment_name (str) – name of mlflow experiment
tensions (List[float]) – list of current tensions
predicted_delta (List[float]) – list of predicted change in tensions
predictions (List[float]) – list of predicted absolute tensions
true_delta (List[float]) – list of true delta in tension
- Raises:
Exception – experiment failed to be created
- focal.mlflow_utils.log_rl_test(config: dict, run_name: str, info: List[Dict[str, Any]], experiment_name: str | None = 'rl_testing') None[source]¶
Logs reinforcement learning test to mlflow.
- Parameters:
config (json file) – configuration file with parameters
run_name (str) – name of mlflow run
info (Dict) – dictionary of saved info from training rl
experiment_name (str, optional) – Defaults to “rl_testing”.
- focal.mlflow_utils.log_xgb_training_run(config: dict, model: Model, X_train: Any, y_train: Any, dataset_path: str, evals_result: Dict[str, str | None] | None = None, artifacts: Dict[str, str | None] | None = None) None[source]¶
Logs training run details for CNN models using MLflow.
- Parameters:
config – Config object with hyperparameters.
model – Trained TensorFlow model.
history – Training history from model.fit().
artifacts (dict) – Optional dict with keys like “model”, “history”.