Fix MLflow model logging warnings

Added input_example parameter to auto-infer model signature and
explicitly set artifact_path parameter to remove deprecation warnings.

This improves MLflow tracking by:
- Auto-generating model signature from training data
- Using correct parameter names for MLflow 3.x
- Enabling better model serving and inference validation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Alexis Bruneteau 2025-10-01 20:01:05 +02:00
parent 22db96b3eb
commit cb7b80ca6a

View File

@ -137,7 +137,13 @@ def main():
# Try to log model to MLflow (if permissions allow) # Try to log model to MLflow (if permissions allow)
try: try:
mlflow.sklearn.log_model(model, "model") # Create input example for model signature
input_example = X_train.head(1)
mlflow.sklearn.log_model(
model,
artifact_path="model",
input_example=input_example
)
print("\nModel logged to MLflow successfully!") print("\nModel logged to MLflow successfully!")
except Exception as e: except Exception as e:
print(f"\nWarning: Could not log model to MLflow: {e}") print(f"\nWarning: Could not log model to MLflow: {e}")