Close Menu
    Facebook X (Twitter) Instagram
    Articles Stock
    • Home
    • Technology
    • AI
    • Pages
      • About us
      • Contact us
      • Disclaimer For Articles Stock
      • Privacy Policy
      • Terms and Conditions
    Facebook X (Twitter) Instagram
    Articles Stock
    AI

    A Full Finish-to-Finish Coding Information to MLflow Experiment Monitoring, Hyperparameter Optimization, Mannequin Analysis, and Reside Mannequin Deployment

    Naveed AhmadBy Naveed Ahmad01/03/2026Updated:01/03/2026No Comments1 Min Read
    blog banner23


    best_C = greatest["params"]["C"]
    best_solver = greatest["params"]["solver"]
    
    
    final_pipe = Pipeline([
       ("scaler", StandardScaler()),
       ("clf", LogisticRegression(
           C=best_C,
           solver=best_solver,
           penalty="l2",
           max_iter=2000,
           random_state=42
       ))
    ])
    
    
    with mlflow.start_run(run_name="final_model_run") as final_run:
       final_pipe.match(X_train, y_train)
    
    
       proba = final_pipe.predict_proba(X_test)[:, 1]
       pred = (proba >= 0.5).astype(int)
    
    
       metrics = {
           "test_auc": float(roc_auc_score(y_test, proba)),
           "test_accuracy": float(accuracy_score(y_test, pred)),
           "test_precision": float(precision_score(y_test, pred, zero_division=0)),
           "test_recall": float(recall_score(y_test, pred, zero_division=0)),
           "test_f1": float(f1_score(y_test, pred, zero_division=0)),
       }
       mlflow.log_metrics(metrics)
       mlflow.log_params({"C": best_C, "solver": best_solver, "mannequin": "LogisticRegression+StandardScaler"})
    
    
       input_example = X_test.iloc[:5].copy()
       signature = infer_signature(input_example, final_pipe.predict_proba(input_example)[:, 1])
    
    
       model_info = mlflow.sklearn.log_model(
           sk_model=final_pipe,
           artifact_path="mannequin",
           signature=signature,
           input_example=input_example,
           registered_model_name=None,
       )
    
    
       print("Remaining run_id:", final_run.information.run_id)
       print("Logged mannequin URI:", model_info.model_uri)
    
    
       eval_df = X_test.copy()
       eval_df["label"] = y_test.values
    
    
       eval_result = mlflow.fashions.consider(
           mannequin=model_info.model_uri,
           information=eval_df,
           targets="label",
           model_type="classifier",
           evaluators="default",
       )
    
    
       eval_summary = {
           "metrics": {okay: float(v) if isinstance(v, (int, float, np.floating)) else str(v)
                       for okay, v in eval_result.metrics.objects()},
           "artifacts": {okay: str(v) for okay, v in eval_result.artifacts.objects()},
       }
       mlflow.log_dict(eval_summary, "analysis/eval_summary.json")



    Source link

    Naveed Ahmad

    Related Posts

    Let’s discover one of the best alternate options to Discord

    02/03/2026

    Polymarket noticed $529M traded on bets tied to bombing of Iran

    02/03/2026

    Find out how to Design a Manufacturing-Grade Multi-Agent Communication System Utilizing LangGraph Structured Message Bus, ACP Logging, and Persistent Shared State Structure

    02/03/2026
    Leave A Reply Cancel Reply

    Categories
    • AI
    Recent Comments
      Facebook X (Twitter) Instagram Pinterest
      © 2026 ThemeSphere. Designed by ThemeSphere.

      Type above and press Enter to search. Press Esc to cancel.